summaryrefslogtreecommitdiff
path: root/openssl_benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'openssl_benchmark')
-rw-r--r--openssl_benchmark/openssl_test.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/openssl_benchmark/openssl_test.go b/openssl_benchmark/openssl_test.go
index 06dce03..a1e3d17 100644
--- a/openssl_benchmark/openssl_test.go
+++ b/openssl_benchmark/openssl_test.go
@@ -13,25 +13,22 @@ import (
"crypto/cipher"
"github.com/spacemonkeygo/openssl"
"testing"
+ "github.com/rfjakob/gocryptfs/cryptfs"
)
func TestMain(m *testing.M) {
- fmt.Printf("Benchmarking AES-GCM-128 with 4kB block size\n")
+ fmt.Printf("Benchmarking AES-GCM-%d with 4kB block size\n", cryptfs.KEY_LEN*8)
r := m.Run()
os.Exit(r)
}
-// This gets rid of the "testing: warning: no tests to run" message
-func TestDummy(t *testing.T) {
-}
-
func BenchmarkGoEnc4K(b *testing.B) {
buf := make([]byte, 1024*4)
b.SetBytes(int64(len(buf)))
- var key [16]byte
+ var key [cryptfs.KEY_LEN]byte
var nonce [12]byte
aes, _ := aes.NewCipher(key[:])
aesgcm, _ := cipher.NewGCM(aes)
@@ -47,7 +44,7 @@ func BenchmarkGoDec4K(b *testing.B) {
buf := make([]byte, 1024*4)
b.SetBytes(int64(len(buf)))
- var key [16]byte
+ var key [cryptfs.KEY_LEN]byte
var nonce [12]byte
aes, _ := aes.NewCipher(key[:])
aesgcm, _ := cipher.NewGCM(aes)
@@ -67,7 +64,7 @@ func BenchmarkOpensslEnc4K(b *testing.B) {
buf := make([]byte, 1024*4)
b.SetBytes(int64(len(buf)))
- var key [16]byte
+ var key [cryptfs.KEY_LEN]byte
var nonce [12]byte
var ciphertext bytes.Buffer
@@ -76,7 +73,7 @@ func BenchmarkOpensslEnc4K(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
ciphertext.Reset()
- ectx, err := openssl.NewGCMEncryptionCipherCtx(128, nil, key[:], nonce[:])
+ ectx, err := openssl.NewGCMEncryptionCipherCtx(cryptfs.KEY_LEN*8, nil, key[:], nonce[:])
if err != nil {
b.FailNow()
}
@@ -105,7 +102,7 @@ func BenchmarkOpensslDec4K(b *testing.B) {
tag := buf[4096:]
buf = buf[0:4096]
- var key [16]byte
+ var key [cryptfs.KEY_LEN]byte
var nonce [12]byte
var plaintext bytes.Buffer
@@ -114,7 +111,7 @@ func BenchmarkOpensslDec4K(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
plaintext.Reset()
- dctx, err := openssl.NewGCMDecryptionCipherCtx(128, nil, key[:], nonce[:])
+ dctx, err := openssl.NewGCMDecryptionCipherCtx(cryptfs.KEY_LEN*8, nil, key[:], nonce[:])
if err != nil {
b.FailNow()
}
@@ -137,12 +134,12 @@ func BenchmarkOpensslDec4K(b *testing.B) {
func makeOpensslCiphertext() []byte {
buf := make([]byte, 1024*4)
- var key [16]byte
+ var key [cryptfs.KEY_LEN]byte
var nonce [12]byte
var ciphertext bytes.Buffer
var part []byte
- ectx, _ := openssl.NewGCMEncryptionCipherCtx(128, nil, key[:], nonce[:])
+ ectx, _ := openssl.NewGCMEncryptionCipherCtx(cryptfs.KEY_LEN*8, nil, key[:], nonce[:])
part, _ = ectx.EncryptUpdate(buf)
ciphertext.Write(part)
part, _ = ectx.EncryptFinal()