newbie needs helps

Simon Josefsson jas at
Tue Jun 15 15:33:38 CEST 2004

Steven Truong <steven_n_truong at> writes:

> Hi, everybody.  I am interested in developing some
> multi-threaded apps that would use the AES in Linux
> Fedora FC2 PC. However, I have not been able to use
> AES alone just to encrypt some files for testing.
> Here is what I do:
> After setting the handle I would pick the cipher and
> specified CBC mode and CBC_CTS for AES256 using
> cipher_open. Then do a get_algo_keylen, and setkey (my
> key is of 128/8 bits.  Then I would setiv(handle, HDD,
> NULL, 0) and then read from file and do encrypting.  I
> would ask if this is the right sequence because I
> studies the tests/basic.c to do this.  I think it is
> right. However, since I also set CBC_CTS, but I got
> error for the last block of the file that is less than
> 16 bytes and I have to pad it up with something to
> have 16 byte block.  What is wrong?  Did I miss
> something or misunderstand anything?  For decryption,
> I followed the same sequence, except I don't worry
> about the last block size since ....

It is not clear if you intend to use CBC with Cipher Text Stealing
(CTS).  Not many application use this.  If you don't need it, you will
likely get a mismatch on the last bock.  So I guess the question is
whether you want CBC or CBC-CTS?

It isn't unlikely that the CTS behaviour is incorrect, the test
vectors used in the self tests is from only one source.  If you really
want CBC-CTS, do you have any test vectors for your application?

More information about the Gcrypt-devel mailing list