AES is a block cipher. It encrypts and decrypts a block of 128 bits (16 bytes). AES_decrypt and AES_encrypt act on one block at a time. So, you only get the first 16 bytes. You need to manually decrypt or encrypt other blocks.
If you know the mode (e.g. CBC, ECB, etc.), you can call such functions AES_decrypt_cbc, etc.
You need to change the code as follows (I gave just an example):
int len = strlen(ciphertext); //or get cipher text length by any mean. int i; for(i=0; i<=len; i+=16) AES_decrypt(cipherText+i, plainText+i, &decKey);
If you are confident in the mode, call the cbc / ecb / cfb / ofb functions.
In case of any doubt, please let me know.
source share