我需要在CTR模式下使用128位AES算法从openssl库进行加密。 但是似乎从openssl 1.1.0g中删除了相应的函数AES_ctr128_encrypt。因为出现以下错误:-
互联网上的文档或参考文献并未建议AES CTR模式的替代功能。 带有openssl 1.1.0g的AES_ctr128_encrypt的确切替代方案是什么?
答案 0 :(得分:1)
您可以使用CRYPTO_ctr128_encrypt()
,而不是:
AES_ctr128_encrypt(
in,
out,
len,
&cipher->aes_key->key,
cipher->aes_key->IV,
buffer,
&num);
您会这样做:
CRYPTO_ctr128_encrypt(
in,
out,
len,
&cipher->aes_key->key,
cipher->aes_key->IV,
buffer,
&num,
(block128_f)AES_encrypt);
答案 1 :(得分:0)
为了简便,我只想补充一点,您不要忘记包含以下标头:
那么这:
AES_ctr128_encrypt(
cipher_in,
plaintext_out,
bytes_length,
&cipher->aes_key->key,
cipher->aes_key->IV,
counter,
&offset);
将成为:
#include <openssl/aes.h>
#include <openssl/modes.h>
.
.
.
CRYPTO_ctr128_encrypt(
cipher_in,
plaintext_out,
bytes_length,
&cipher->aes_key->key,
cipher->aes_key->IV,
counter,
&offset,
(block128_f)AES_encrypt);