Hi Geoff, Thank you for your reply!
It seems to work when exporting with only DEREncode thx. /Tor Den onsdagen den 9:e juli 2014 kl. 00:01:12 UTC+2 skrev Geoff Beier: > > Your code is exporting just a sequence containing the modulus and public > exponent. The openssl rsa utility expects a sequence containing an > algorithm identifier and a bit string, where the bit string contains that > sequence with the modulus and exponent. > > You could convince yourself of this using the openssl command line > asn1parse utility on the public key your code exports: > openssl asn1parse -in pub.pem -inform pem > Compare that to the public key you get when you run > openssl rsa -in priv.pem -pubout |openssl asn1parse -inform pem > > followed by > openssl rsa -in priv.pem -pubout |openssl asn1parse -inform pem -strparse > 17 > > The way to get crypto++ to export what openssl expects here is to replace > pub.DEREncodePublicKey(queue); > with > pub.DEREncode(queue); > > > On Tue, Jul 8, 2014 at 5:26 PM, Tor Krill <[email protected] <javascript:> > > wrote: > >> Hi, >> >> I'm trying to export an RSA key pair in PEM format to be able to use >> these keys in other contexts including with openssl. >> >> The export of the public key unfortunately ends up being unrecognized by >> openssl. (The private one seems to work fine) >> >> Example code is here, http://pastebin.com/qw8wxx4L >> >> When i run: >> >> openssl rsa -pubin -inform PEM -in pub.pem -noout -text >> >> to check i get: >> >> unable to load Public Key >> 139875126281920:error:0D0680A8:asn1 encoding >> routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1319: >> 139875126281920:error:0D07803A:asn1 encoding >> routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:381:Type=X509_ALGOR >> 139875126281920:error:0D08303A:asn1 encoding >> routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 >> error:tasn_dec.c:751:Field=algor, Type=X509_PUBKEY >> 139875126281920:error:0906700D:PEM routines:PEM_ASN1_read_bio:ASN1 >> lib:pem_oth.c:83: >> >> Am i missing anything here? It is more or less cut & paste from the >> examples. >> >> I run Crypto++ 5.6.1(-6) on an 64 bit Ubuntu 13.10 system >> >> /Tor >> >> -- >> -- >> You received this message because you are subscribed to the "Crypto++ >> Users" Google Group. >> To unsubscribe, send an email to [email protected] >> <javascript:>. >> More information about Crypto++ and this group is available at >> http://www.cryptopp.com. >> --- >> You received this message because you are subscribed to the Google Groups >> "Crypto++ Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
