Lawrence Bowie escribió:
Where do you hold your IVs for the C program? Are the Java and C
programs seperate or are you using
JNI?
Yes, I'm using jni, so I pass the IV as a parameter o a C function.
Also, I am not sure if "IAIK" is an actually optional Provider if you
are using JCE, possibly an
option using Bouncy Castle.... You also might try a different padding
as well ..
The big thing is that where are your IVs being written to and read from ?
LDB
Manuel Sánchez Cuenca wrote:
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);
int outlen;
res = EVP_DecryptUpdate(&ctx, decrypted, &outlen, encrypted,
encryptedlen);
=================================================================
but the decrypted message isn't correct. Can anybody give me any
suggestion?
Thanks in advance.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]
--
=======================================================
Manuel Sanchez Cuenca
Dept. Ingenieria de la Informacion y las Comunicaciones
Universidad de Murcia - España
Tlf: +34 968364644 - Fax: 968364151
email: [EMAIL PROTECTED]
www: http://livia.dif.um.es/~lolo
www: http://livia.dif.um.es/~irisgrid
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]