[openssl-users] Programmatic key conversion of PKCS#1 to #8
Gelareh Taban
gadphly at gmail.com
Fri Feb 16 20:56:41 UTC 2018
Works beautifully. Thanks very much Matt!
On Fri, Feb 16, 2018 at 11:49 AM, Matt Caswell <matt at openssl.org> wrote:
>
>
> On 16/02/18 17:24, Gelareh Taban wrote:
> > Hi all,
> >
> > I need to convert a Json Web Key (JWK) to PEM PKCS#8 format.
> >
> > I am using creating an RSA key using the parameters in JWK and then
> > using i2d_RSAPublicKey() to encode the RSA key to PEM PKCS#1.
> >
> > Are there any OpenSSL functions that programmatically convert the key
> > (both public and private) to PKCS#8?
>
> You can use PEM_write_bio_PrivateKey() for this purpose. You need to
> have your RSA key in EVP_PKEY format first. So something like
> (simplified to remove error handling):
>
> EVP_PKEY *key = EVP_PKEY_new();
> EVP_PKEY_assign_RSA(key, rsa);
>
> https://www.openssl.org/docs/man1.1.0/crypto/PEM_write_bio_PrivateKey.html
>
> https://www.openssl.org/docs/man1.1.0/crypto/EVP_PKEY_new.html
>
> https://www.openssl.org/docs/man1.1.0/crypto/EVP_PKEY_assign_RSA.html
>
> Matt
>
> --
> openssl-users mailing list
> To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20180216/b075188b/attachment.html>
More information about the openssl-users
mailing list