问题
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