EVP_get_cipherbyname始终返回null [英] EVP_get_cipherbyname always returns null
问题描述
在macOS上调用EVP_get_cipherbyname
时遇到问题:
I have a problem when calling EVP_get_cipherbyname
on macOS:
const char *cipher_str = "aes-256-cbc";
const evp_cipher_st *cipher1 = EVP_aes_256_cbc();
const evp_cipher_st *cipher2 = EVP_get_cipherbyname(cipher_str);
在上面的代码中,cipher1
将始终设置为有效的evp_cipher_st *
对象,而cipher2
将始终为null.我还没有找到产生非null的cipher_str
的单个实例.
In the code above, cipher1
will always be set to a valid evp_cipher_st *
object, and cipher2
will always be null. I haven't found a single instance of cipher_str
that produces a non-null cipher2
.
我做错什么了吗?我还应该打电话给其他电话吗?
Am I doing something wrong? Are there some other calls I should be making to get this to work?
推荐答案
您需要先初始化OpenSSL库.如果您仅使用libcrypto, 致电:
You need to initialize the OpenSSL library first. If you just use libcrypto, call:
OpenSSL_add_all_algorithms();
请参考 https://wiki.openssl.org/index.php/Library_Initialization有关如何处理其他情况或openssl版本的信息.
Refer to https://wiki.openssl.org/index.php/Library_Initialization for how to handle other situations or openssl versions.
这篇关于EVP_get_cipherbyname始终返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!