Re: Programmatic key conversion of PKCS#1 to #8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Works beautifully. Thanks very much Matt!

On Fri, Feb 16, 2018 at 11:49 AM, Matt Caswell <matt@xxxxxxxxxxx> 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

-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux