This should be a simple question, but I can\'t find any examples or figure out the answer from the openssl docs.
I want to encrypt exactly 128 bits,
Here, you have already figured out the steps. So, it will be
EVP_EncryptFinal_ex
also take care of the fact that data is not in multiple of block lengths.
In my opinion, if you have only to use AES with no padding (EVP_ interfaces takes care of padding), then go for AES_encrypt
.
They are fairly easy to use.
//Step 1: Set encrypt key.
AES_KEY aeskey;
AES_set_encrypt_key(key, bits, &aeskey);
//Step2: Encrypt exactly 128 bits.
AES_encrypt(data, dataout, &aeskey);