mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 13:24:26 -04:00
added missing EVP_CIPHER_CTX_cleanup calls (issue #128)
This commit is contained in:
parent
261c7faa61
commit
f49f7ac763
1 changed files with 11 additions and 1 deletions
|
@ -61,7 +61,10 @@ bool RsAES::aes_crypt_8_16(const uint8_t *input_data,uint32_t input_data_length,
|
||||||
int f_len = 0;
|
int f_len = 0;
|
||||||
|
|
||||||
if(output_data_length < (uint32_t)c_len)
|
if(output_data_length < (uint32_t)c_len)
|
||||||
return false ;
|
{
|
||||||
|
EVP_CIPHER_CTX_cleanup(&e_ctx) ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
/* update ciphertext, c_len is filled with the length of ciphertext generated,
|
/* update ciphertext, c_len is filled with the length of ciphertext generated,
|
||||||
*len is the size of plaintext in bytes */
|
*len is the size of plaintext in bytes */
|
||||||
|
@ -69,6 +72,7 @@ bool RsAES::aes_crypt_8_16(const uint8_t *input_data,uint32_t input_data_length,
|
||||||
if(!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;
|
std::cerr << "RsAES: decryption failed at end. Check padding." << std::endl;
|
||||||
|
EVP_CIPHER_CTX_cleanup(&e_ctx) ;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +80,7 @@ bool RsAES::aes_crypt_8_16(const uint8_t *input_data,uint32_t input_data_length,
|
||||||
if(!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;
|
std::cerr << "RsAES: decryption failed at end. Check padding." << std::endl;
|
||||||
|
EVP_CIPHER_CTX_cleanup(&e_ctx) ;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +117,10 @@ bool RsAES::aes_decrypt_8_16(const uint8_t *input_data,uint32_t input_data_lengt
|
||||||
int f_len = 0;
|
int f_len = 0;
|
||||||
|
|
||||||
if(output_data_length < (uint32_t)c_len)
|
if(output_data_length < (uint32_t)c_len)
|
||||||
|
{
|
||||||
|
EVP_CIPHER_CTX_cleanup(&e_ctx) ;
|
||||||
return false ;
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
output_data_length = c_len ;
|
output_data_length = c_len ;
|
||||||
|
|
||||||
|
@ -122,6 +130,7 @@ bool RsAES::aes_decrypt_8_16(const uint8_t *input_data,uint32_t input_data_lengt
|
||||||
if(! 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;
|
std::cerr << "RsAES: decryption failed." << std::endl;
|
||||||
|
EVP_CIPHER_CTX_cleanup(&e_ctx) ;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +138,7 @@ bool RsAES::aes_decrypt_8_16(const uint8_t *input_data,uint32_t input_data_lengt
|
||||||
if(!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;
|
std::cerr << "RsAES: decryption failed at end. Check padding." << std::endl;
|
||||||
|
EVP_CIPHER_CTX_cleanup(&e_ctx) ;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue