Hello to everyone, I'm finding some issues using the symmetric encryption and decryption routines EVP_encrypt/decrypt. Here is the code of the function that I'm calling:
int cipher :: symm_encrypt(){ EVP_CIPHER_CTX_init(symm_ctx); init_symm_cipher(symm_encryption_alg); int cipher_text_length; int tmp_len; if(!EVP_EncryptUpdate(symm_ctx, buffer, &cipher_text_length, (unsigned char*) data.c_str(), MAX_MSG_SIZE)) return 0; if(!EVP_EncryptFinal_ex(symm_ctx, buffer + cipher_text_length, &tmp_len)) return 0; EVP_CIPHER_CTX_cleanup(symm_ctx); return 1; } Buffer is an unsigned char * dinamically initialized with: new unsigned char [4096] symm_encryption_alg is EVP_bf_cbc() symm_ctx is EVP_CIPHER_CTX_new(); Well it seems that after the execution of this function something spurious is written in memory, infact if I call the destructor of my class object "cipher" without calling this function everything works fine, otherwise sometimes I'm obtaining a segmentation fault. Using Valgrind it reports several errors about the function BF_encrypt() about the use of 4 unititialized bytes. Are there known issues about this function that could be related to this problem? Thanks in advance. Best Regards. Andrea Saracino