hmac-drbg

Pure Haskell HMAC-DRBG (docs.ppad.tech/hmac-drbg).
git clone git://git.ppad.tech/hmac-drbg.git
Log | Files | Refs | README | LICENSE

Main.hs (1067B)


      1 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
      2 {-# LANGUAGE BangPatterns #-}
      3 {-# LANGUAGE OverloadedStrings #-}
      4 
      5 module Main where
      6 
      7 import Criterion.Main
      8 import qualified Crypto.DRBG.HMAC as DRBG
      9 import qualified Crypto.Hash.SHA256 as SHA256
     10 import qualified Crypto.Hash.SHA512 as SHA512
     11 
     12 main :: IO ()
     13 main = do
     14   !drbg <- DRBG.new SHA256.hmac mempty mempty mempty -- no NFData
     15   defaultMain [
     16       suite drbg
     17     ]
     18 
     19 suite drbg =
     20   bgroup "ppad-hmac-drbg" [
     21     bgroup "HMAC-SHA256" [
     22       bench "new" $ whnfAppIO (DRBG.new SHA256.hmac mempty mempty) mempty
     23     , bench "reseed" $ whnfAppIO (DRBG.reseed mempty mempty) drbg
     24     , bench "gen (32B)"  $ whnfAppIO (DRBG.gen mempty 32) drbg
     25     , bench "gen (256B)" $ whnfAppIO (DRBG.gen mempty 256) drbg
     26     ]
     27   , bgroup "HMAC-SHA512" [
     28       bench "new" $ whnfAppIO (DRBG.new SHA512.hmac mempty mempty) mempty
     29     , bench "reseed" $ whnfAppIO (DRBG.reseed mempty mempty) drbg
     30     , bench "gen (32B)"  $ whnfAppIO (DRBG.gen mempty 32) drbg
     31     , bench "gen (256B)" $ whnfAppIO (DRBG.gen mempty 256) drbg
     32     ]
     33   ]
     34