1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
-- |
-- Module : Crypto.Cipher.Tests
-- License : BSD-style
-- Maintainer : Vincent Hanquez <vincent@snarc.org>
-- Stability : Stable
-- Portability : Excellent
--
{-# LANGUAGE ViewPatterns #-}
module Crypto.Cipher.Tests
( testBlockCipher
, testBlockCipherIO
, testStreamCipher
-- * KATs
, defaultKATs
, defaultStreamKATs
, KATs(..)
, KAT_Stream(..)
, KAT_ECB(..)
, KAT_CBC(..)
, KAT_CFB(..)
, KAT_CTR(..)
, KAT_XTS(..)
, KAT_AEAD(..)
) where
import Test.Framework (Test, testGroup)
import Crypto.Cipher.Types
import Crypto.Cipher.Types.Unsafe
import Crypto.Cipher.Tests.KATs
import Crypto.Cipher.Tests.Properties
-- | Return tests for a specific blockcipher and a list of KATs
testBlockCipher :: BlockCipher a => KATs -> a -> Test
testBlockCipher kats cipher = testGroup (cipherName cipher)
( (if kats == defaultKATs then [] else [testKATs kats cipher])
++ testModes cipher
)
-- | Return test for a specific blockcipher and a list of KATs
testBlockCipherIO :: BlockCipherIO a => KATs -> a -> Test
testBlockCipherIO _ cipher = testGroup ("mutable " ++ cipherName cipher)
( []
++ testIOModes cipher
)
-- | Return tests for a specific streamcipher and a list of KATs
testStreamCipher :: StreamCipher a => [KAT_Stream] -> a -> Test
testStreamCipher kats cipher = testGroup (cipherName cipher)
( (if kats == defaultStreamKATs then [] else [testStreamKATs kats cipher])
++ testStream cipher
)
|