I have a simple problem: The first 16 bytes are not encrypted/decrypted correctly. What is wrong?
The encryption function writes it to a file, and the decryption function reads it from the file again.
int inum = 0;
unsigned char ckey [] = "3q43*_;fsdf#ßß94";
unsigned char civ [] = "sfgsjni274z#-,.-";
Encryption:
unsigned char outdata [4096 + 1];
AES_KEY key;
AES_set_encrypt_key(ckey, 128, &key);
AES_cfb128_encrypt((const unsigned char *) "aaaaaaaaaaaaaaaaa", outdata, 17, &key, civ, &inum, AES_ENCRYPT);
Decryption:
indata
is set by the read function
AES_KEY key;
AES_set_encrypt_key(ckey, 128, &key);
AES_cfb128_encrypt(indata, outdata, iSize, &key, civ, &inum, AES_DECRYPT);
The output will be:
‡~MÚjô±¦¤,`Ð,-âa
Original string is 17 bytes long, so the last byte is correct.
The characters after the the first 16 bytes are always correct, I've tested it with multiple strings.