Weight.hs (834B)
1 {-# OPTIONS_GHC -fno-warn-orphans #-} 2 {-# LANGUAGE BangPatterns #-} 3 {-# LANGUAGE OverloadedStrings #-} 4 5 module Main where 6 7 import Control.DeepSeq 8 import qualified Crypto.MAC.Poly1305 as Poly1305 9 import qualified Data.ByteString as BS 10 import Weigh 11 12 instance NFData Poly1305.MAC where 13 rnf (Poly1305.MAC b) = rnf b 14 15 -- note that 'weigh' doesn't work properly in a repl 16 main :: IO () 17 main = mainWith mac 18 19 mac :: Weigh () 20 mac = 21 let !key = BS.replicate 32 0x88 22 !bs0 = BS.replicate 16 0 23 !bs1 = BS.replicate 64 0 24 !bs2 = BS.replicate 128 0 25 !bs3 = BS.replicate 1024 0 26 in wgroup "mac" $ do 27 func "mac (16B input)" (Poly1305.mac key) bs0 28 func "mac (64B input)" (Poly1305.mac key) bs1 29 func "mac (128B input)" (Poly1305.mac key) bs2 30 func "mac (1024B input)" (Poly1305.mac key) bs3