aboutsummaryrefslogtreecommitdiff
path: root/internal/cryptocore/cryptocore_test.go
blob: 9da6059740f892cced9a0be3901c06a8739860ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()
	}
	// "New(key, BackendGoGCM, 128)" is tested for Go 1.4 and 1.5+ seperately
}

// "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)
}