crypto-api 0.5 → 0.5.2
raw patch · 5 files changed
+22/−7 lines, 5 filesdep +filepathPVP ok
version bump matches the API change (PVP)
Dependencies added: filepath
API changes (from Hackage documentation)
Files
- Benchmark/Crypto.hs +1/−0
- Crypto/Random.hs +2/−2
- Test/AES.hs +7/−1
- Test/Crypto.hs +10/−2
- crypto-api.cabal +2/−2
Benchmark/Crypto.hs view
@@ -60,6 +60,7 @@ op f str = whnf (B.unpack . Ser.encode . f) str -- |Benchmark a block cipher by calling the 'ecb'' and 'unEcb'' functions+-- on 128KB strings benchmarkBlockCipher :: BlockCipher k => k -> String -> Benchmark benchmarkBlockCipher k name = let benchs = bgroup name [ bench "enc" (whnf (ecb' k) ps)
Crypto/Random.hs view
@@ -148,7 +148,7 @@ instance CryptoRandomGen SystemRandom where newGen _ = Left NeedsInfiniteSeed- genSeedLength = Tagged 0+ genSeedLength = Tagged maxBound genBytes req (SysRandom bs) = let reqI = fromIntegral req rnd = L.take reqI bs@@ -159,7 +159,7 @@ reseed _ _ = Left NeedsInfiniteSeed newGenIO = getSystemGen --- | While the safety and wisdom of a splitting function depends on the properties of the generator being split,+-- |While the safety and wisdom of a splitting function depends on the properties of the generator being split, -- several arguments from informed people indicate such a function is safe for NIST SP 800-90 generators. -- (see libraries@haskell.org discussion ~ Sept, Oct 2010) splitGen :: CryptoRandomGen g => g -> Either GenError (g,g)
Test/AES.hs view
@@ -17,6 +17,11 @@ import Test.ParseNistKATs -- |Based on NIST KATs, build a list of Tests for the instantiated AES algorithm.+-- e.g. @runTests $ makeAESTests (undefined :: AES128)@+--+-- This is just a hack-job, if the BlockCipher instance doesn't toss keys+-- of incorrect length then you'll get this test running, say, AES128 being tested+-- with the first 128 bits of AES192 and AES256 tests. makeAESTests :: BlockCipher k => k -> IO [Test] makeAESTests k = do kats <- getAES_KATs k@@ -73,7 +78,8 @@ ct <- lookup "CIPHERTEXT" t pt <- lookup "PLAINTEXT" t k <- lookup "KEY" t- let realKey = (fromJust . buildKey . hexStringToBS $ k) `asTypeOf` ek+ rK <- (buildKey . hexStringToBS $ k)+ let realKey = rK `asTypeOf` ek ctBS = hexStringToBS ct ptBS = hexStringToBS pt nm = name ++ "-" ++ cnt
Test/Crypto.hs view
@@ -128,12 +128,20 @@ -- |some generic blockcipher tests +goodKey :: BlockCipher k => k -> B.ByteString -> Bool goodKey k bs =- case (buildKey bs `asTypeOf` Just k) of+ case (getKey k bs `asTypeOf` Just k) of Nothing -> False Just _ -> True -bKey k bs = let Just k' = (buildKey bs `asTypeOf` Just k) in k'+bKey k bs = let Just k' = (getKey k bs `asTypeOf` Just k) in k'++-- Pad out (or trim) material to correct length (for testing only!)+getKey :: BlockCipher k => k -> B.ByteString -> Maybe k+getKey k bs =+ let l = (keyLength `for` k) `div` 8+ b' = B.take l (B.concat $ replicate l (B.append bs (B.singleton 0)))+ in buildKey b' bIV :: BlockCipher k => k -> B.ByteString -> Either String (IV k) bIV k bs = Ser.decode bs
crypto-api.cabal view
@@ -1,5 +1,5 @@ name: crypto-api-version: 0.5+version: 0.5.2 license: BSD3 license-file: LICENSE copyright: Thomas DuBuisson <thomas.dubuisson@gmail.com>@@ -61,7 +61,7 @@ extra-libraries: advapi32 if flag(tests) exposed-modules: Test.Crypto, Test.AES, Test.SHA, Test.HMAC, Test.ParseNistKATs, Test.TwoFish- build-depends: QuickCheck >= 2.3 && < 2.4, directory >= 1.0.1.0 && < 1.2+ build-depends: QuickCheck >= 2.3 && < 2.4, directory >= 1.0.1.0 && < 1.2, filepath other-modules: Paths_crypto_api if flag(benchmarks) exposed-modules: Benchmark.Crypto