EVP_get_cipherbyname always returns null

拟墨画扇 提交于 2019-12-12 05:29:14

问题


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);

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?


回答1:


You need to initialize the OpenSSL library first. If you just use libcrypto, call:

OpenSSL_add_all_algorithms();

Refer to https://wiki.openssl.org/index.php/Library_Initialization for how to handle other situations or openssl versions.



来源:https://stackoverflow.com/questions/44542613/evp-get-cipherbyname-always-returns-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!