HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulecrypto-api-tests-0.3Haskell98

Test.Crypto

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.

  • 4 values

Block Cipher KATs

1 declaration
valuemakeBlockCipherPropTests :: BlockCipher k => k -> [Test]
#

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

1 declaration
valuemakeHashPropTests :: Hash c d => d -> Test
#

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

1 declaration

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

1 declaration

Orphan instances

2 instances