PEM to EVP_PKEY

Viktor Dukhovni openssl-users at dukhovni.org
Mon Sep 26 01:28:58 UTC 2022


On Sun, Sep 25, 2022 at 04:12:57PM -0700, Kory Hamzeh wrote:

> So I have a PEM formatted file that contains an EC certificate and a
> private key. I need to load that PEM file and converted to an
> EVP_PKEY. The goal of this exercise is so that I can do an ECDH
> pairwise consistency test (SP 800-56Ar3 Section 5.6.2.1.4) on the key
> pair by calling EVP_PKEY_pairwise_check(). I need some help in getting
> from the PEM file to an EVP_PKEY.

For an "atomic" interface, that reads both from the same file, even
if the file is replaced (atomically, via rename(2)) while the key and
cert are being read:

    1. https://github.com/vdukhovni/postfix/blob/master/postfix/src/tls/tls_certkey.c#L344-L378
    2. https://github.com/vdukhovni/postfix/blob/master/postfix/src/tls/tls_certkey.c#L245-L266

For a simpler interface that is subject to races vs. atomic updates:

    https://github.com/vdukhovni/postfix/blob/master/postfix/src/tls/tls_certkey.c#L245-L266

-- 
    Viktor.


More information about the openssl-users mailing list