Being newbie to crypto, I understood that RSA keys are shared are pairs $(e,n)$ or $(d,n)$. But when I was given a doc with keys, they were in PKCS#8 format.

How to get the keys out of this format?

  • $\begingroup$ Mathematically speaking your are right, keys do consist of the set of modulus and exponent (although CRT parameters may be present instead of or in addition to the private exponent). However, computers do not directly process numbers or sets, they process bytes, and to distribute keys they are commonly encoded to bytes. PKCS#8 is an often used, standardized format for private keys (which usually also contain the public exponent, so extracting the public key is possible). When unsure read the standard. $\endgroup$ – Maarten - reinstate Monica May 8 at 16:12
  • $\begingroup$ There are different keyfile formats, and there are tools dealing with them. None of them have a very nice doc, but google + so + your already existing crypto knowledge will be enough. In your case, I would start my tries with openssl, digging on the unix.stackexchange.com . Good luck! $\endgroup$ – peterh says reinstate Monica May 9 at 0:14
  • $\begingroup$ There are two PKCS8 formats (four if you count PEM as different); see stackoverflow.com/questions/48958304/… for a brief summary. For details of the (PKCS1) RSA key within PKCS8, see crypto.stackexchange.com/questions/21102/… . If you simply want to use it in some program or library, there are Qs for many such in stackoverflow, security.SX, unix.SX, superuser, and serverfault. $\endgroup$ – dave_thompson_085 May 9 at 3:57

Browse other questions tagged or ask your own question.