DEar all,
I am terribly sorry to bother you again. I have been seeking help and
trying myself with the problems, but I think you are the only one that can
really help me. Please help.
I am doing Blowfish encryption using Java IAIK cryptography library, ECB
mode, and key size is 16 bytes. But I wish to use Openssl cryptography
library to do the decryption, C++.
I have refered to the example on
http://www.openssl.org/docs/crypto/EVP_EncryptInit.html which deals with the
EVP symmetric enc/decryption. The snippet of the decryption code is as
follows:
----------------------------------------------------------------------------
--------
EVP_CipherInit(&ctx, EVP_bf_ecb(), NULL, NULL, 0);
EVP_CIPHER_CTX_set_key_length(&ctx, 16);
EVP_CipherInit(&ctx, NULL, contentKey, NULL, 0);
fin = fopen("C:\\My Project\\Practices\\Crypto\\Debug\\HelloWorld.sum",
"rb");
fout = fopen("C:\\My Project\\Practices\\Crypto\\Debug\\HelloWorld.pdf",
"wb");
for (;;) {
inlen = fread(inbuf, 1, 1024, fin);
if (inlen <= 0) break;
if (!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen)) {
printf("error1");
exit(-1);
}
fwrite(outbuf, 1, outlen, fout);
}
if (!EVP_CipherFinal(&ctx, outbuf, &outlen)) {
printf("error2");
exit(-1);
}
fwrite(outbuf, 1, outlen, fout);
----------------------------------------------------------------------------
--------
When I run this code, the decryption is done partially, (that means the
decryption is done partially in the file, part of the file remains
undecrypted, and perhaps damaged). The message "error2" is printed out.
Then, I suspected that because of the padding problem so I tried to look for
padding information, unfortunately I couldn't find any. Though in the same
resource, I found a function called "EVP_CIPHER_CTX_set_padding(...)" but
when I checked with the evp.h (openssl 0.9.6) I couldn't find this
function... Is it because it is from different version? Is there any other
way to do the padding?? Please help. Thousand thanks.
Best regards,
--------------------------------------------
Jordan Cheun Ngen, Chong
INF-4067 Universiteit Twente
Postbus 217
7500 AE Enschede
The Netherlands
Distributed and Embedded Systems (DIES)
--------------------------------------------
Office Phone: +31 53 4894655
Web site: http://www.cs.utwente.nl/~chong
Email Add.: [EMAIL PROTECTED]
============================================
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]