Skip to content

Commit 20e8f4b

Browse files
committed
xts: add an xts benchmark
1 parent 37a17fe commit 20e8f4b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

xts/xts_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,19 @@ func TestShorterCiphertext(t *testing.T) {
103103
t.Errorf("En/Decryption is not inverse")
104104
}
105105
}
106+
107+
func BenchmarkXTS(b *testing.B) {
108+
b.ReportAllocs()
109+
c, err := NewCipher(aes.NewCipher, make([]byte, 32))
110+
if err != nil {
111+
b.Fatalf("NewCipher failed: %s", err)
112+
}
113+
plaintext := make([]byte, 32)
114+
encrypted := make([]byte, 48)
115+
decrypted := make([]byte, 48)
116+
117+
for i := 0; i < b.N; i++ {
118+
c.Encrypt(encrypted, plaintext, 0)
119+
c.Decrypt(decrypted, encrypted[:len(plaintext)], 0)
120+
}
121+
}

0 commit comments

Comments
 (0)