<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 6, 2020, 9:16 PM Jason Proctor <<a href="mailto:jason@spatiallabs.com" target="_blank" rel="noreferrer">jason@spatiallabs.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Distinguished crypto community,<br>
<br>
I have the requirement to import RSA keypairs generated by the Amazon<br>
Key Management System into my environment. These keypairs arrive in<br>
the de facto standard of SPKI for the public component and PKCS8 for<br>
the private component.<br>
<br>
I have no problem with the PKCS8 encoded private keys, they seem fine<br>
when imported using d2i_PKCS8_PRIV_KEY_INFO_bio().<br>
<br>
However, I'm having issues importing the SPKI encoded public keys. My<br>
Java test program imports them fine. The Js Web Crypto API is happy<br>
with them. Online ASN.1 parsers are fine with them. The OpenSSL<br>
command line tool can dump their contents, no problem. However, the<br>
d2i_NETSCAPE_SPKI() function errors out trying to deal with them.<br>
<br>
Back in the day I had a hack to import SPKI encoded public keys, as I<br>
knew their structure. I would just set the modulus and exponent<br>
directly using BN_bin2bn(). However these days it seems that the RSA<br>
structure is opaque, and so I can't do that either. (I mean fair<br>
enough, it's a hack.)<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">There's setter functions now. See:</div><div dir="auto"><a href="https://www.openssl.org/docs/man1.1.0/man3/RSA_set0_key.html" target="_blank" rel="noreferrer">https://www.openssl.org/docs/man1.1.0/man3/RSA_set0_key.html</a><br></div><div dir="auto"><br></div><div dir="auto">So I have no idea about the spki function, but if you have the rsa private key can't you get the public key from it? I would just look at what API the rsa command line tool is using. I would imagine there is a high level API for this.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Question -- is there a supported way of importing SPKI encoded public<br>
keys into the OpenSSL world?<br>
<br>
thanks so much for any help with this,<br>
Jason@Spatial<br>
EAY/OpenSSL user since 1995<br>
</blockquote></div></div></div>