At 01:28 PM 2/23/2005 +0100, Manuel Sánchez Cuenca writeth: >Hello all, I have to write a C program which decrypts some data >encrypted by a java program. The java program is the following: >================================================================= > KeyGenerator key_gen = KeyGenerator.getInstance("Rijndael"); > SecretKey aes_key = (SecretKey)key_gen.generateKey(); > Cipher aes = Cipher.getInstance("Rijndael/CBC/PKCS5Padding", "IAIK"); > aes.init(Cipher.ENCRYPT_MODE, aes_key); > byte[] crypted = aes.doFinal(bb.array()); > byte[] iv = aes.getIV(); >================================================================= >and the C program: >================================================================= > char byte_aes_key[16]; // <---- the byte array obtained with >aes_key.getEncoded() in java > char byte_iv[16]; // <---- The iv from the java program > EVP_CIPHER_CTX ctx; > EVP_DecryptInit(&ctx, EVP_aes_128_cbc(), byte_aes_key, byte_iv); ^^^^^^^^^^^^^^^^^
This is the only thing that pops out immediately. Rijndael != AES. They are and aren't the same. AES has restricted block sizes, Rijndael (in its true form) doesn't - so make sure your blocks from the Java instance are the right size. I'd look around for the standard Rijndael and AES test vectors and check those against both implementations. When you can get the same output from both, then you are on the right track. Thomas J. Hruska [EMAIL PROTECTED] Shining Light Productions Home of the Nuclear Vision scripting language and ProtoNova web server. http://www.slproweb.com/ ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]