-- 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.3


-- | NIST KAT files are composed of properties, such as:
--   
--   <pre>
--   [SHA-1]
--   [PredictionResistance = True]
--   [EntropyInputSize = 128]
--   </pre>
--   
--   and individual known answer tests using these properties, ex:
--   
--   <pre>
--   COUNT = 0
--   EntropyInput = 7
--   PersonalizationString =
--   Result = 8
--   
--   COUNT = 1
--   EntropyInput = 4
--   PersonalizationString = 
--   Result = 2
--   </pre>
--   
--   Using 'many parseCategory' this input would be converted to a single
--   element list of <a>TestCategory</a>:
--   
--   <pre>
--   [([("SHA-1",""), ("PredictionResistance", "True"), ("EntropyInputSize", "128")],
--           [   [("COUNT", "0"), ("EntropyInput", "7"), ("PersonalizationString", ""), ("Result", "8")], 
--             , [("COUNT", "1"), ("EntropyInput", "4"), ("PersonalizationString", ""), ("Result", "2")]])]
--   </pre>
--   
--   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:
--   
--   <pre>
--   runTests (makeMD5Tests (undefined :: MD5Digest))
--   </pre>
--   
--   or
--   
--   <pre>
--   runTests =&lt;&lt; makeAESTests (undefined :: AESKey)
--   </pre>
--   
--   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:
--   
--   <ul>
--   <li>Operating on lazy bytestrings obtains the same result as on strict
--   bytestrings.</li>
--   <li>The length of the digest (instance definition) matches the
--   Serialize definition.</li>
--   <li>encode . decode == id</li>
--   <li>Hash block length is byte aligned (the 'crypto-api' operations
--   require this!)</li>
--   <li>The digest (output) length is byte aligned (also needed by
--   'crypto-api')</li>
--   </ul>
makeHashPropTests :: Hash c d => d -> Test

-- | Convert hex strings to bytestrings, for example:
--   
--   <pre>
--   "3adf91c0" ==&gt; B.pack [0x3a, 0xdf, 0x91, 0xc0]
--   </pre>
--   
--   Strings of odd length will cause an exception as will non-hex
--   characters such as '0x'.
hexStringToBS :: String -> ByteString
defaultMain :: [Test] -> IO ()
instance Test.QuickCheck.Arbitrary.Arbitrary Data.ByteString.Internal.ByteString
instance Test.QuickCheck.Arbitrary.Arbitrary Data.ByteString.Lazy.Internal.ByteString

module Test.MD5
makeMD5Tests :: (Show d, Hash c d) => d -> [Test]

module Test.AES

-- | Based on NIST KATs, build a list of Tests for the instantiated AES
--   algorithm. e.g. <tt>runTests $ makeAESTests (undefined :: AES128)</tt>
--   
--   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.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.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.TwoFish
makeTwoFishTests :: BlockCipher k => k -> IO [Test]
