Topic
1 reply Latest Post - ‏2009-01-30T12:10:20Z by SystemAdmin
SystemAdmin
SystemAdmin
9394 Posts
ACCEPTED ANSWER

Pinned topic IOException: invalid padding on WM6

‏2009-01-28T09:21:40Z |
Hi,

I'm trying to interact with a server FTPS. I'm using WEME 6.1 on Windows Mobile 6.

Below my code (the server listen on 169.254.2.2:990, implicit SSL)




public 

static 

void main(String[] args) 

throws NoSuchAlgorithmException, KeyManagementException, IOException 
{ 

final String CRLF = 
"\r\n"; String buf = 
"";   SSLContext context = SSLContext.getInstance (
"ssl"); context.init(null, 

new TrustManager[]
{

new X509TrustManager() 
{ @Override 

public 

void checkClientTrusted(X509Certificate[] chain, String authType) 

throws CertificateException 
{ 
} @Override 

public 

void checkServerTrusted(X509Certificate[] chain, String authType) 

throws CertificateException 
{ 
} @Override 

public X509Certificate[] getAcceptedIssuers() 
{ 

return 

null; 
}
}
}, 

null); 
// open Socket piSocket = context.getSocketFactory().createSocket(
"169.254.2.2", 990); BufferedReader piIn = 

new BufferedReader(

new InputStreamReader(piSocket.getInputStream())); BufferedWriter piOut = 

new BufferedWriter(

new OutputStreamWriter(piSocket.getOutputStream())); 
// auth piOut.write(
"USER cyril" + CRLF); piOut.write(
"PASS asdf" + CRLF); piOut.flush(); 

while (!buf.startsWith(
"230")) 
{ buf = piIn.readLine(); System.out.println(buf); 
} 
// cwd piOut.write(
"CWD /test" + CRLF); piOut.flush(); buf = piIn.readLine(); System.out.println(buf); 
}


I compile in Java 6 with the Sun JDK and I use Retrotranslator to convert the bytecode in Java 1.4.

On the desktop with Sun JVM, the program is running without error. On the PocketPC, this exception is raised:


220-FileZilla Server version 0.9.29 beta 220-written by Tim Kosse (Tim.Kosse@gmx.de) 220 Please visit http:
//sourceforge.net/projects/filezilla/ 331 Password required 

for cyril 230 Logged on Exception in thread 
"main" java.io.IOException: invalid padding at com.ibm.oti.crypto.Util.unpadTLS10(Unknown Source) at com.ibm.oti.crypto.CL3BasedProvider.decryptImpl(Unknown Source) at com.ibm.oti.crypto.CL3BasedProvider.cryptUpdate(Unknown Source) at com.ibm.oti.crypto.Key.cryptFinish(Unknown Source) at com.ibm.j9.ssl.CipherAlgorithm.decipher(Unknown Source) at com.ibm.j9.jsse.SSLSocketImpl.readData(Unknown Source) at com.ibm.j9.jsse.SSLSocketImpl$SSLInputStream.read(Unknown Source) at java.io.InputStreamReader.fillbuf(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at java.io.BufferedReader.fillbuf(Unknown Source) at java.io.BufferedReader.readLine(Unknown Source) at idinfo.mobile.utils.TestFtps.main(Unknown Source)


We could see the challenge-response works until the CWD command.

Finally, I can see this log in the FileZilla Server Admin Interface

(000064) 28.01.2009 10:09:20 - (not logged in) (169.254.2.1)> Connected, sending welcome message... (000064) 28.01.2009 10:09:20 - (not logged in) (169.254.2.1)> 220-FileZilla Server version 0.9.29 beta (000064) 28.01.2009 10:09:20 - (not logged in) (169.254.2.1)> 220-written by Tim Kosse (Tim.Kosse@gmx.de) (000064) 28.01.2009 10:09:20 - (not logged in) (169.254.2.1)> 220 Please visit http:
//sourceforge.net/projects/filezilla/ (000064) 28.01.2009 10:09:22 - (not logged in) (169.254.2.1)> SSL connection established (000064) 28.01.2009 10:09:22 - (not logged in) (169.254.2.1)> USER cyril (000064) 28.01.2009 10:09:22 - (not logged in) (169.254.2.1)> 331 Password required 

for cyril (000064) 28.01.2009 10:09:22 - (not logged in) (169.254.2.1)> PASS **** (000064) 28.01.2009 10:09:22 - cyril (169.254.2.1)> 230 Logged on (000064) 28.01.2009 10:09:22 - cyril (169.254.2.1)> CWD /test (000064) 28.01.2009 10:09:22 - cyril (169.254.2.1)> 250 CWD successful. 
"/test" is current directory. (000064) 28.01.2009 10:09:22 - cyril (169.254.2.1)> (000064) 28.01.2009 10:09:22 - cyril (169.254.2.1)> 500 Syntax error, command unrecognized. (000064) 28.01.2009 10:09:23 - cyril (169.254.2.1)> disconnected.


I don't understand what is wrong. Could somebody help me?

Thanks
Cyril
Updated on 2009-01-30T12:10:20Z at 2009-01-30T12:10:20Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    9394 Posts
    ACCEPTED ANSWER

    Re: IOException: invalid padding on WM6

    ‏2009-01-30T12:10:20Z  in response to SystemAdmin
    After a lot of different test, I think it's a J9 bug with the CBC padding implementation.

    If I change the CWD location /test to /test0, /test01, /test012, /test0123, /test01234, /test012345 or /test0123456 it's working.

    But if I keep the /test location, or I set /test01234567 (8 bytes more than /test, so logically the same padding) it isn't working.

    How could I report the bug ?