libgocryptfs/internal/cryptocore/cryptocore_test.go
Jakob Unterwurzacher 966308eeb7 Drop Go 1.4 compatability code everywhere
Yields a nice reduction in code size.
2017-03-05 17:44:14 +01:00

36 lines
610 B
Go

package cryptocore
import (
"testing"
)
// "New" should accept at least these param combinations
func TestCryptoCoreNew(t *testing.T) {
key := make([]byte, 32)
c := New(key, BackendOpenSSL, 128)
if c.IVLen != 16 {
t.Fail()
}
c = New(key, BackendGoGCM, 96)
if c.IVLen != 12 {
t.Fail()
}
c = New(key, BackendGoGCM, 128)
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)
}