summaryrefslogtreecommitdiff
path: root/internal/speed/speed.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/speed/speed.go')
-rw-r--r--internal/speed/speed.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/speed/speed.go b/internal/speed/speed.go
index 37b9daf..a696703 100644
--- a/internal/speed/speed.go
+++ b/internal/speed/speed.go
@@ -92,6 +92,25 @@ func bEncrypt(b *testing.B, c cipher.AEAD) {
}
+func bDecrypt(b *testing.B, c cipher.AEAD) {
+ authData := randBytes(adLen)
+ iv := randBytes(c.NonceSize())
+ plain := randBytes(blockSize)
+ ciphertext := c.Seal(iv, iv, plain, authData)
+
+ b.SetBytes(int64(len(plain)))
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ // Reset plain buffer
+ plain = plain[:0]
+ // Decrypt
+ _, err := c.Open(plain, iv, ciphertext[c.NonceSize():], authData)
+ if err != nil {
+ b.Fatal(err)
+ }
+ }
+}
+
// bStupidGCM benchmarks stupidgcm's openssl GCM
func bStupidGCM(b *testing.B) {
if stupidgcm.BuiltWithoutOpenssl {