Importing a PKCS#1 RSAPublicKey structure into a gnutls_pubkey_t
Nikos Mavrogiannopoulos
nmav at gnutls.org
Sat Aug 4 22:31:40 CEST 2012
On 08/03/2012 02:39 PM, René Korthaus wrote:
> Hello list,
>
> I have a smartcard that gives me a PKCS#1 RSAPublicKey structure of the
> public key on the card and I need to generate a X.509
> SubjectPublicKeyInfo structure from it. I already have a C++ wrapper
> class that uses gnutls_pubkey_export to generate the
> SubjectPublicKeyInfo structure. The question is how to import the
> RSAPublicKey structure right.
There is no exported function in gnutls that can read the RSAPublicKey
structure. gnutls_rsa_params_t reads the private key not the public (the
documentation has a typo which I just fixed).
You can read this DER structure by using libtasn1. Check
lib/x509/key_decode.c, and the function _gnutls_x509_read_rsa_pubkey().
After extracting the values you can import them using
gnutls_pubkey_import_rsa_raw().
regards,
Nikos
More information about the Gnutls-help
mailing list