> buff = (char *)malloc(bptr->length); > memcpy(buff, bptr->data, bptr->length-1); > buff[bptr->length-1] = 0;
Umm, you don't copy the last byte of data. You don't allocate enough space to hold the data and a terminator. This is probably your main error. How will 'buff' hold a C-style string when it's only as many bytes as the data? (Remember, you need an extra byte for the terminator.) And why aren't you copying the last byte of data? And why are you writing a zero in the wrong place? And for the love of all that is holy, why are you copying the data into a temporary buffer just to copy it immediately into the final buffer? What purpose does the temporary buffer serve? You have to allocate it, copy out of it, and free it -- and for what purpose?! > When i use to encrypt data, i have not problems.. when i decrypt the > result of this code, i have not problem... when i decrypt with this > program, i have > 13015:error:06065064:digital envelope routines: > EVP_DecryptFinal_ex:bad decrypt:evp_enc.c:461: > The EVP_DecryptUpdate works ok, decrypt the info, but the rest > off encypted (the remaining encrypted data) is not decrypted, and > the tlen = 0. You treat the Base64 BIO as if it were a C-style string, but it's not. The Base64 BIO is just a chunk of arbitrary data. DS ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org