AES decrypted text mismatch

Stephen A. Cochran Lists stephen.a.cochran.lists at cahir.net
Wed Oct 11 04:56:06 CEST 2006


I was following Tobias Bayer's example code to perform some AES  
encryption. Code available at:

http://www.tobias-bayer.de/main/tutorials/libgcrypt.html

I made a simple modification to allow command line input to  
demonstrate the problem, changing only the following lines:

int main(int argc, char *argv[])
{
     const int BLOCKSIZE = 16;
     int TEXTLEN = strlen(argv[1]);
     unsigned char* plaintext = argv[1];

When I run the program (using libgcrypt 1.2.0, I realize it's out of  
date, trying to get the sysadmin to update it), some input strings  
are decrypted back with extra characters on the end. Note the  
different length after decryption as well:

angus at dev:~/aes_test>./aes 12345678901
Key is: 92 75 26 AD C8 BC 36 C7 C 52 8 E3 BF 13 8C F9
Encrypting plaintext: 12345678901...
plaintext len: 11
Resulting ciphertext (hex): BA C6 2A 23 DC 39 0 D5 7E 48 CB
Decrypted text len: 11
Decrypted text: 12345678901

angus at dev:~/aes_test>./aes 123456789012
Key is: FF 5 76 50 41 9F 2B A0 1B 2F 3 D2 B0 9 A8 9D
Encrypting plaintext: 123456789012...
plaintext len: 12
Resulting ciphertext (hex): D6 FD 6E 93 53 4B 1F 1B 4F 6 41 99
Decrypted text len: 15
Decrypted text: 123456789012?


Is this a known bug in 1.2.0? I didn't see anything in the archives  
or the change log, but didn't really find release notes.

Thanks in advance,

Steve Cochran



More information about the Gcrypt-devel mailing list