Main.hs (831B)
1 {-# LANGUAGE BangPatterns #-} 2 {-# LANGUAGE OverloadedStrings #-} 3 4 module Main where 5 6 import Criterion.Main 7 import qualified Crypto.MAC.Poly1305 as Poly1305 8 import qualified Data.ByteString as BS 9 import qualified Data.ByteString.Base16 as B16 10 import Data.Maybe (fromJust) 11 12 main :: IO () 13 main = defaultMain [ 14 suite 15 ] 16 17 msg :: BS.ByteString 18 msg = fromJust . B16.decode $ 19 "4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" 20 21 key :: BS.ByteString 22 key = fromJust . B16.decode $ 23 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" 24 25 suite :: Benchmark 26 suite = 27 bgroup "ppad-poly1305" [ 28 bench "mac" $ nf (Poly1305.mac key) msg 29 ] 30