Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

javax.crypto.BadPaddingException: Invalid PKCS#5 padding length: 7

Former Member
0 Kudos

The exception was thrown when trying to decrypt the password while running the application inside NetWeaver AS.

The code example is:

Cipher decCipher = Cipher.getInstance("AES/CFB8/PKCS5Padding");

SecretKeySpec key = c();

AlgorithmParameterSpec paramSpec = d();

decCipher.init(2, key, paramSpec);

byte original[] = decCipher.doFinal(decode("2721838ACDF9805FD60063154D4EEF3B"));

And the exception stack trace is:

javax.crypto.BadPaddingException: Invalid PKCS#5 padding length: 7

at iaik.security.cipher.v.b(Unknown Source)

at iaik.security.cipher.z.b(Unknown Source)

at iaik.security.cipher.z.engineDoFinal(Unknown Source)

at javax.crypto.Cipher.doFinal(DashoA13*..)

Note that the same code would be able to decrypt the password correctly when running in NWDS (Eclipse) using sapjvm 5.

Thanks

1 REPLY 1

Former Member
0 Kudos

OK, I made a little bit progress on this --- it turns out the SAP NetWeaver is using IAIK by default as the security provider, which is incompitable with the Cipher which has been used to encrypt the password.

Now the question is how to remove, or not using IAIK package, in NetWeaver?