Search code examples
copenssllibcrypto

Does PEM_read_bio_PrivateKey have (or even need) a public key equivalent?


libcrypto3 provides a PEM_read_bio_PrivateKey as shown here

https://www.openssl.org/docs/man1.1.0/man3/PEM_read_bio_PrivateKey.html

I do not see a PEM_read_bio_PublicKey. There is a PEM_read_PUBKEY, but it expects a FILE* and not a BIO.

Obviously algorithm-specific read functions exist, but why is there no PEM_read_bio_PublicKey?


Solution

  • It's actually called PEM_read_bio_PUBKEY, listed in the same man page:

     EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x,
                                   pem_password_cb *cb, void *u);