-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A test framework and KATs for cryptographic operations. -- -- A test framework for hash and cipher operations using the crypto-api -- interface. Known answer tests (KATs) for common cryptographic -- algorithms are included. Patches welcome (both adding KATs for more -- algorithms or property tests for classes of algorithms). @package crypto-api-tests @version 0.2 -- | NIST KAT files are composed of properties, such as: -- --
--   [SHA-1]
--   [PredictionResistance = True]
--   [EntropyInputSize = 128]
--   
-- -- and individual known answer tests using these properties, ex: -- --
--   COUNT = 0
--   EntropyInput = 7
--   PersonalizationString =
--   Result = 8
--   
--   COUNT = 1
--   EntropyInput = 4
--   PersonalizationString = 
--   Result = 2
--   
-- -- Using 'many parseCategory' this input would be converted to a single -- element list of TestCategory: -- --
--   [([("SHA-1",""), ("PredictionResistance", "True"), ("EntropyInputSize", "128")],
--           [   [("COUNT", "0"), ("EntropyInput", "7"), ("PersonalizationString", ""), ("Result", "8")], 
--             , [("COUNT", "1"), ("EntropyInput", "4"), ("PersonalizationString", ""), ("Result", "2")]])]
--   
-- -- that is, a list of tuples, the first element is a list of properties -- (key/value pairs) and the second element is a list of tests. Each test -- is itself a list of records (key/value pairs). Properties apply to all -- tests contained in the second element of the tuple. module Test.ParseNistKATs parseCategories :: String -> String -> [(Properties, [NistTest])] type Properties = [(String, String)] type Record = (String, String) type NistTest = [Record] type TypedTest = (String, [NistTest]) type TestCategory = (Properties, [NistTest]) -- | Basic tests for some common cryptographic algorithms Most user only -- need to run the {make,run}Tests functions: -- --
--   runTests (makeMD5Tests (undefined :: MD5Digest))
--   
-- -- or -- --
--   runTests =<< makeAESTests (undefined :: AESKey)
--   
-- -- TODO: More KATs are needed - particularly ones for non-AES, SHA, or -- MD5 algorithms. module Test.Crypto -- | Build test groups for encrypt/decrypt identity and equality of -- operations on strict and lazy ByteStrings. -- -- Admittedly, these tests conflate testing the algorithm in question and -- testing the mode implementation in 'crypto-api', but more testing -- isn't exactly a bad thing. makeBlockCipherPropTests :: BlockCipher k => k -> [Test] -- | Construct a test group to check common hash properties. Properties -- include: -- -- makeHashPropTests :: Hash c d => d -> Test -- | Convert hex strings to bytestrings, for example: -- --
--   "3adf91c0" ==> B.pack [0x3a, 0xdf, 0x91, 0xc0]
--   
-- -- Strings of odd length will cause an exception as will non-hex -- characters such as '0x'. hexStringToBS :: String -> ByteString defaultMain :: [Test] -> IO () instance Arbitrary ByteString instance Arbitrary ByteString module Test.AES -- | 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] module Test.SHA makeSHA1Tests :: Hash c d => d -> IO [Test] makeSHA224Tests :: Hash c d => d -> IO [Test] makeSHA256Tests :: Hash c d => d -> IO [Test] makeSHA384Tests :: Hash c d => d -> IO [Test] makeSHA512Tests :: Hash c d => d -> IO [Test] module Test.HMAC makeSHA1HMACTests :: Hash c d => d -> IO [Test] makeSHA224HMACTests :: Hash c d => d -> IO [Test] makeSHA256HMACTests :: Hash c d => d -> IO [Test] makeSHA384HMACTests :: Hash c d => d -> IO [Test] makeSHA512HMACTests :: Hash c d => d -> IO [Test] module Test.TwoFish makeTwoFishTests :: BlockCipher k => k -> IO [Test] module Test.MD5 makeMD5Tests :: (Show d, Hash c d) => d -> [Test]