diff options
author | joe <joe@jerkface.net> | 2013-12-15 22:06:29 -0500 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-12-15 22:06:29 -0500 |
commit | 395f75c6b7f66d313b4d44be4ed1317f9d7c7042 (patch) | |
tree | f66e931fb49cca89a0faa5bcc6a66c52418505a0 /Data/OpenPGP/Util/Base.hs | |
parent | 8dd042382eb2a676bac6cd266268ef4d3ed2b390 (diff) |
Adapted to new ecc solutoin for OpenPGP-Haskell
Diffstat (limited to 'Data/OpenPGP/Util/Base.hs')
-rw-r--r-- | Data/OpenPGP/Util/Base.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Data/OpenPGP/Util/Base.hs b/Data/OpenPGP/Util/Base.hs index 802d503..aaa02c7 100644 --- a/Data/OpenPGP/Util/Base.hs +++ b/Data/OpenPGP/Util/Base.hs | |||
@@ -14,6 +14,8 @@ import Crypto.Hash.SHA224 as SHA224 | |||
14 | import Crypto.Hash.RIPEMD160 as RIPEMD160 | 14 | import Crypto.Hash.RIPEMD160 as RIPEMD160 |
15 | import qualified Crypto.PubKey.RSA as Vincent.RSA | 15 | import qualified Crypto.PubKey.RSA as Vincent.RSA |
16 | import Crypto.PubKey.HashDescr as Vincent | 16 | import Crypto.PubKey.HashDescr as Vincent |
17 | import qualified Crypto.Types.PubKey.ECC as Vincent.ECDSA | ||
18 | import qualified Crypto.Types.PubKey.ECDSA as Vincent.ECDSA | ||
17 | 19 | ||
18 | import Data.OpenPGP.Util.Fingerprint (fingerprint) | 20 | import Data.OpenPGP.Util.Fingerprint (fingerprint) |
19 | 21 | ||
@@ -25,6 +27,20 @@ hashBySymbol OpenPGP.SHA512 = SHA512.hashlazy | |||
25 | hashBySymbol OpenPGP.SHA224 = SHA224.hashlazy | 27 | hashBySymbol OpenPGP.SHA224 = SHA224.hashlazy |
26 | hashBySymbol OpenPGP.RIPEMD160 = RIPEMD160.hashlazy | 28 | hashBySymbol OpenPGP.RIPEMD160 = RIPEMD160.hashlazy |
27 | 29 | ||
30 | curveFromOID :: Integer -> Vincent.ECDSA.Curve | ||
31 | curveFromOID 0x2a8648ce3d030107 = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p256r1 -- NIST P-256 | ||
32 | curveFromOID 0x2B81040022 = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p384r1 -- NIST P-384 | ||
33 | curveFromOID 0x2B81040023 = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p521r1 -- NIST P-521 | ||
34 | curveFromOID 0x2b8104000a = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p256k1 -- bitcoin curve | ||
35 | curveFromOID n = error $ "Unknown curve: "++ show n | ||
36 | |||
37 | ecdsaKey k = Vincent.ECDSA.PublicKey curve (Vincent.ECDSA.Point x y) | ||
38 | where | ||
39 | x = keyParam 'x' k | ||
40 | y = keyParam 'y' k | ||
41 | curve = curveFromOID (keyParam 'c' k) | ||
42 | |||
43 | |||
28 | toStrictBS :: LZ.ByteString -> BS.ByteString | 44 | toStrictBS :: LZ.ByteString -> BS.ByteString |
29 | toStrictBS = BS.concat . LZ.toChunks | 45 | toStrictBS = BS.concat . LZ.toChunks |
30 | 46 | ||