HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

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.

Contents
  1. Block Cipher KATs
  2. Hash property tests
  3. Utils
  4. Re-exported
Synopsis

Block Cipher KATs

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

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

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

Orphan instances

2 instances