69d88505fd
Our git version is v2+ for some time now, but go.mod still declared v1. Hopefully making both match makes https://pkg.go.dev/github.com/rfjakob/gocryptfs/v2 work. All the import paths have been fixed like this: find . -name \*.go | xargs sed -i s%github.com/rfjakob/gocryptfs/%github.com/rfjakob/gocryptfs/v2/%
42 lines
840 B
Go
42 lines
840 B
Go
package cryptocore
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/rfjakob/gocryptfs/v2/internal/stupidgcm"
|
|
)
|
|
|
|
// "New" should accept at least these param combinations
|
|
func TestCryptoCoreNew(t *testing.T) {
|
|
key := make([]byte, 32)
|
|
for _, useHKDF := range []bool{true, false} {
|
|
c := New(key, BackendGoGCM, 96, useHKDF, false)
|
|
if c.IVLen != 12 {
|
|
t.Fail()
|
|
}
|
|
c = New(key, BackendGoGCM, 128, useHKDF, false)
|
|
if c.IVLen != 16 {
|
|
t.Fail()
|
|
}
|
|
if stupidgcm.BuiltWithoutOpenssl {
|
|
continue
|
|
}
|
|
c = New(key, BackendOpenSSL, 128, useHKDF, false)
|
|
if c.IVLen != 16 {
|
|
t.Fail()
|
|
}
|
|
}
|
|
}
|
|
|
|
// "New" should panic on any key not 32 bytes long
|
|
func TestNewPanic(t *testing.T) {
|
|
defer func() {
|
|
if r := recover(); r == nil {
|
|
t.Errorf("The code did not panic")
|
|
}
|
|
}()
|
|
|
|
key := make([]byte, 16)
|
|
New(key, BackendOpenSSL, 128, true, false)
|
|
}
|