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 (1171B)


      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   !drbg256 <- DRBG.new SHA256.hmac mempty mempty mempty -- no NFData
     15   !drbg512 <- DRBG.new SHA512.hmac mempty mempty mempty -- no NFData
     16   defaultMain [
     17       suite drbg256 drbg512
     18     ]
     19 
     20 suite drbg256 drbg512 =
     21   bgroup "ppad-hmac-drbg" [
     22     bgroup "HMAC-SHA256" [
     23       bench "new" $ whnfAppIO (DRBG.new SHA256.hmac mempty mempty) mempty
     24     , bench "reseed" $ whnfAppIO (DRBG.reseed mempty mempty) drbg256
     25     , bench "gen (32B)"  $ nfAppIO (DRBG.gen mempty 32) drbg256
     26     , bench "gen (256B)" $ nfAppIO (DRBG.gen mempty 256) drbg256
     27     ]
     28   , bgroup "HMAC-SHA512" [
     29       bench "new" $ whnfAppIO (DRBG.new SHA512.hmac mempty mempty) mempty
     30     , bench "reseed" $ whnfAppIO (DRBG.reseed mempty mempty) drbg512
     31     , bench "gen (32B)"  $ nfAppIO (DRBG.gen mempty 32) drbg512
     32     , bench "gen (256B)" $ nfAppIO (DRBG.gen mempty 256) drbg512
     33     ]
     34   ]
     35