Hi, first of all i want to thank you for your great work.
I have some trouble using your AES-CBC encryption class.
On client side I have
var data = get_unencrypted_data();
var key_aes = generate_password(32);
var aes = new pidCrypt.AES.CBC();
aes.initEncrypt(data, key_aes, {nBits :256});
var encrypted_data = aes.encryptRaw();
encrypted_data = pidCryptUtil.encodeBase64(encrypted_data);
But when i do this, i have an error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt and my $unencrypted_data is empty. Any idea?
Thanks for your time
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-06-07
Ok, I didn't know that openSSL use salted data.
aes.encrypt() encode in base64 if I'm not wrong, so I send to the server side the result of aes.encrypt() "as is".
I started with this, now I have the same result than before :
error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
I'm sure that my key are good, I even tried whit hardcoded key for the same result.
Am I missing something?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you please check if you're able to decrypt the data using the openSSL commandline:
echo "U2FsdGVkX1+7T7HYXNW8HpURIz0aa5a5kYMebhcemqOVks2Nqg9oWjG7qYfBSRcH"|openssl enc -aes-256-cbc -a -d
If that works as expected, it is possible that the openssl_decrypt function you're using isn't working as expected. Assuming that you are using PHP's openssl_decrypt function, could you please check if the demo code at the end of this page does work for decrypting your input: http://php.net/manual/en/function.openssl-decrypt.php
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-06-11
Using openssl in commandline with 'password' work fine, but using this with openssl_decrypt return nothing (empty string, not bool(false))
I tried with sqAES.decrypt and it work perfectly fine, so it seem it was openssl fault all this time. Sorry for cursing you ^^
And again, thank for your time and your great work
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, first of all i want to thank you for your great work.
I have some trouble using your AES-CBC encryption class.
On client side I have
And on the server side I have
But when i do this, i have an error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt and my $unencrypted_data is empty. Any idea?
Thanks for your time
openssl needs a salted input (see http://www.cipherbox.org/wiki/index.php/Developer_documentation#OpenSSL_encrypted_data). Try to use aes.encrypt() instead of aes.encryptRaw(). This function returns a openssl compatible salted string.
Ok, I didn't know that openSSL use salted data.
aes.encrypt() encode in base64 if I'm not wrong, so I send to the server side the result of aes.encrypt() "as is".
I started with this, now I have the same result than before :
error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
I'm sure that my key are good, I even tried whit hardcoded key for the same result.
Am I missing something?
Could you please check if you're able to decrypt the data using the openSSL commandline:
If that works as expected, it is possible that the openssl_decrypt function you're using isn't working as expected. Assuming that you are using PHP's openssl_decrypt function, could you please check if the demo code at the end of this page does work for decrypting your input: http://php.net/manual/en/function.openssl-decrypt.php
Using openssl in commandline with 'password' work fine, but using this with openssl_decrypt return nothing (empty string, not bool(false))
I tried with sqAES.decrypt and it work perfectly fine, so it seem it was openssl fault all this time. Sorry for cursing you ^^
And again, thank for your time and your great work