iOSDev
iOSDev

Reputation: 3617

Java Server not able to encrypt/decrypt data with Blackberry's AESkey

I am developing a BlackBerry application where the server is in Java. Whenever AES encrypted data is sent to server along with PKCS5 Formatting,The server gets bad padding exception while decrypting it.

Upvotes: 1

Views: 1546

Answers (2)

Chochos
Chochos

Reputation: 5159

Is that the Blackberry or the server code? Have you tried using the standard JCE classes? something like this:

Cipher aes = Cipher.getInstance("AES/ECB/PKCS5Padding");
SecretKeySpec key = new SecretKeySpec(yourKeyBytes, "AES");
aes.init(Cipher.DECRYPT_MODE, key);
byte[] cleartext = aes.update(ciphertext, 0, ciphertext.length);

Upvotes: 1

Charlie Martin
Charlie Martin

Reputation: 112404

Make sure you're doing the padding etc in the right order first: pad then encrypt, decrypt then unpad.

  • Check the transmitted data length and make sure it's a multiple of blocksize.

  • Make sure blocksize is consistent in all the calls.

  • Make sure your crypto provider settings are exactly matching.

Upvotes: 1

Related Questions