Yusuf Khan-YUK wrote:

> I tried using BlockSize() but my output was still the same. Thats
> because in my case, the the key size was 16 and BlockSize() also
> returned 16.

There in another mistake in your code, which I did not immediately
noticed; when you call: 

fread(buffer,sizeof(byte), KEYSIZE,fp);

you're assuming the input is multiple of KEYSIZE (or better of
BlockSize).
If that's not true, you implicitly append zeros at the end of your file
to allign with the block.
When the decryptor reverses the process it has no way of knowing the
real file size, and therefore he cannot truncate the file correctly (how
does it know how many zeros really belong to the plain-text file ?).

You have either to store the plain file length in the encrypted file or
to use/implement some padding scheme. Look at previous messages, there's
one named "questions on data block size?" where you can find an example.

> The version of crypto++ I am using is 4.2, in AESEcnryptor you can
> only specify the key, you cannot specify the password, or the iv

That's because it is only an encryptor. But you can easily convert a
password into a key using an hash function (say MD5). In this way you
can take variable length input password. 

The IV can be specified through a CBCPaddedEncryptor for example, which
can take the encryptor object (in your case AES) and the IV.

-- 
Giuliano Bertoletti
e-Security Manager


Intrinsic - Security Monitoring
http://www.intrinsic.it

COOL-FIRE: la soluzione Firewall per Windows NT/2000
http://www.symbolic.it/Prodotti/cool-fire.html

SYMBOLIC S.p.A. Tel: +39 0521 776180 / Fax: +39 0521 776190

Reply via email to