crypto-pubkey 0.1.3 → 0.1.4
raw patch · 5 files changed
+31/−14 lines, 5 filesdep ~bytestringdep ~crypto-pubkey-typesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: bytestring, crypto-pubkey-types
API changes (from Hackage documentation)
- Crypto.PubKey.DSA: type Signature = (Integer, Integer)
+ Crypto.PubKey.DSA: Signature :: Integer -> Integer -> Signature
+ Crypto.PubKey.DSA: data Signature :: *
+ Crypto.PubKey.DSA: sign_r :: Signature -> Integer
+ Crypto.PubKey.DSA: sign_s :: Signature -> Integer
Files
- Crypto/PubKey/DSA.hs +3/−3
- Crypto/PubKey/HashDescr.hs +9/−3
- Crypto/PubKey/RSA/OAEP.hs +15/−4
- Tests/KAT/DSA.hs +2/−2
- crypto-pubkey.cabal +2/−2
Crypto/PubKey/DSA.hs view
@@ -8,7 +8,7 @@ module Crypto.PubKey.DSA ( Params(..)- , Signature+ , Signature(..) , PublicKey(..) , PrivateKey(..) -- * signature primitive@@ -35,7 +35,7 @@ -> Maybe Signature signWith k pk hash msg | r == 0 || s == 0 = Nothing- | otherwise = Just (r,s)+ | otherwise = Just $ Signature r s where -- parameters (Params p g q) = private_params pk x = private_x pk@@ -56,7 +56,7 @@ -- | verify a bytestring using the public key. verify :: HashFunction -> PublicKey -> Signature -> ByteString -> Bool-verify hash pk (r,s) m+verify hash pk (Signature r s) m -- Reject the signature if either 0 < r < q or 0 < s < q is not satisfied. | r <= 0 || r >= q || s <= 0 || s >= q = False | otherwise = v == r
Crypto/PubKey/HashDescr.hs view
@@ -6,9 +6,14 @@ -- Stability : experimental -- Portability : Good --+-- Standard digests wrapped in ASN1 structure+-- module Crypto.PubKey.HashDescr- ( HashFunction+ (+ -- * Types+ HashFunction , HashDescr(..)+ -- * List of known hash description , hashDescrMD2 , hashDescrMD5 , hashDescrSHA1@@ -28,8 +33,8 @@ -- | Describe a hash function and a way to wrap the digest into -- an DER encoded ASN1 marshalled structure.-data HashDescr = HashDescr { hashFunction :: HashFunction- , digestToASN1 :: ByteString -> ByteString+data HashDescr = HashDescr { hashFunction :: HashFunction -- ^ hash function+ , digestToASN1 :: ByteString -> ByteString -- ^ convertion to an ASN1 wrapped digest bytestring } -- | Describe the MD2 hashing algorithm@@ -75,6 +80,7 @@ , digestToASN1 = toHashWithInfo "\x30\x51\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03\x05\x00\x04\x40" } +-- | Describe the RIPEMD160 hashing algorithm hashDescrRIPEMD160 :: HashDescr hashDescrRIPEMD160 = HashDescr { hashFunction = digestToByteString . (hash :: ByteString -> Digest RIPEMD160)
Crypto/PubKey/RSA/OAEP.hs view
@@ -1,3 +1,13 @@+-- |+-- Module : Crypto.PubKey.RSA.OAEP+-- License : BSD-style+-- Maintainer : Vincent Hanquez <vincent@snarc.org>+-- Stability : experimental+-- Portability : Good+--+-- RSA OAEP mode+-- <http://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding>+-- {-# LANGUAGE OverloadedStrings #-} module Crypto.PubKey.RSA.OAEP (@@ -38,10 +48,11 @@ , oaepLabel = Nothing } -encryptWithSeed :: ByteString- -> OAEPParams- -> PublicKey- -> ByteString+-- | Encrypt a message using OAEP with a predefined seed.+encryptWithSeed :: ByteString -- ^ Seed+ -> OAEPParams -- ^ OAEP params to use for encryption+ -> PublicKey -- ^ Public key.+ -> ByteString -- ^ Message to encrypt -> Either Error ByteString encryptWithSeed seed oaep pk msg | k < 2*hashLen+2 = Left InvalidParameters
Tests/KAT/DSA.hs view
@@ -134,11 +134,11 @@ } doSignatureTest (i, vector) = testCase (show i) (expected @=? actual)- where expected = Just (r vector, s vector)+ where expected = Just $ DSA.Signature (r vector) (s vector) actual = DSA.signWith (k vector) (vectorToPrivate vector) SHA1.hash (msg vector) doVerifyTest (i, vector) = testCase (show i) (True @=? actual)- where actual = DSA.verify SHA1.hash (vectorToPublic vector) (r vector, s vector) (msg vector)+ where actual = DSA.verify SHA1.hash (vectorToPublic vector) (DSA.Signature (r vector) (s vector)) (msg vector) dsaTests = testGroup "DSA" [ testGroup "SHA1"
crypto-pubkey.cabal view
@@ -1,5 +1,5 @@ Name: crypto-pubkey-Version: 0.1.3+Version: 0.1.4 Description: Public Key cryptography .@@ -28,7 +28,7 @@ Build-Depends: base >= 4 && < 5 , bytestring , crypto-random-api >= 0.2 && < 0.3- , crypto-pubkey-types >= 0.3 && < 0.4+ , crypto-pubkey-types >= 0.4 && < 0.5 , cryptohash >= 0.8 , crypto-numbers Exposed-modules: Crypto.PubKey.RSA