2022-08-28 11:11:36 +02:00
|
|
|
//go:build !without_openssl
|
2017-07-14 23:22:15 +02:00
|
|
|
// +build !without_openssl
|
|
|
|
|
2016-05-04 22:34:52 +02:00
|
|
|
// We compare against Go's built-in GCM implementation. Since stupidgcm only
|
|
|
|
// supports 128-bit IVs and Go only supports that from 1.5 onward, we cannot
|
|
|
|
// run these tests on older Go versions.
|
2016-05-01 22:26:47 +02:00
|
|
|
package stupidgcm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/aes"
|
|
|
|
"crypto/cipher"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2021-09-02 10:04:38 +02:00
|
|
|
func TestStupidGCM(t *testing.T) {
|
2016-05-01 22:26:47 +02:00
|
|
|
key := randBytes(32)
|
2021-09-10 12:14:19 +02:00
|
|
|
sGCM := NewAES256GCM(key)
|
2016-05-01 22:26:47 +02:00
|
|
|
|
|
|
|
gAES, err := aes.NewCipher(key)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
gGCM, err := cipher.NewGCMWithNonceSize(gAES, 16)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-02 10:04:38 +02:00
|
|
|
testCiphers(t, sGCM, gGCM)
|
2016-05-01 22:26:47 +02:00
|
|
|
}
|