I have an RSA Private key file my_private_key.pem with the header -----BEGIN RSA PRIVATE KEY-----. I can parse that with the openssl utility: openssl asn1parse < my_private_key.pem

That shows me a bunch of integers: a 4096 bit integer, a 17 bit integer, another 4096 bit integer, and then five 2048 bit integers.

I understand the textbook RSA primitive where the private key is $(p,q,e)$ where $p,q$ are large secret primes and $e$ is the encryption exponent where $\gcd(e, (p-1)(q-1)) = 1$ and you encrypt plaintext $m$ by $c \equiv m^e \pmod{N}$ where $N=p \cdot q$. How does that textbook version of RSA relate to these integer numbers I see in a .pem file?

I'm sure this is a newbie question. Where do I start to read on this?

  • 2
    $\begingroup$ See this answer of mine. $\endgroup$
    – yyyyyyy
    Oct 24, 2017 at 23:21
  • 2
    $\begingroup$ $d$ is the private exponent (for decryption and signing) and $e$ the public one (for encryption and verification). The file structure is defined in PKCS1 republished as tools.ietf.org/html/rfc8017#appendix-A.1.2 ; the rest of PKCS1 explains how the CRT (Chinese Remainder Theorem) components are computed and used, but you might want to start with en.wikipedia.org/wiki/RSA_%28cryptosystem%29 for an appreciation of why this is done. $\endgroup$ Oct 24, 2017 at 23:28
  • $\begingroup$ The RFC Appendix was exactly what I was looking for. The whole RFC itself is extremely readable and helpful. Thank you! $\endgroup$
    – clay
    Oct 25, 2017 at 13:25

1 Answer 1


Here is a labeled example output (don't worry I created a new key):enter image description here

Which you can verify for example in Sage. Although, surprisingly, it apparently doesn't allow decryption because the exponent is too large.

  • 1
    $\begingroup$ There is a power-mod function which allows for such large exponents. $\endgroup$
    – SEJPM
    Oct 25, 2017 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.