Blame tests/KAT_PubKey.hs
|
Packit |
141393 |
{-# LANGUAGE OverloadedStrings #-}
|
|
Packit |
141393 |
module KAT_PubKey (tests) where
|
|
Packit |
141393 |
|
|
Packit |
141393 |
import Test.Tasty
|
|
Packit |
141393 |
import Test.Tasty.HUnit
|
|
Packit |
141393 |
|
|
Packit |
141393 |
import Data.ByteString (ByteString)
|
|
Packit |
141393 |
import qualified Data.ByteString as B
|
|
Packit |
141393 |
import Data.ByteString.Char8 ()
|
|
Packit |
141393 |
|
|
Packit |
141393 |
import Crypto.PubKey.MaskGenFunction
|
|
Packit |
141393 |
import Crypto.Hash
|
|
Packit |
141393 |
|
|
Packit |
141393 |
import KAT_PubKey.OAEP
|
|
Packit |
141393 |
import KAT_PubKey.PSS
|
|
Packit |
141393 |
import KAT_PubKey.DSA
|
|
Packit |
141393 |
import KAT_PubKey.ECC
|
|
Packit |
141393 |
import KAT_PubKey.ECDSA
|
|
Packit |
141393 |
import Utils
|
|
Packit |
141393 |
import qualified KAT_PubKey.P256 as P256
|
|
Packit |
141393 |
|
|
Packit |
141393 |
data VectorMgf = VectorMgf { seed :: ByteString
|
|
Packit |
141393 |
, dbMask :: ByteString
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
|
|
Packit |
141393 |
doMGFTest (i, vmgf) = testCase (show i) (dbMask vmgf @=? actual)
|
|
Packit |
141393 |
where actual = mgf1 SHA1 (seed vmgf) (B.length $ dbMask vmgf)
|
|
Packit |
141393 |
|
|
Packit |
141393 |
vectorsMGF =
|
|
Packit |
141393 |
[ VectorMgf
|
|
Packit |
141393 |
{ seed = "\xdf\x1a\x89\x6f\x9d\x8b\xc8\x16\xd9\x7c\xd7\xa2\xc4\x3b\xad\x54\x6f\xbe\x8c\xfe"
|
|
Packit |
141393 |
, dbMask = "\x66\xe4\x67\x2e\x83\x6a\xd1\x21\xba\x24\x4b\xed\x65\x76\xb8\x67\xd9\xa4\x47\xc2\x8a\x6e\x66\xa5\xb8\x7d\xee\x7f\xbc\x7e\x65\xaf\x50\x57\xf8\x6f\xae\x89\x84\xd9\xba\x7f\x96\x9a\xd6\xfe\x02\xa4\xd7\x5f\x74\x45\xfe\xfd\xd8\x5b\x6d\x3a\x47\x7c\x28\xd2\x4b\xa1\xe3\x75\x6f\x79\x2d\xd1\xdc\xe8\xca\x94\x44\x0e\xcb\x52\x79\xec\xd3\x18\x3a\x31\x1f\xc8\x97\x39\xa9\x66\x43\x13\x6e\x8b\x0f\x46\x5e\x87\xa4\x53\x5c\xd4\xc5\x9b\x10\x02\x8d"
|
|
Packit |
141393 |
}
|
|
Packit |
141393 |
]
|
|
Packit |
141393 |
|
|
Packit |
141393 |
tests = testGroup "PubKey"
|
|
Packit |
141393 |
[ testGroup "MGF1" $ map doMGFTest (zip [katZero..] vectorsMGF)
|
|
Packit |
141393 |
, pssTests
|
|
Packit |
141393 |
, oaepTests
|
|
Packit |
141393 |
, dsaTests
|
|
Packit |
141393 |
, eccTests
|
|
Packit |
141393 |
, ecdsaTests
|
|
Packit |
141393 |
, P256.tests
|
|
Packit |
141393 |
]
|
|
Packit |
141393 |
|
|
Packit |
141393 |
--newKats = [ eccKatTests ]
|