Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract exponent and modulus from a private key?

Is there a way to extract modulus and exponent of a private key using openssl? If there is a way, please let me know.

like image 268
Ajay kumar Avatar asked May 25 '12 08:05

Ajay kumar


People also ask

What is modulus and exponent in RSA private key?

Modulus (n) is the product of two prime numbers used to generate the key pair. Public exponent (d) is the exponent used on signed / encoded data to decode the original value.

How do you find the RSA private key modulus?

At the center of the RSA cryptosystem is the RSA modulus N. It is a positive integer which equals the product of two distinct prime numbers p and q: RSA modulus: N = pq.


1 Answers

Yes. Using the -text option to openssl rsa is one way:

$ openssl genrsa 2048 > dummy.key
Generating RSA private key, 2048 bit long modulus
..............+++
....................+++
e is 65537 (0x10001)
$ openssl rsa -in dummy.key -noout -text
Private-Key: (2048 bit)
modulus:
    00:c3:21:46:32:f5:d8:89:c5:bb:bd:a7:4a:14:32:
    [...]
    ea:5d:d3:20:bd:d7:5d:36:1e:45:28:f3:e3:dd:0b:
    d1:f9
publicExponent: 65537 (0x10001)
privateExponent:
    55:4d:74:8c:ce:a0:cd:09:de:1a:f8:c9:0f:af:4f:
    ed:a1:92:89:89:86:4f:cb:b2:f6:aa:60:e7:05:a6:
    [...]
like image 101
Anders Lindahl Avatar answered Nov 15 '22 12:11

Anders Lindahl