haskell-tls / hs-certificate

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

introduce `serializePoint` function and cleanup existing code a bit #111

Open ababkin opened 5 years ago

ababkin commented 5 years ago

this introduces serializePoint function as the opposite of deserializePoint. This is useful when converting public/private keys from cryptonite PublicKey into X509 PubKey.

example:

toX509PubKey :: PublicKey -> Maybe X509.PubKey
toX509PubKey (PublicKey curve publicPoint) =
  case X509.serializePoint curve publicPoint of
    Left _err -> Nothing
    Right sp ->
        Just . X509.PubKeyEC $ X509.PubKeyEC_Named SEC_p384r1 sp

As a result of adding this, I've also cleaned related things and used Either for more informative errors at various places.

ababkin commented 5 years ago

I plan to also add a roundtrip test for serialization a bit later to this PR.

ababkin commented 5 years ago

I'm trying to fix the earlier GHC ver travis builds for this PR but I get lost in the huge number of warnings. Is there a trick to filter out the real error messages from this? https://travis-ci.org/vincenthz/hs-certificate/jobs/497913242