commit c7be2ec6af1943172444c2d140e053ac92799479
parent 268bab002f8fe1706d5becb31ba843be46ab009a
Author: Jared Tobin <jared@jtobin.io>
Date: Sun, 26 Apr 2026 07:18:17 -0230
test, bench: update for MAC type
Diffstat:
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/bench/Main.hs b/bench/Main.hs
@@ -1,14 +1,19 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
+import Control.DeepSeq
import Criterion.Main
import qualified Crypto.MAC.Poly1305 as Poly1305
import qualified Data.ByteString as BS
import qualified Data.ByteString.Base16 as B16
import Data.Maybe (fromJust)
+instance NFData Poly1305.MAC where
+ rnf (Poly1305.MAC b) = rnf b
+
main :: IO ()
main = defaultMain [
suite
diff --git a/bench/Weight.hs b/bench/Weight.hs
@@ -1,12 +1,17 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
+import Control.DeepSeq
import qualified Crypto.MAC.Poly1305 as Poly1305
import qualified Data.ByteString as BS
import Weigh
+instance NFData Poly1305.MAC where
+ rnf (Poly1305.MAC b) = rnf b
+
-- note that 'weigh' doesn't work properly in a repl
main :: IO ()
main = mainWith mac
diff --git a/ppad-poly1305.cabal b/ppad-poly1305.cabal
@@ -68,6 +68,7 @@ benchmark poly1305-bench
base
, bytestring
, criterion
+ , deepseq
, ppad-base16
, ppad-poly1305
@@ -85,6 +86,7 @@ benchmark poly1305-weigh
build-depends:
base
, bytestring
+ , deepseq
, ppad-poly1305
, weigh
diff --git a/test/Main.hs b/test/Main.hs
@@ -35,7 +35,7 @@ mac = H.testCase "mac" $ do
Just e = B16.decode "a8061dc1305136c6c22b8baf0c0127a9"
Just o = Poly1305.mac key msg
- H.assertEqual mempty e o
+ H.assertEqual mempty (Poly1305.MAC e) o
mac1 :: TestTree
mac1 = H.testCase "mac (A.3 #1)" $ do
@@ -46,7 +46,7 @@ mac1 = H.testCase "mac (A.3 #1)" $ do
Just tag = B16.decode
"00000000000000000000000000000000"
Just out = Poly1305.mac key msg
- H.assertEqual mempty tag out
+ H.assertEqual mempty (Poly1305.MAC tag) out
mac2 :: TestTree
mac2 = H.testCase "mac (A.3 #2)" $ do
@@ -57,7 +57,7 @@ mac2 = H.testCase "mac (A.3 #2)" $ do
Just tag = B16.decode
"36e5f6b5c5e06070f0efca96227a863e"
Just out = Poly1305.mac key msg
- H.assertEqual mempty tag out
+ H.assertEqual mempty (Poly1305.MAC tag) out
mac3 :: TestTree
mac3 = H.testCase "mac (A.3 #3)" $ do
@@ -68,7 +68,7 @@ mac3 = H.testCase "mac (A.3 #3)" $ do
Just tag = B16.decode
"f3477e7cd95417af89a6b8794c310cf0"
Just out = Poly1305.mac key msg
- H.assertEqual mempty tag out
+ H.assertEqual mempty (Poly1305.MAC tag) out
mac4 :: TestTree
mac4 = H.testCase "mac (A.3 #4)" $ do
@@ -79,7 +79,7 @@ mac4 = H.testCase "mac (A.3 #4)" $ do
Just tag = B16.decode
"4541669a7eaaee61e708dc7cbcc5eb62"
Just out = Poly1305.mac key msg
- H.assertEqual mempty tag out
+ H.assertEqual mempty (Poly1305.MAC tag) out
mac5 :: TestTree
mac5 = H.testCase "mac (A.3 #5)" $ do