~ubuntu-branches/ubuntu/trusty/haskell-crypto-cipher-tests/trusty

« back to all changes in this revision

Viewing changes to Crypto/Cipher/Tests/KATs.hs

  • Committer: Package Import Robot
  • Author(s): Clint Adams
  • Date: 2013-12-07 23:05:46 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20131207230546-wx3u4lep0yiam6fp
Tags: 0.0.11-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
defaultStreamKATs = []
96
96
 
97
97
-- | tests related to KATs
98
 
testKATs :: BlockCipher cipher => KATs -> cipher -> Test
 
98
testKATs :: BlockCipher cipher
 
99
         => KATs
 
100
         -> cipher
 
101
         -> Test
99
102
testKATs kats cipher = testGroup "KAT"
100
103
    (   maybeGroup makeECBTest "ECB" (kat_ECB kats)
101
104
     ++ maybeGroup makeCBCTest "CBC" (kat_CBC kats)
149
152
                etag = aeadFinalize aeadEFinal (aeadTaglen d)
150
153
                dtag = aeadFinalize aeadDFinal (aeadTaglen d)
151
154
               
152
 
        cipherMakeIV :: BlockCipher cipher => cipher -> ByteString -> IV cipher
153
 
        cipherMakeIV _ bs = fromJust $ makeIV bs
154
 
 
155
155
testStreamKATs :: StreamCipher cipher => [KAT_Stream] -> cipher -> Test
156
156
testStreamKATs kats cipher = testGroup "KAT" $ maybeGroup makeStreamTest "Stream" kats
157
157
  where makeStreamTest i d =
165
165
                        Left e -> error ("invalid key " ++ show bs ++ " for " ++ show (cipherName c) ++ " " ++ show e)
166
166
                        Right k  -> k
167
167
 
 
168
cipherMakeIV :: BlockCipher cipher => cipher -> ByteString -> IV cipher
 
169
cipherMakeIV _ bs = fromJust $ makeIV bs
 
170
 
 
171
 
168
172
maybeGroup :: (String -> t -> [Test]) -> TestName -> [t] -> [Test]
169
173
maybeGroup mkTest groupName l
170
174
    | null l    = []