Need PrivateKey encoding/decoding
Closed this issue · 5 comments
It seems this library would be more complete with private key encoding/decoding.
For future reference (I like to pretend I'll make a patch soon, but incase soon isn't very soon):
I have worked out how to decode PEM files (OpenSSH private key files) using Vincent's PEM and asn1-data packages. This sketch assumes you've parsed the header ----- SOME HEADER -----
properly and know the contained key is an RSA key (as a first example):
let Right [pem] = pemParseBS theRawBytes
Right asns = (decodeASN1' DER (pemContent pem)) -- Start Sequence , IntVal (x 9) , End Sequence
-- -- Version, Modulus (?), exp? (65537), public exp?, private?, prime 1, prime 2, exp1, exp2, coeff
Right key = runParseASN1 (some monadic parser returning ::RSA.PublicKey) asns
Oh, I was wrong on part of that - the sketch requires the header to be intact to be parsed by "pemParseBS". We can further parse the string pemName pem
to determine the type.
I agree, that's a good idea. Also there should be a support for passphrases in encoding/decoding.
This is partially fixed (my need is addressed) by pull request #7. Could we get a release including this basic functionality? We could remove the stubbed functions and perhaps passphrase arguments for the purposes of the release. After that we might have time to get around to DES (for passpharses) and fixing the types (for encoding), but at least the common need is filled.
Version with your pull request already at hackage, thanks.