summaryrefslogtreecommitdiff
path: root/Data/OpenPGP/Util/Base.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-12-15 22:06:29 -0500
committerjoe <joe@jerkface.net>2013-12-15 22:06:29 -0500
commit395f75c6b7f66d313b4d44be4ed1317f9d7c7042 (patch)
treef66e931fb49cca89a0faa5bcc6a66c52418505a0 /Data/OpenPGP/Util/Base.hs
parent8dd042382eb2a676bac6cd266268ef4d3ed2b390 (diff)
Adapted to new ecc solutoin for OpenPGP-Haskell
Diffstat (limited to 'Data/OpenPGP/Util/Base.hs')
-rw-r--r--Data/OpenPGP/Util/Base.hs16
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
14import Crypto.Hash.RIPEMD160 as RIPEMD160 14import Crypto.Hash.RIPEMD160 as RIPEMD160
15import qualified Crypto.PubKey.RSA as Vincent.RSA 15import qualified Crypto.PubKey.RSA as Vincent.RSA
16import Crypto.PubKey.HashDescr as Vincent 16import Crypto.PubKey.HashDescr as Vincent
17import qualified Crypto.Types.PubKey.ECC as Vincent.ECDSA
18import qualified Crypto.Types.PubKey.ECDSA as Vincent.ECDSA
17 19
18import Data.OpenPGP.Util.Fingerprint (fingerprint) 20import Data.OpenPGP.Util.Fingerprint (fingerprint)
19 21
@@ -25,6 +27,20 @@ hashBySymbol OpenPGP.SHA512 = SHA512.hashlazy
25hashBySymbol OpenPGP.SHA224 = SHA224.hashlazy 27hashBySymbol OpenPGP.SHA224 = SHA224.hashlazy
26hashBySymbol OpenPGP.RIPEMD160 = RIPEMD160.hashlazy 28hashBySymbol OpenPGP.RIPEMD160 = RIPEMD160.hashlazy
27 29
30curveFromOID :: Integer -> Vincent.ECDSA.Curve
31curveFromOID 0x2a8648ce3d030107 = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p256r1 -- NIST P-256
32curveFromOID 0x2B81040022 = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p384r1 -- NIST P-384
33curveFromOID 0x2B81040023 = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p521r1 -- NIST P-521
34curveFromOID 0x2b8104000a = Vincent.ECDSA.getCurveByName Vincent.ECDSA.SEC_p256k1 -- bitcoin curve
35curveFromOID n = error $ "Unknown curve: "++ show n
36
37ecdsaKey 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
28toStrictBS :: LZ.ByteString -> BS.ByteString 44toStrictBS :: LZ.ByteString -> BS.ByteString
29toStrictBS = BS.concat . LZ.toChunks 45toStrictBS = BS.concat . LZ.toChunks
30 46