From 1e03e059fa0980db8d527f1c01094999d8813b95 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 22 Feb 2017 23:55:43 +0100 Subject: Implement "gocryptfs -speed" A crypto benchmark mode like "openssl speed". Example run: $ ./gocryptfs -speed AES-GCM-256-OpenSSL 180.89 MB/s (selected in auto mode) AES-GCM-256-Go 48.19 MB/s AES-SIV-512-Go 37.40 MB/s --- internal/stupidgcm/stupidgcm_test.go | 58 ------------------------------------ 1 file changed, 58 deletions(-) (limited to 'internal/stupidgcm/stupidgcm_test.go') diff --git a/internal/stupidgcm/stupidgcm_test.go b/internal/stupidgcm/stupidgcm_test.go index d6c0714..ba25855 100644 --- a/internal/stupidgcm/stupidgcm_test.go +++ b/internal/stupidgcm/stupidgcm_test.go @@ -15,9 +15,6 @@ import ( "encoding/hex" "log" "testing" - - // For benchmark comparison - "github.com/rfjakob/gocryptfs/internal/siv_aead" ) // Get "n" random bytes from /dev/urandom or panic @@ -121,58 +118,3 @@ func TestCorruption(t *testing.T) { t.Fatalf("Should have gotten error") } } - -// $ go test -bench . -// PASS -// Benchmark4kEncStupidGCM-2 50000 25622 ns/op 159.86 MB/s -// Benchmark4kEncGoGCM-2 10000 116544 ns/op 35.15 MB/s -// ok github.com/rfjakob/gocryptfs/internal/stupidgcm 3.775s -func Benchmark4kEncStupidGCM(b *testing.B) { - key := randBytes(32) - authData := randBytes(24) - iv := randBytes(16) - in := make([]byte, 4096) - b.SetBytes(int64(len(in))) - - sGCM := New(key) - - for i := 0; i < b.N; i++ { - // Encrypt and append to nonce - sGCM.Seal(iv, iv, in, authData) - } -} - -func Benchmark4kEncGoGCM(b *testing.B) { - key := randBytes(32) - authData := randBytes(24) - iv := randBytes(16) - in := make([]byte, 4096) - b.SetBytes(int64(len(in))) - - gAES, err := aes.NewCipher(key) - if err != nil { - b.Fatal(err) - } - gGCM, err := cipher.NewGCMWithNonceSize(gAES, 16) - if err != nil { - b.Fatal(err) - } - - for i := 0; i < b.N; i++ { - // Encrypt and append to nonce - gGCM.Seal(iv, iv, in, authData) - } -} - -func Benchmark4kEncAESSIV(b *testing.B) { - key := randBytes(32) - authData := randBytes(24) - iv := randBytes(16) - in := make([]byte, 4096) - b.SetBytes(int64(len(in))) - gGCM := siv_aead.New(key) - for i := 0; i < b.N; i++ { - // Encrypt and append to nonce - gGCM.Seal(iv, iv, in, authData) - } -} -- cgit v1.2.3