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.

As there seems to be no direct way to import from PCKS#1 I tried the following approach, which failed: 1) Use gnutls_rsa_params_import_pkcs1 to import PKCS1 structure into rsa_params structure
2) Use gnutls_rsa_params_export_raw to export modulus and exponent
3) Use gnutls_pubkey_import_rsa_raw to finally import modulus and exponent into gnutls_pubkey_t

The call to gnutls_rsa_params_import_pkcs1 fails with a GNUTLS_E_ASN1_DER_ERROR. The data can be viewed fine from within an ASN1 viewer.

Questions:
* Is there an onbvious way to import PKCS#1 RSAPublicKey into a gnutls_pubkey_t structure? * From my short look into the code of gnutls_rsa_params_import_pkcs1, it seems that it calls gnutls_x509_privkey_import which uses _gnutls_privkey_decode_pkcs1_rsa_key to import a _private key_ from a _RSAPrivateKey_ structure although it according to doc "should contain a PKCS1 RSAPublicKey structure PEM or DER encoded". Of course this fails in my case, as what I hand over is a RSAPublicKey structure, not a RSAPrivatekey. What's wrong here?

Please CC me when answering, as I am not on the list. Thx.

Best regards, René


--
Sirrix AG security technologies - http://www.sirrix.com
René Korthaus      eMail: [email protected]
Tel +49(681) 959 86-163    Fax +49(681) 959 86-5163
PGP Key ID 0x688EF9C8    Fingerprint 1FB6 2405 51C4 79DB C008 D1D2 C2E0 1A14 
688E F9C8
Vorstand: Ammar Alkassar (Vors.), Christian Stüble, Markus Bernhammer
Vorsitzender des Aufsichtsrates: Harald Stöber
Sitz der Gesellschaft: Homburg/Saar, HRB 3857 Amtsgericht Saarbrücken

This message may contain confidential and/or privileged information. If you are 
not the addressee, you must not use, copy, disclose or take any action based on 
this message or any information herein. If you have received this message in 
error, please advise the sender immediately by reply e-mail and
delete this message.

_______________________________________________
Help-gnutls mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-gnutls

Reply via email to