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

Viktor Dukhovni openssl-users at dukhovni.org
Tue Dec 22 08:26:52 UTC 2015


On Mon, Dec 21, 2015 at 09:29:03PM -0800, Stephen Kou wrote:

> 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?

    len = i2d_PrivateKey(key, NULL);
    if (len <= 0) {
	/* No private key, or error determining its DER length */
    } else {
	/* Private key available */
    }

-- 
	Viktor.


More information about the openssl-users mailing list