[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openssl-dev
Subject:    Interoperability of C++ libcrypto and Java bouncy castle
From:       ashuahen <ashuahen () gmail ! com>
Date:       2010-02-28 14:11:07
Message-ID: 27735202.post () talk ! nabble ! com
[Download RAW message or body]


I am using AES_CBC with padding (using PKCS#5 to pad) on C++ side:

AES_set_encrypt_key( keyBuf, 128, &key )
keyBuf contains key string
key is the key generated

Block Lenght is 16

AES_cbc_encrypt (ibuf, obuf, lenpad, &key, iv, AES_ENCRYPT)
ibuf = input data
obuf = encrypted data
lenpad = length of data (input data length + pad data length)
key = key generated by AES_set_encrypt_key
iv = initialization vector

On java side:
I am decrypting using following:
 
SecretKey aesKey = new SecretKeySpec(KeSo.getKey(keyBuffer), "AES");
keyBuffer: is same as KeyBuf @ C++ side

Cipher cipherDec = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC");
cipherDec.init(Cipher.DECRYPT_MODE, aesKey, iv); 
cipherDec.doFinal(enc);
enc: data to be encrypted in byte.

Problem
=======

I was using libcrypto.0.9.8a and every thing was working fine.
But as a part of upgrade on Sun SPARC licrypto0.9.8a is changed to
libcrypto.0.9.8k and things became worst. Encryption is not giving any
problem but during decryption with the same code I am getting
BadPaddingException.

Please help me out, this problem has made my life hell.

Thanks
Ashutosh
-- 
View this message in context: \
http://old.nabble.com/Interoperability-of-C%2B%2B-libcrypto-and-Java-bouncy-castle-tp27735202p27735202.html
 Sent from the OpenSSL - Dev mailing list archive at Nabble.com.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majordomo@openssl.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic