Add AES-GCM-SIV to AEAD benchmarks

This commit is contained in:
Olivier Chéron 2019-08-25 08:55:54 +02:00
parent 908f979d44
commit 73719cbe88

View File

@ -6,6 +6,7 @@ module Main where
import Gauge.Main import Gauge.Main
import Crypto.Cipher.AES import Crypto.Cipher.AES
import qualified Crypto.Cipher.AESGCMSIV as AESGCMSIV
import Crypto.Cipher.Blowfish import Crypto.Cipher.Blowfish
import Crypto.Cipher.CAST5 import Crypto.Cipher.CAST5
import qualified Crypto.Cipher.ChaChaPoly1305 as CP import qualified Crypto.Cipher.ChaChaPoly1305 as CP
@ -167,6 +168,7 @@ benchAE =
[ bench "ChaChaPoly1305" $ nf (cp key32) (input64, input1024) [ bench "ChaChaPoly1305" $ nf (cp key32) (input64, input1024)
, bench "AES-GCM" $ nf (gcm key32) (input64, input1024) , bench "AES-GCM" $ nf (gcm key32) (input64, input1024)
, bench "AES-CCM" $ nf (ccm key32) (input64, input1024) , bench "AES-CCM" $ nf (ccm key32) (input64, input1024)
, bench "AES-GCM-SIV" $ nf (gcmsiv key32) (input64, input1024)
] ]
where cp k (ini, plain) = where cp k (ini, plain) =
let iniState = throwCryptoError $ CP.initialize k (throwCryptoError $ CP.nonce12 nonce12) let iniState = throwCryptoError $ CP.initialize k (throwCryptoError $ CP.nonce12 nonce12)
@ -186,6 +188,11 @@ benchAE =
state = throwCryptoError $ aeadInit mode ctx nonce12 state = throwCryptoError $ aeadInit mode ctx nonce12
in aeadSimpleEncrypt state ini plain 16 in aeadSimpleEncrypt state ini plain 16
gcmsiv k (ini, plain) =
let ctx = throwCryptoError (cipherInit k) :: AES256
iv = throwCryptoError (AESGCMSIV.nonce nonce12)
in AESGCMSIV.encrypt ctx iv ini plain
input64 = B.replicate 64 0 input64 = B.replicate 64 0
input1024 = B.replicate 1024 0 input1024 = B.replicate 1024 0