haskell-tls / hs-certificate

Certificate and Key Reader/Writer in haskell
60 stars 57 forks source link

add function to decode public keys #6

Closed rekado closed 12 years ago

rekado commented 12 years ago

Hi,

I added a function to decode public keys from files that only contain public keys. Such public key files can be generated from a private key file with openssl rsa -in rsa.pem -out rsapub.pem -pubout.

The format is SEQUENCE SEQUENCE OBJECT NULL BITSTRING, where yet another SEQUENCE INTEGER INTEGER is contained in the ASN1 stream inside the BITSTRING. That's why the pattern matching is done in two steps.

rekado commented 12 years ago

I had to change the type signature of parse_RSA so that I don't have to run a parser in KeyRSA.hs. Is this better?

rekado commented 12 years ago

Would you like me to change anything in the pull request? I actually find the latest changes to be a bit uglier than the initial commits, so I can understand if you don't want to merge it.

vincenthz commented 12 years ago

Thanks, i've merged it and move parse_RSA into the KeyRSA function. It's not uglier than before, i really think there's no asn1 parsing code that can looks good anyway.

rekado commented 12 years ago

woo, thanks.