[tests] re-enable poly1305

This commit is contained in:
Vincent Hanquez 2015-05-02 15:43:49 +01:00
parent 1267500318
commit b28109ecb4

View File

@ -2,12 +2,14 @@
module Main where module Main where
import qualified Data.ByteString as B import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as B ()
import Imports import Imports
import qualified Crypto.Cipher.ChaCha as ChaCha import qualified Crypto.Cipher.ChaCha as ChaCha
import qualified Crypto.Cipher.Salsa as Salsa import qualified Crypto.Cipher.Salsa as Salsa
import qualified Crypto.MAC.Poly1305 as Poly1305 import qualified Crypto.MAC.Poly1305 as Poly1305
import qualified Crypto.Internal.ByteArray as B (convert)
import qualified KATHash import qualified KATHash
import qualified KAT_HMAC import qualified KAT_HMAC
@ -66,19 +68,17 @@ tests = testGroup "cryptonite"
[ testGroup "KAT" $ [ testGroup "KAT" $
map (\(i,f) -> testCase (show (i :: Int)) f) $ zip [1..] $ map (\(r, k,i,e) -> salsaRunSimple e r k i) KATSalsa.vectors map (\(i,f) -> testCase (show (i :: Int)) f) $ zip [1..] $ map (\(r, k,i,e) -> salsaRunSimple e r k i) KATSalsa.vectors
] ]
{-
, testGroup "Poly1305" , testGroup "Poly1305"
[ testCase "V0" $ [ testCase "V0" $
let key = "\x85\xd6\xbe\x78\x57\x55\x6d\x33\x7f\x44\x52\xfe\x42\xd5\x06\xa8\x01\x03\x80\x8a\xfb\x0d\xb2\xfd\x4a\xbf\xf6\xaf\x41\x49\xf5\x1b" :: ByteString let key = "\x85\xd6\xbe\x78\x57\x55\x6d\x33\x7f\x44\x52\xfe\x42\xd5\x06\xa8\x01\x03\x80\x8a\xfb\x0d\xb2\xfd\x4a\xbf\xf6\xaf\x41\x49\xf5\x1b" :: ByteString
msg = "Cryptographic Forum Research Group" msg = "Cryptographic Forum Research Group" :: ByteString
tag = Poly1305.Auth "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9" tag = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9" :: ByteString
in tag @=? Poly1305.auth key msg in tag @=? B.convert (Poly1305.auth key msg)
, testProperty "Chunking" $ \(Chunking chunkLen totalLen) -> , testProperty "Chunking" $ \(Chunking chunkLen totalLen) ->
let key = B.replicate 32 0 let key = B.replicate 32 0
msg = B.pack $ take totalLen $ concat (replicate 10 [1..255]) msg = B.pack $ take totalLen $ concat (replicate 10 [1..255])
in Poly1305.auth key msg == Poly1305.finalize (foldr (flip Poly1305.update) (Poly1305.initialize key) (chunks chunkLen msg)) in Poly1305.auth key msg == Poly1305.finalize (foldr (flip Poly1305.update) (Poly1305.initialize key) (chunks chunkLen msg))
] ]
-}
, KATHash.tests , KATHash.tests
, KAT_HMAC.tests , KAT_HMAC.tests
, KAT_Curve25519.tests , KAT_Curve25519.tests