aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-02-29 21:27:05 +0100
committerJakob Unterwurzacher2020-04-13 14:54:04 +0200
commit194030f18ae623fbf5b0bb805b780f81fe9ec7a7 (patch)
tree587a25d65155eb6a9931e2b168cfe69879988da0
parent75f16771ff3380e930f0f569dcecbfd60863b8d0 (diff)
speed: add XChaCha20-Poly1305-Go
https://github.com/rfjakob/gocryptfs/issues/452
-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 2f1e0f6..6cfe511 100644
--- a/internal/speed/speed.go
+++ b/internal/speed/speed.go
@@ -12,6 +12,8 @@ import (
"log"
"testing"
+ "golang.org/x/crypto/chacha20poly1305"
+
"github.com/rfjakob/gocryptfs/internal/siv_aead"
"github.com/rfjakob/gocryptfs/internal/stupidgcm"
)
@@ -32,6 +34,7 @@ func Run() {
{name: "AES-GCM-256-OpenSSL", f: bStupidGCM, preferred: stupidgcm.PreferOpenSSL()},
{name: "AES-GCM-256-Go", f: bGoGCM, preferred: !stupidgcm.PreferOpenSSL()},
{name: "AES-SIV-512-Go", f: bAESSIV, preferred: false},
+ {name: "XChaCha20-Poly1305-Go", f: bChacha20poly1305, preferred: false},
}
for _, b := range bTable {
fmt.Printf("%-20s\t", b.name)
@@ -125,3 +128,19 @@ func bAESSIV(b *testing.B) {
gGCM.Seal(iv, iv, in, authData)
}
}
+
+// bChacha20poly1305 benchmarks XChaCha20 from golang.org/x/crypto/chacha20poly1305
+func bChacha20poly1305(b *testing.B) {
+ key := randBytes(32)
+ authData := randBytes(adLen)
+ iv := randBytes(chacha20poly1305.NonceSizeX)
+ in := make([]byte, blockSize)
+ b.SetBytes(int64(len(in)))
+ c, _ := chacha20poly1305.NewX(key)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ // Encrypt and append to nonce
+ c.Seal(iv, iv, in, authData)
+ }
+}