Skip to content

Commit

Permalink
macos: make testing without openssl work properly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rfjakob committed Jul 14, 2017
1 parent 61e9644 commit ccf1a84
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/contentenc/content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestSplitRange(t *testing.T) {
testRange{6654, 8945})

key := make([]byte, cryptocore.KeyLen)
cc := cryptocore.New(key, cryptocore.BackendOpenSSL, DefaultIVBits, true, false)
cc := cryptocore.New(key, cryptocore.BackendGoGCM, DefaultIVBits, true, false)
f := New(cc, DefaultBS, false)

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

key := make([]byte, cryptocore.KeyLen)
cc := cryptocore.New(key, cryptocore.BackendOpenSSL, DefaultIVBits, true, false)
cc := cryptocore.New(key, cryptocore.BackendGoGCM, DefaultIVBits, true, false)
f := New(cc, DefaultBS, false)

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

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

b := f.CipherOffToBlockNo(788)
Expand Down
15 changes: 10 additions & 5 deletions internal/cryptocore/cryptocore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ package cryptocore

import (
"testing"

"github.com/rfjakob/gocryptfs/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, BackendOpenSSL, 128, useHKDF, false)
if c.IVLen != 16 {
t.Fail()
}
c = New(key, BackendGoGCM, 96, useHKDF, 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()
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions internal/stupidgcm/stupidgcm_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !without_openssl

// We compare against Go's built-in GCM implementation. Since stupidgcm only
// supports 128-bit IVs and Go only supports that from 1.5 onward, we cannot
// run these tests on older Go versions.
Expand Down

0 comments on commit ccf1a84

Please sign in to comment.