Dear all,
Sorry to send the similar email again. I am quite frustrated here. I wish to
decode a big chunk of data array with Blowfish (key size 16 bytes), ECB
mode, and 1024 bytes block by block, like the following picture
|--------------------------|
| Big chunk of data |
|--------------------------|
||
\/
1024 bytes block
decryption with Blowfish
||
\/
Write the decrypted block
into new block
||
\/
|--------------------------|
| Decrypted data |
|--------------------------|
I have the following codes, but I know it is wrong... I wish you could help
me please to correct it a bit... THOUSAND THANKS.
================== the code =====================
// encryptedData is the char array which has the encrypted data
// decryptedData is the char array which is to store the decrypted data
// inbuf and outbuf are both 1024 bytes
// Decrypt the data
int kBufferSize = 1024;
EVP_CIPHER_CTX_init(&cipher);
EVP_DecryptInit(&cipher, EVP_bf_ecb(), BFkey, NULL);
int count = 0;
for (;;) {
inlen = 0;
for (int i=0; i<kBufferSize; i++) {
if (i+count < filesize) {
inbuf[i] = encryptedData[i+count];
inlen++;
}
}
if (!EVP_DecryptUpdate(&cipher, outbuf, &outlen, inbuf, inlen)) {
printf("ERROR: Content decryption error.");
exit(-1);
}
for (int j=0; j<kBufferSize; j++) {
decryptedData[j+count] = outbuf[j];
}
count += kBufferSize;
}
if (!EVP_DecryptFinal(&cipher, outbuf, &outlen)) {
printf("ERROR: Content decryption error");
exit(-1);
}
for (int k=1; k<outlen; k++) {
decryptedData[k+count] = outbuf[k];
}
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
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]