hmac-drbg

Pure Haskell HMAC-DRBG per NIST-SP 800-90A.
git clone git://git.ppad.tech/hmac-drbg.git
Log | Files | Refs | LICENSE

commit 56602578ed8a316b546136f064cc19292cd8333a
parent 3d7fbd0d1d0dfbd61a98d27526e1aee319eb32c1
Author: Jared Tobin <jared@jtobin.io>
Date:   Thu,  3 Oct 2024 21:19:08 +0400

bench: basic suite

Diffstat:
Abench/Main.hs | 28++++++++++++++++++++++++++++
Mlib/Crypto/DRBG/HMAC.hs | 1-
Mppad-hmac-drbg.cabal | 16++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/bench/Main.hs b/bench/Main.hs @@ -0,0 +1,28 @@ +{-# OPTIONS_GHC -fno-warn-missing-signatures #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import Criterion.Main +import qualified Crypto.DRBG.HMAC as DRBG +import qualified Crypto.Hash.SHA256 as SHA256 + +main :: IO () +main = do + !drbg <- DRBG.new SHA256.hmac mempty mempty mempty -- no NFData + defaultMain [ + suite drbg + ] + +suite drbg = + bgroup "ppad-hmac-drbg" [ + bgroup "HMAC-SHA256" [ + bench "gen (32B)" $ whnfAppIO (DRBG.gen mempty 32) drbg + , bench "gen (64B)" $ whnfAppIO (DRBG.gen mempty 64) drbg + , bench "gen (128B)" $ whnfAppIO (DRBG.gen mempty 128) drbg + , bench "gen (256B)" $ whnfAppIO (DRBG.gen mempty 256) drbg + , bench "gen (512B)" $ whnfAppIO (DRBG.gen mempty 512) drbg + ] + ] + diff --git a/lib/Crypto/DRBG/HMAC.hs b/lib/Crypto/DRBG/HMAC.hs @@ -18,7 +18,6 @@ import qualified Data.ByteString.Builder as BSB import qualified Data.Primitive.MutVar as P import Data.Word (Word64) - -- keystroke savers and utilities --------------------------------------------- fi :: (Integral a, Num b) => a -> b diff --git a/ppad-hmac-drbg.cabal b/ppad-hmac-drbg.cabal @@ -49,3 +49,19 @@ test-suite hmac-drbg-tests , tasty , tasty-hunit +benchmark hmac-drbg-bench + type: exitcode-stdio-1.0 + default-language: Haskell2010 + hs-source-dirs: bench + main-is: Main.hs + + ghc-options: + -rtsopts -O2 -Wall + + build-depends: + base + , bytestring + , criterion + , ppad-hmac-drbg + , ppad-sha256 +