Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse RSA public / private keys from PEM files #12

Open
dantb opened this issue May 9, 2022 · 0 comments
Open

Parse RSA public / private keys from PEM files #12

dantb opened this issue May 9, 2022 · 0 comments

Comments

@dantb
Copy link
Owner

dantb commented May 9, 2022

Brain dump from reading through the Haskell code for this.

In the end this all boils down to extracting the numbers from the modular exponentiation equation underpinning RSA:

  1. The modulus n
  2. Public exponent e
  3. Private exponent d

Explanation of PEM in relation to other file types here

  1. Data.X509.Memory - read PEM (private key) key file from memory. Depends on 2 pemParseBS, 3 decodeASN1’
  2. Data.PEM.Parser - Parses lines of PEM file into a PEM data structure, with name, header and content
  3. Data.ASN1.Encoding - ASN1 is Abstract Syntax Notation One, interface for defining data structures to be (de-)serialised across platforms. Seems to be used after the PEM has been parsed, to extract the actual primitive number theory values, for keys.
  4. Crypto.Store.X509 - reads public key from memory, also depends on 2 pemParseBS and 3 decodeASN1’ , then does some other stuff to go to public key shape
  5. Web.JWT - JWT library, containing claims, parsing, signing and verifying. Parsing is done in readRsaPublicKey and readRsaSecret . Depends on 2 readKeyFileFromMemory , 4 readPubKeyFileFromMemory .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant