Encryption in c++ and decryption in java
838507Mar 17 2011 — edited Mar 18 2011Hi,
I am having a sample programs in which C++ is using Cyassl library for AES encryption while JAVA is using JCA library (AES/CBC/PKCS5Padding) for decryption. I have same hard coded keys and IV in both c++ and Java. I am using AES256. While decryption I am getting following exception.
javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
at com.intel.kbd.util.SE_API_Impl.decrypt(SE_API_Impl.java:57)
at com.intel.kbd.util.SE_API_Impl.main(SE_API_Impl.java:179)
However Encryption by java and decryption by C++ is working fine with same configuration and in addition to this encryption and decryption by itself I mean encryption and decryption by Java itself is working fine, same with C++.
What will be the reason due to which Java is not able to decrypt the C++ encrypted string? Do I need to do any configuration changes?
Edited by: user3516155 on Mar 17, 2011 12:19 AM
Edited by: user3516155 on Mar 17, 2011 12:19 AM