bug fixing. Apparently still problems with AES padding.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6323 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-04-21 19:16:25 +00:00
parent 1c3ff8c54b
commit 5657ab9796
4 changed files with 60 additions and 14 deletions

View file

@ -23,6 +23,7 @@
*
*/
#include <iostream>
#include <openssl/evp.h>
#include <openssl/aes.h>
@ -65,10 +66,18 @@ bool RsAES::aes_crypt_8_16(const uint8_t *input_data,uint32_t input_data_length,
/* update ciphertext, c_len is filled with the length of ciphertext generated,
*len is the size of plaintext in bytes */
EVP_EncryptUpdate(&e_ctx, output_data, &c_len, input_data, input_data_length);
if(!EVP_EncryptUpdate(&e_ctx, output_data, &c_len, input_data, input_data_length))
{
std::cerr << "RsAES: decryption failed at end. Check padding." << std::endl;
return false ;
}
/* update ciphertext with the final remaining bytes */
EVP_EncryptFinal_ex(&e_ctx, output_data+c_len, &f_len);
if(!EVP_EncryptFinal_ex(&e_ctx, output_data+c_len, &f_len))
{
std::cerr << "RsAES: decryption failed at end. Check padding." << std::endl;
return false ;
}
output_data_length = c_len + f_len;
@ -109,10 +118,18 @@ bool RsAES::aes_decrypt_8_16(const uint8_t *input_data,uint32_t input_data_lengt
/* update ciphertext, c_len is filled with the length of ciphertext generated,
*len is the size of plaintext in bytes */
EVP_DecryptUpdate(&e_ctx, output_data, &c_len, input_data, input_data_length);
if(! EVP_DecryptUpdate(&e_ctx, output_data, &c_len, input_data, input_data_length))
{
std::cerr << "RsAES: decryption failed." << std::endl;
return false ;
}
/* update ciphertext with the final remaining bytes */
EVP_DecryptFinal_ex(&e_ctx, output_data+c_len, &f_len);
if(!EVP_DecryptFinal_ex(&e_ctx, output_data+c_len, &f_len))
{
std::cerr << "RsAES: decryption failed at end. Check padding." << std::endl;
return false ;
}
output_data_length = c_len + f_len;