[openssl-users] Checking if an EVP_PKEY* contains a private key

Stephen Kou s.kou at outlook.com
Tue Dec 22 05:29:03 UTC 2015

OpenSSL has the higher-level EVP_PKEY_* functions which work abstracts the public key cryptography algorithms.  However, sometimes a EVP_PKEY* only has a public key.  How could I check if a given EVP_PKEY* contains a private key?  I could use EVP_PKEY_decrypt_init and see if it returns an error, but that seems to be quite heavy-handed for what seems to be a simple check.  The other option is to go through the EVP_PKEY_get0_* functions and investigate the underlying mechanism directly (e.g. EVP_PKEY_get0_RSA and checking the RSA*'s private exponent is NULL), but that is also clumsy as I'll have to write code for every possible algorithm.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20151221/140ee1ad/attachment.html>

More information about the openssl-users mailing list