login: root

Cracking the RSA keys (Part 2 – generating the private key)

Previous part:
Part 1 – Cracking the RSA keys (Part 1 – getting the private exponent)

PART 2
For a private key generation, we need to create an asn1parse.txt file with the contents of:

Explanation:
Modulus – it’s the product of two prime keys. It’s visible in public key.
pubExp – public exponent, it’s also visible in public key.
privExp – private exponent (d) that was calculated in previous post.
p – first prime number
q – second prime number
So we have all these from a previous post.

We are missing 3 private key values. They are easy calculable, and they are only auxilary private key values to speedup encryption and other processes.
I’ve used for calculations wolframalpha.
e1 – first exponent



e2 – second exponent



coeff – coefficient



Lets fill up the file with our values (as I’ve mentioned before, some of the values are from the previous post here). All the values are decimal:

Now it’s the last part. Generating the private key itself:

And here You go:

rsa-logo
Now let’s match:

with the public key that we had:

Lets create files public_rsa.txt and private_rsa.txt with the keys accordingly.

To me, they look the same :)

The final word:
Do not forget to use strong keys when generating keys. >2048bits is advised.

Leave a Reply

Close
%d bloggers like this: