RSA 1.0.6.1 → 1.0.6.2
raw patch · 3 files changed
+20/−67 lines, 3 filesdep −test-framework-quickcheckdep ~QuickCheckdep ~test-framework-quickcheck2PVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: test-framework-quickcheck
Dependency ranges changed: QuickCheck, test-framework-quickcheck2
API changes (from Hackage documentation)
- Codec.Crypto.RSA: instance Random Word8
Files
- Codec/Crypto/RSA.hs +4/−0
- RSA.cabal +16/−27
- Test.hs +0/−40
Codec/Crypto/RSA.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ -- |An implementation of RSA (PKCS #1) Cryptography, as described by the -- RSA standard and RFC 3447. module Codec.Crypto.RSA(@@ -574,12 +576,14 @@ | BS.length bstr <= len = [bstr] | otherwise = (BS.take len bstr):(chunkify len $ BS.drop len bstr) +#if !MIN_VERSION_random(1,0,1) instance Random Word8 where randomR (a,b) g = let aI::Int = fromIntegral a bI::Int = fromIntegral b (x, g') = randomR (aI, bI) g in (fromIntegral x, g') random = randomR (minBound, maxBound)+#endif generate_random_bytestring :: RandomGen g => g -> Int64 -> (ByteString, g) generate_random_bytestring g 0 = (BS.empty, g)
RSA.cabal view
@@ -1,13 +1,13 @@ name: RSA category: Cryptography, Codec-version: 1.0.6.1+version: 1.0.6.2 license: BSD3 license-file: LICENSE author: Adam Wick <awick@galois.com> maintainer: Adam Wick <awick@galois.com> stability: stable build-type: Simple-cabal-version: >= 1.2+cabal-version: >= 1.6 tested-with: GHC ==6.8.0 synopsis: Implementation of RSA, using the padding schemes of PKCS#1 v2.1. description: This library implements the RSA encryption and signature @@ -17,9 +17,9 @@ included are based of RFC 3447, or the Public-Key Cryptography Standard for RSA, version 2.1 (a.k.a, PKCS#1 v2.1). -Flag SkipTests- Default: True- Description: Skip building the test program+Flag test+ Default: False+ Description: Building the test program Flag IncludeMD5 Description: Include support for using MD5 in the various crypto routines.@@ -27,18 +27,10 @@ Flag UseBinary Description: Use the binary package for serializing keys. -Flag QuickCheck1- Description: Whether this is QuickCheck 1 or not- Default: False- Flag OldBase Description: Whether or not to use base 3 (default: no) Default: False -Flag HasArbitraryWord8- Description: Whether or not Arbitrary Word8 is defined by QuickCheck- Default: False- Library build-depends: bytestring, random GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans@@ -59,26 +51,23 @@ extensions: CPP, BangPatterns, ScopedTypeVariables Executable test_rsa- if flag(SkipTests)- Buildable: False- else+ if flag(test) if flag(OldBase) build-depends: base >= 3 && < 4, SHA < 1.4.1 else build-depends: base >= 4 && < 5, SHA- build-depends: bytestring, test-framework >= 0.3 && < 0.4- if flag(QuickCheck1)- build-depends: QuickCheck < 2, test-framework-quickcheck >= 0.2.6 && < 0.3- CPP-Options: -DQUICKCHECK1- else- build-depends: test-framework-quickcheck2 >= 0.2.7 && < 0.3- if flag(HasArbitraryWord8)- build-depends: QuickCheck >= 2.1.2 && < 3- CPP-Options: -DQUICKCHECK_DEFINES_ARBITRARY_WORD8- else- build-depends: QuickCheck >= 2 && < 2.1.2+ build-depends: bytestring, test-framework >= 0.3 && < 0.4,+ QuickCheck >= 2 && < 3,+ test-framework-quickcheck2 >= 0.2 && < 0.3+ else+ Buildable: False GHC-Options: -O2 -Wall -fno-ignore-asserts -fno-warn-orphans CPP-Options: -DRSA_TEST Main-Is: Test.hs Other-Modules: Codec.Crypto.RSA extensions: CPP, BangPatterns, ScopedTypeVariables++source-repository head+ type: git+ location: git://code.galois.com/RSA.git+
Test.hs view
@@ -8,11 +8,7 @@ import Test.QuickCheck import Test.Framework (defaultMain, testGroup, Test)-#ifdef QUICKCHECK1-import Test.Framework.Providers.QuickCheck (testProperty)-#else import Test.Framework.Providers.QuickCheck2 (testProperty)-#endif -- -------------------------------------------------------------------------- @@ -23,27 +19,17 @@ deriving (Show) getRNGSeed :: Gen StdGen-#ifdef QUICKCHECK1-getRNGSeed = rand-#else getRNGSeed = fmap mkStdGen arbitrary-#endif instance Arbitrary KeyPair where arbitrary = do g <- getRNGSeed let (pub, priv, _) = generateKeyPair g 1024 return $ KP1K pub priv-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif instance Arbitrary KeyPair2048 where arbitrary = do g <- getRNGSeed let (pub, priv, _) = generateKeyPair g 2048 return $ KP2K pub priv-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif -- -------------------------------------------------------------------------- @@ -56,9 +42,6 @@ arbitrary = do g <- getRNGSeed let (res, _) = large_random_prime g 64 return (LP res)-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif -- -------------------------------------------------------------------------- @@ -69,9 +52,6 @@ instance Arbitrary PositiveInteger where arbitrary = (PI . (+1) . abs) `fmap` arbitrary-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif -- -------------------------------------------------------------------------- @@ -80,25 +60,11 @@ instance Show NonEmptyByteString where show (NEBS x) = show x -#ifndef QUICKCHECK_DEFINES_ARBITRARY_WORD8-instance Arbitrary Word8 where- arbitrary = fromIntegral `fmap` (arbitrary::(Gen Int))-# ifdef QUICKCHECK1- coarbitrary = undefined-# endif-#endif- instance Arbitrary ByteString where arbitrary = BS.pack `fmap` arbitrary-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif instance Arbitrary NonEmptyByteString where arbitrary = (NEBS . BS.pack) `fmap` (return(:)`ap`arbitrary`ap`arbitrary)-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif -- -------------------------------------------------------------------------- @@ -115,18 +81,12 @@ sha256' = bytestringDigest . sha256 sha384' = bytestringDigest . sha384 sha512' = bytestringDigest . sha512-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif instance Show HashInfo where show h = "<hash: len=" ++ (show $ BS.length $ hashFunction h BS.empty) ++ ">" instance Arbitrary HashInfo where arbitrary = elements [ha_SHA1, ha_SHA256, ha_SHA384, ha_SHA512]-#ifdef QUICKCHECK1- coarbitrary = undefined-#endif -- --------------------------------------------------------------------------