DRBG 0.2.2 → 0.2.3
raw patch · 3 files changed
+18/−15 lines, 3 filesdep +HUnitdep +crypto-api-testsdep +entropyPVP ok
version bump matches the API change (PVP)
Dependencies added: HUnit, crypto-api-tests, entropy, test-framework, test-framework-hunit
API changes (from Hackage documentation)
Files
- Crypto/Random/DRBG.hs +1/−1
- DRBG.cabal +4/−4
- Test/KAT.hs +13/−10
Crypto/Random/DRBG.hs view
@@ -61,7 +61,7 @@ import Crypto.Hash.SHA224 (SHA224) import Crypto.Hash.SHA1 (SHA1) import Crypto.Cipher.AES (AES128)-import System.Crypto.Random+import System.Entropy import qualified Data.ByteString as B import qualified Data.ByteString.Internal as BI import Data.Tagged
DRBG.cabal view
@@ -1,5 +1,5 @@ name: DRBG-version: 0.2.2+version: 0.2.3 license: BSD3 license-file: LICENSE author: Thomas DuBuisson <thomas.dubuisson@gmail.com>@@ -23,16 +23,16 @@ Build-Depends: base >= 4.0 && < 5, cereal >= 0.2, bytestring, prettyclass, tagged >= 0.2, crypto-api >= 0.6, cryptohash >= 0.6.1, parallel, mtl >= 2.0,- cryptocipher+ cryptocipher, entropy ghc-options: -O2 hs-source-dirs: exposed-modules: Crypto.Random.DRBG.Hash, Crypto.Random.DRBG.HMAC, Crypto.Random.DRBG, Crypto.Random.DRBG.Types- other-modules: Crypto.Random.DRBG.HashDF, Crypto.Random.DRBG.Util+ other-modules: Crypto.Random.DRBG.HashDF Crypto.Random.DRBG.Util Executable drbg_test if !flag(test) buildable: False main-is: Test/KAT.hs if flag(test)- build-depends: base, QuickCheck, crypto-api, bytestring, binary, cereal, cryptohash+ build-depends: base, QuickCheck, crypto-api, bytestring, binary, cereal, cryptohash, crypto-api-tests, HUnit, test-framework, test-framework-hunit other-modules: Paths_DRBG
Test/KAT.hs view
@@ -21,14 +21,22 @@ import Crypto.Types import Data.Bits (xor) import Data.Tagged+import Data.Proxy import Data.Maybe (maybeToList) import Data.List (deleteBy, isPrefixOf) import Test.Crypto import Test.ParseNistKATs import Paths_DRBG -main = hmacMain >> hashMain+import Test.Framework+import Test.HUnit.Base (assertEqual)+import Test.Framework.Providers.HUnit (testCase) +main = do+ h <- nistTests_HMAC+ s <- nistTests_Hash+ defaultMain (h ++ s)+ -- Test the SHA-256 HMACs (other hash implementations will be tested once crypthash uses the crypto-api classes) nistTests_HMAC :: IO [Test] nistTests_HMAC = do@@ -85,7 +93,7 @@ st3 = M.reseed st2 (hx eInPR2) (hx aIn2) Just (r1,_) = M.generate st3 olen B.empty in r1- return (TK (f == L.fromChunks [hexStringToBS ret]) name)+ return (testCase name $ assertEqual name f (hexStringToBS ret)) | otherwise = do cnt <- lookup "COUNT" t let name = testName ++ "-" ++ cnt@@ -106,12 +114,7 @@ st2 = M.reseed st1 (hx eInRS) (hx aInRS) Just (r1, _) = M.generate st2 olen (hx aIn2) in r1- return (TK (f == L.fromChunks [hexStringToBS ret]) name)---- Test the HMAC DRBG functionallity-hmacMain = nistTests_HMAC >>= runTests--hashMain = nistTests_Hash >>= runTests+ return (testCase name $ assertEqual name (hexStringToBS ret) f) nistTests_Hash :: IO [Test] nistTests_Hash = do@@ -160,7 +163,7 @@ st3 = H.reseed st2 (hx eInPR2) (hx aIn2) Just (r1,_) = H.generate st3 olen B.empty in r1- return (TK (f == L.fromChunks [hexStringToBS ret]) name)+ return (testCase name $ assertEqual name (hexStringToBS ret) f) buildKAT p t | otherwise = do cnt <- lookup "COUNT" t@@ -182,7 +185,7 @@ st2 = H.reseed st1 (hx eInRS) (hx aInRS) Just (r1, _) = H.generate st2 olen (hx aIn2) in r1- return (TK (f == L.fromChunks [hexStringToBS ret]) name)+ return (testCase name $ assertEqual name (hexStringToBS ret) f) proxyUnwrapHashState :: Proxy (H.State a) -> Proxy a proxyUnwrapHashState = const Proxy