Hi,
I'm doing decryption with function:
int decrypt (unsigned const char *input, size_t inputSize, char *&output,
size_t &outputSize, unsigned char *key)
{
int outlen=0, tlen=0;
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX_init (& ctx);
EVP_DecryptInit (& ctx, EVP_bf_cbc (), key, (unsigned char*)iv);
output = new char[inputSize+1];
bzero(output,inputSize+1);
if (EVP_DecryptUpdate (& ctx, (uc*)output, & outlen, input, inputSize) != 1)
{
cerr<<"EVP_DecryptUpdate error !"<<endl;
exit(1);
}
if (EVP_DecryptFinal (& ctx, (uc*)output + outlen, & tlen) != 1)
{
cerr<<"EVP_DecryptFinal error !"<<endl;
exit(1);
}
outlen += tlen;
EVP_CIPHER_CTX_cleanup (& ctx);
outputSize=outlen;
return 0;
}
In the main() I have key:
unsigned char key[]={'a','b','c','\0'};
If I use this key and compile with -O2 option EVP_DecryptFianal fails.
But if I define key as:
static unsigned char key[]={'a','b','c','\0'};
it works. It also works in if I don't specify -O2 option.
What's happening ?
---------------------------------
Czy już jesteś w Yahoo!?
Masz dosyć spamu? Poczta Yahoo! dysponuje najlepszą ochroną przed spamem
http://pl.mail.yahoo.com