How to get rsa-private key in plain text format?

Viktor Dukhovni openssl-users at dukhovni.org
Fri Sep 3 03:30:25 UTC 2021


On Thu, Sep 02, 2021 at 05:21:22PM -0600, Shariful Alam wrote:

> Is there any command-line tool to get the plain text rsa private key like
> the following format from .pem file?

Yes, if you're willing to tolerate slightly different labels and ":"
every two nibbles.With slightly different labels and ":" every two
nibbles.  For example:

    $ openssl genrsa 512 2>&1 | openssl rsa -text -noout
    RSA Private-Key: (512 bit, 2 primes)
    modulus:
        00:d6:e5:14:e0:d9:42:e4:11:81:e5:cd:33:11:24:
        7f:3b:08:d7:ba:16:1e:01:05:37:65:c3:41:b8:df:
        3c:df:af:a3:e0:a3:02:fc:e6:20:3d:f2:c6:cc:bf:
        03:0c:c0:4b:8a:78:2b:8b:55:2e:f8:3e:81:10:e9:
        d9:b2:46:d2:7d
    publicExponent: 65537 (0x10001)
    privateExponent:
        67:e3:59:a3:96:05:0b:83:17:3c:44:66:92:bc:05:
        32:42:05:20:b6:3e:8d:19:bb:7d:5b:d6:f3:0c:21:
        3e:b5:a4:bd:1d:01:02:c5:37:b9:e3:ed:fb:60:33:
        eb:d4:f0:9f:fd:03:6d:e9:64:42:85:3d:dd:57:51:
        0c:63:57:f5
    prime1:
        00:f6:d6:33:68:9c:5b:3e:74:7c:95:36:e1:f3:7f:
        82:0d:e7:aa:65:f4:36:51:46:c0:83:92:cc:da:60:
        9d:47:83
    prime2:
        00:de:df:52:aa:da:a9:95:06:92:e7:32:b4:28:3c:
        69:58:17:31:10:69:80:89:41:f1:6f:4b:9a:7c:3f:
        36:5d:ff
    exponent1:
        19:c9:d1:3f:29:ae:c2:bc:aa:d3:70:13:75:3c:2a:
        1b:47:cb:de:b1:00:07:c7:cb:8f:33:84:21:80:9c:
        8d:ff
    exponent2:
        00:d1:48:7a:53:50:13:f0:8a:04:c6:af:f9:36:d3:
        4b:c4:d9:ba:4c:04:16:1c:4d:dd:0e:ba:ba:ed:b3:
        5a:35:37
    coefficient:
        00:9f:ec:87:75:7f:31:c3:f8:17:fc:c7:c0:f4:0e:
        ec:2a:a5:e4:52:e1:ed:1b:c4:5a:a8:fa:35:22:28:
        1f:e5:c3

-- 
    Viktor.


More information about the openssl-users mailing list