mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-17 05:22:31 -04:00
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:
parent
1c3ff8c54b
commit
5657ab9796
4 changed files with 60 additions and 14 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue