I was searching for implementations of AES, and i read that the OPENSSL have the best implementations, so i took a code from openssl, aes 128 cbc, and use it in my project, because i don't want to link whole library for the sake of one method. However it seems there is no padding implementation in:
AES_cbc_encrypt
So is padding a basically a size that is added to make data the multiplicity of key size?
So if i have following, key size is 128 bit - 16 byte
char dataToEncrypt[73];
BOOL bResult = ReadFile(hDataFile, dataToEncrypt, 73, &bRead, 0);
I need to calculate how much zeros i need to add:
So if: 73 % 16 != 0
i need to calculate: 73 / 16 = 4
,
then add one block: 4 + 1 = 5
, size in bytes would be 16 * 5 = 80
,
add 80 - 73 = 7
, 7
zero bytes to the end of my buffer dataToEncrypt
, and encrypt as
AES_cbc_encrypt(dataToEncrypt, encrypted, 80, &dk, iv, AES_DECRYPT);
Is this what evp version of aes is suppose to do?