Question regarding `X509_PUBKEY` and ASN.1 SubjectPublicKeyInfo.

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

 



Hello OpenSSL,

I'm working on a program that generates pairs of keys and then writes the ASN.1 encoded SubjectPublicKeyInfo (RFC 5280[1]) to a file.

I turned to API `X509_PUBKEY`, and especially `X509_PUBKEY_set`[2], which seems to do the trick by taking an `EVP_PKEY` object that contains the public key:

The X509_PUBKEY structure represents the ASN.1 SubjectPublicKeyInfo structure defined in RFC5280 and used in certificates and certificate requests.

However, I'm kind of lost when it comes to encoding it to an ASN.1 document.
The documentation states the following:
i2d_PUBKEY() encodes an EVP_PKEY structure using SubjectPublicKeyInfo format.

So it seems that I can use `i2d_PUBKEY` with an `EVP_PKEY` directly without having to deal with an intermediate `X509_PUBKEY` object. However, `i2d_X509_PUBKEY` also exists but it doesn't have a dedicated manpage (only the generic manpage[3] about encoding/decoding from/to ASN.1).

My question is: which one should I use?

Regards,
- thomas

[1]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.7
[2]: https://www.openssl.org/docs/man3.2/man3/X509_PUBKEY_set.html
[3]: https://www.openssl.org/docs/man3.2/man3/i2d_X509_PUBKEY.html

--

Thomas Bailleux

Staff cryptography software engineer

thomas@xxxxxxxxxxxxx

Paris, FRANCE



[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