【发布时间】:2016-11-10 08:38:36
【问题描述】:
我正在尝试了解 openSSL 加密库中以下函数的参数。
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
size_t length, const AES_KEY *key,
unsigned char ivec[AES_BLOCK_SIZE],
unsigned char ecount_buf[AES_BLOCK_SIZE],
unsigned int *num);
通过解决here 给出的建议,我能够弄清楚:
*in - is the buffer in.
*out - is the buffer out.
length - is the the length of the *in buffer.
*key - is the private key.
ivec[0-7] - is the random IV
ivec[8-15] - is the counter thats incremented for every block that's encrypted.
我不确定
ecount_buf和num参数。
我看到调用返回后num 设置为length % AES_BLOCK_SIZE。
任何指向
ecount_buf参数的指针?
【问题讨论】:
-
你应该不使用
AES_encrypt和朋友。这是一个纯软件实现,因此您不会享受硬件支持,如 AES-NI。您应该使用EVP_*函数。请参阅 OpenSSL wiki 上的 EVP Symmetric Encryption and Decryption。事实上,您可能应该使用经过身份验证的加密,因为它提供 机密性和真实性。请参阅 OpenSSL wiki 上的 EVP Authenticated Encryption and Decryption。
标签: c encryption openssl aes libcrypto