- 
                Notifications
    
You must be signed in to change notification settings  - Fork 182
 
Description
With the introduction of OpenSSL 3 providers, newly added algorithms may no longer have associated NIDs. Such algorithms must be "fetched" using the new functions added in OpenSSL 3.0:
- For 
EVP_MD:EVP_MD_fetch(NULL, str, NULL)instead ofEVP_get_digestbyname(str) - For 
EVP_CIPHER:EVP_CIPHER_fetch(NULL, str, NULL)instead ofEVP_get_cipherbyname(str) 
Although the new "fetch" functions have similar signatures and return the same struct, they are not drop-in replacements due to several differences:
- 
The fetched objects are reference counted and must be released by the user by
EVP_MD_free()orEVP_CIPHER_free()explicitly. Legacy functions return aconstpointer to a statically allocated object.- 
The man pages are unclear whether if OpenSSL APIs that take
EVP_MDas a parameter will automatically increment the reference counter. OpenSSL's internals seem to expect it forEVP_DigestInit_ex(), which works onEVP_MD_CTX. - 
On the other hand,
EVP_PKEY_CTX_set_rsa_mgf1_md()used inOpenSSL::PKey::RSA#sign_pssdoes not. In this case, we must ensure theEVP_MDremains alive until we release theEVP_PKEY_CTX. 
 - 
 - 
The algorithm names appear to be managed separately. Not all names accepted by
EVP_get_digestbyname(str)are valid withEVP_MD_fetch(NULL, str, NULL).- 
For example,
OpenSSL::Digest.new("RSA-SHA256")is currently accepted and equivalent toSHA256.EVP_MD_fetch()does not recognize it. - 
We probably don't want to keep a copy of the mapping, so we'd have to continue to use the legacy functions, too. Handling objects with different lifetime will be cumbersome.
 
 - 
 
As of now, algorithms enabled by this in OpenSSL master are the pre-NIST Keccak hash functions and AES-GCM-SIV ciphers added in OpenSSL 3.2. (There may be more.)