Greetings:

If I know all of the values of an RSA key, including its primes,
exponents, coefficents, etc., can I construct an openssl RSA object
from it?  The "RSA_generate_key" appears to only allow the building
of a new RSA key from scratch, with random values that will not
match the desired values of a known key.  

For example, if we take a trival 128 bit RSA key that has know
values:

================================================================
Private-Key: (128 bit)
modulus:
    00:e2:57:d4:1c:13:73:d2:a3:73:42:0b:c5:35:f1:e0:23
publicExponent: 65537 (0x10001)
privateExponent:
    5f:a6:3b:f5:8d:66:e1:b8:f3:4d:c6:7e:9d:58:1b:e1
prime1:
    00:fa:63:1b:38:77:f5:ed:91
prime2:
    00:e7:6a:bd:ab:71:01:a8:73
exponent1:
    00:92:9b:16:e4:20:71:51:d1
exponent2:
    0a:19:52:65:a4:ec:d9:99
coefficient:
    41:07:c6:20:02:27:40:9c
================================================================

What can we do in OpenSSL so that we can import these values into
an OpenSSL RSA object, and simply use "PEM_write_bio_RSAPrivateKey"
to generate the following input?

================================================================
-----BEGIN RSA PRIVATE KEY-----
MGICAQACEQDiV9QcE3PSo3NCC8U18eAjAgMBAAECEF+mO/WNZuG4803Gfp1YG+EC
CQD6Yxs4d/XtkQIJAOdqvatxAahzAgkAkpsW5CBxUdECCAoZUmWk7NmZAghBB8Yg
AidAnA==
-----END RSA PRIVATE KEY-----
================================================================

And can I do the same for the public key?  If I have the
following values?

================================================================
Modulus (128 bit):
    00:e2:57:d4:1c:13:73:d2:a3:73:42:0b:c5:35:f1:e0:23
Exponent: 65537 (0x10001)
================================================================

Can I also import these values into an OpenSSL RSA object of the
public key, and simply use "PEM_write_bio_RSAPublicKey" to
generate the following output?

================================================================
-----BEGIN PUBLIC KEY-----
MCwwDQYJKoZIhvcNAQEBBQADGwAwGAIRAOJX1BwTc9Kjc0ILxTXx4CMCAwEAAQ==
-----END PUBLIC KEY-----
================================================================

My goal is to be able to import RSA keys into OpenSSL from a
various sources, including those generated from Linux's FreeSwan
IPSec "rsasigkey".

Thanks in advance.
Alicia.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to