aboutsummaryrefslogtreecommitdiff
path: root/internal/cryptocore
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-05-04 22:10:06 +0200
committerJakob Unterwurzacher2016-05-05 00:09:08 +0200
commit66156181ee656a3c96175edb3bf3c5904102786a (patch)
treeeb53b6e0c69694a3adb9b73f4874fd8000d77101 /internal/cryptocore
parent508a949d9d07c8efb8ed838c2f7747341a917099 (diff)
cryptocore: support Go 1.4 in tests
Diffstat (limited to 'internal/cryptocore')
-rw-r--r--internal/cryptocore/cryptocore_go1.4_test.go19
-rw-r--r--internal/cryptocore/cryptocore_go1.5_test.go17
-rw-r--r--internal/cryptocore/cryptocore_test.go5
3 files changed, 39 insertions, 2 deletions
diff --git a/internal/cryptocore/cryptocore_go1.4_test.go b/internal/cryptocore/cryptocore_go1.4_test.go
new file mode 100644
index 0000000..3460d02
--- /dev/null
+++ b/internal/cryptocore/cryptocore_go1.4_test.go
@@ -0,0 +1,19 @@
+// +build !go1.5
+// = go 1.4 or lower
+
+package cryptocore
+
+import (
+ "testing"
+)
+
+// Native Go crypto with 128-bit IVs is only supported on Go 1.5 and up
+func TestCryptoCoreNewGo14(t *testing.T) {
+ defer func() {
+ if r := recover(); r == nil {
+ t.Errorf("The code did not panic")
+ }
+ }()
+ key := make([]byte, 32)
+ New(key, false, true)
+}
diff --git a/internal/cryptocore/cryptocore_go1.5_test.go b/internal/cryptocore/cryptocore_go1.5_test.go
new file mode 100644
index 0000000..9e24979
--- /dev/null
+++ b/internal/cryptocore/cryptocore_go1.5_test.go
@@ -0,0 +1,17 @@
+// +build go1.5
+// = go 1.5 or higher
+
+package cryptocore
+
+import (
+ "testing"
+)
+
+// Native Go crypto with 128-bit IVs is only supported on Go 1.5 and up
+func TestCryptoCoreNewGo15(t *testing.T) {
+ key := make([]byte, 32)
+ c := New(key, false, true)
+ if c.IVLen != 12 {
+ t.Fail()
+ }
+}
diff --git a/internal/cryptocore/cryptocore_test.go b/internal/cryptocore/cryptocore_test.go
index fd6a300..1151591 100644
--- a/internal/cryptocore/cryptocore_test.go
+++ b/internal/cryptocore/cryptocore_test.go
@@ -16,10 +16,11 @@ func TestCryptoCoreNew(t *testing.T) {
if c.IVLen != 12 {
t.Fail()
}
- c = New(key, false, true)
- if c.IVLen != 16 {
+ c = New(key, false, false)
+ if c.IVLen != 12 {
t.Fail()
}
+ // "New(key, false, true)" is tested for Go 1.4 and 1.5+ seperately
}
// "New" should panic on any key not 32 bytes long