Maintainer | [email protected] |
---|---|
Stability | beta |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Test.Crypto
Description
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.
Synopsis
- makeBlockCipherPropTests :: BlockCipher k => k -> [Test]
- makeHashPropTests :: Hash c d => d -> Test
- hexStringToBS :: String -> ByteString
- defaultMain :: [Test] -> IO ()
Block Cipher KATs
makeBlockCipherPropTests :: BlockCipher k => k -> [Test] Source #
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.
Hash property tests
makeHashPropTests :: Hash c d => d -> Test Source #
Construct a test group to check common hash properties. Properties include:
- Operating on lazy bytestrings obtains the same result as on strict bytestrings.
- The length of the digest (instance definition) matches the Serialize definition.
- encode . decode == id
- Hash block length is byte aligned (the 'crypto-api' operations require this!)
- The digest (output) length is byte aligned (also needed by 'crypto-api')
Utils
hexStringToBS :: String -> ByteString Source #
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'.
Re-exported
defaultMain :: [Test] -> IO () #