Skip to content

Commit ccf1a84

Browse files
committed
macos: make testing without openssl work properly
On MacOS, building and testing without openssl is much easier. The tests should skip tests that fail because of missing openssl instead of aborting. Fixes #123
1 parent 61e9644 commit ccf1a84

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

internal/contentenc/content_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestSplitRange(t *testing.T) {
2323
testRange{6654, 8945})
2424

2525
key := make([]byte, cryptocore.KeyLen)
26-
cc := cryptocore.New(key, cryptocore.BackendOpenSSL, DefaultIVBits, true, false)
26+
cc := cryptocore.New(key, cryptocore.BackendGoGCM, DefaultIVBits, true, false)
2727
f := New(cc, DefaultBS, false)
2828

2929
for _, r := range ranges {
@@ -51,7 +51,7 @@ func TestCiphertextRange(t *testing.T) {
5151
testRange{6654, 8945})
5252

5353
key := make([]byte, cryptocore.KeyLen)
54-
cc := cryptocore.New(key, cryptocore.BackendOpenSSL, DefaultIVBits, true, false)
54+
cc := cryptocore.New(key, cryptocore.BackendGoGCM, DefaultIVBits, true, false)
5555
f := New(cc, DefaultBS, false)
5656

5757
for _, r := range ranges {
@@ -74,7 +74,7 @@ func TestCiphertextRange(t *testing.T) {
7474

7575
func TestBlockNo(t *testing.T) {
7676
key := make([]byte, cryptocore.KeyLen)
77-
cc := cryptocore.New(key, cryptocore.BackendOpenSSL, DefaultIVBits, true, false)
77+
cc := cryptocore.New(key, cryptocore.BackendGoGCM, DefaultIVBits, true, false)
7878
f := New(cc, DefaultBS, false)
7979

8080
b := f.CipherOffToBlockNo(788)

internal/cryptocore/cryptocore_test.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@ package cryptocore
22

33
import (
44
"testing"
5+
6+
"github.com./rfjakob/gocryptfs/internal/stupidgcm"
57
)
68

79
// "New" should accept at least these param combinations
810
func TestCryptoCoreNew(t *testing.T) {
911
key := make([]byte, 32)
1012
for _, useHKDF := range []bool{true, false} {
11-
c := New(key, BackendOpenSSL, 128, useHKDF, false)
12-
if c.IVLen != 16 {
13-
t.Fail()
14-
}
15-
c = New(key, BackendGoGCM, 96, useHKDF, false)
13+
c := New(key, BackendGoGCM, 96, useHKDF, false)
1614
if c.IVLen != 12 {
1715
t.Fail()
1816
}
1917
c = New(key, BackendGoGCM, 128, useHKDF, false)
2018
if c.IVLen != 16 {
2119
t.Fail()
2220
}
21+
if stupidgcm.BuiltWithoutOpenssl {
22+
continue
23+
}
24+
c = New(key, BackendOpenSSL, 128, useHKDF, false)
25+
if c.IVLen != 16 {
26+
t.Fail()
27+
}
2328
}
2429
}
2530

internal/stupidgcm/stupidgcm_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build !without_openssl
2+
13
// We compare against Go's built-in GCM implementation. Since stupidgcm only
24
// supports 128-bit IVs and Go only supports that from 1.5 onward, we cannot
35
// run these tests on older Go versions.

0 commit comments

Comments
 (0)