我在 macOS 上调用 EVP_get_cipherbyname
时遇到问题:
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。我还没有找到一个生成非空 cipher2
的 cipher_str
实例。
我做错了什么吗?我是否应该调用其他电话才能使其正常工作?
最佳答案
您需要先初始化 OpenSSL 库。如果你只是使用 libcrypto, 调用:
OpenSSL_add_all_algorithms();
引用https://wiki.openssl.org/index.php/Library_Initialization了解如何处理其他情况或 openssl 版本。
关于c - EVP_get_cipherbyname 始终返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44542613/