aboutsummaryrefslogtreecommitdiff
path: root/internal/stupidgcm/stupidgcm_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-09-25 20:04:33 +0200
committerJakob Unterwurzacher2016-09-25 20:04:55 +0200
commit0e277ba19e3a18093c33d3927739031b76892de3 (patch)
treec17f019c3f7b9896e6f20455213a3a682af570b4 /internal/stupidgcm/stupidgcm_test.go
parent32e35adcadb99bdcbc129fe419269a675cb4fd40 (diff)
stupidgcm: add GCM-SIV benchmark
On a CPU without AES-NI: $ go test -bench . Benchmark4kEncStupidGCM-2 50000 24155 ns/op 169.57 MB/s Benchmark4kEncGoGCM-2 20000 93965 ns/op 43.59 MB/s Benchmark4kEncGCMSIV-2 500 2576193 ns/op 1.59 MB/s
Diffstat (limited to 'internal/stupidgcm/stupidgcm_test.go')
-rw-r--r--internal/stupidgcm/stupidgcm_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/stupidgcm/stupidgcm_test.go b/internal/stupidgcm/stupidgcm_test.go
index b0e25ab..1dbfccb 100644
--- a/internal/stupidgcm/stupidgcm_test.go
+++ b/internal/stupidgcm/stupidgcm_test.go
@@ -14,6 +14,8 @@ import (
"crypto/rand"
"encoding/hex"
"testing"
+
+ "github.com/rfjakob/gcmsiv"
)
// Get "n" random bytes from /dev/urandom or panic
@@ -159,3 +161,19 @@ func Benchmark4kEncGoGCM(b *testing.B) {
gGCM.Seal(iv, iv, in, authData)
}
}
+
+func Benchmark4kEncGCMSIV(b *testing.B) {
+ key := randBytes(32)
+ authData := randBytes(24)
+ iv := randBytes(16)
+ in := make([]byte, 4096)
+ b.SetBytes(int64(len(in)))
+ gGCM, err := gcmsiv.NewGCMSIV(key)
+ if err != nil {
+ b.Fatal(err)
+ }
+ for i := 0; i < b.N; i++ {
+ // Encrypt and append to nonce
+ gGCM.Seal(iv, iv, in, authData)
+ }
+}