summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/cryptocore/cryptocore.go2
-rw-r--r--internal/cryptocore/cryptocore_go1.4_test.go20
-rw-r--r--internal/cryptocore/cryptocore_go1.5_test.go16
-rw-r--r--internal/cryptocore/cryptocore_test.go5
-rw-r--r--internal/cryptocore/gcm_go1.4.go29
-rw-r--r--internal/cryptocore/gcm_go1.5.go21
-rw-r--r--internal/nametransform/names.go2
-rw-r--r--internal/nametransform/raw64_go1.4.go18
-rw-r--r--internal/nametransform/raw64_go1.5.go16
-rw-r--r--internal/speed/speed.go2
-rw-r--r--internal/speed/speed_go1.4.go11
-rw-r--r--internal/speed/speed_test.go2
-rw-r--r--internal/stupidgcm/stupidgcm_test.go4
-rw-r--r--internal/tlog/log.go25
-rw-r--r--internal/tlog/log_go1.4.go16
-rw-r--r--internal/tlog/log_go1.5.go32
16 files changed, 31 insertions, 190 deletions
diff --git a/internal/cryptocore/cryptocore.go b/internal/cryptocore/cryptocore.go
index fea0c94..735c409 100644
--- a/internal/cryptocore/cryptocore.go
+++ b/internal/cryptocore/cryptocore.go
@@ -74,7 +74,7 @@ func New(key []byte, aeadType AEADTypeEnum, IVBitLen int) *CryptoCore {
}
aeadCipher = stupidgcm.New(key)
case BackendGoGCM:
- aeadCipher, err = goGCMWrapper(blockCipher, IVLen)
+ aeadCipher, err = cipher.NewGCMWithNonceSize(blockCipher, IVLen)
case BackendAESSIV:
if IVLen != 16 {
// SIV supports any nonce size, but we only use 16.
diff --git a/internal/cryptocore/cryptocore_go1.4_test.go b/internal/cryptocore/cryptocore_go1.4_test.go
deleted file mode 100644
index 14e1e03..0000000
--- a/internal/cryptocore/cryptocore_go1.4_test.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// +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,
-// this should panic.
-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, BackendGoGCM, 128)
-}
diff --git a/internal/cryptocore/cryptocore_go1.5_test.go b/internal/cryptocore/cryptocore_go1.5_test.go
deleted file mode 100644
index f9d38e9..0000000
--- a/internal/cryptocore/cryptocore_go1.5_test.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// +build go1.5
-// = go 1.5 or higher
-
-package cryptocore
-
-import (
- "testing"
-)
-
-func TestCryptoCoreNewGo15(t *testing.T) {
- key := make([]byte, 32)
- c := New(key, BackendGoGCM, 128)
- if c.IVLen != 16 {
- t.Fail()
- }
-}
diff --git a/internal/cryptocore/cryptocore_test.go b/internal/cryptocore/cryptocore_test.go
index c54eac9..252c311 100644
--- a/internal/cryptocore/cryptocore_test.go
+++ b/internal/cryptocore/cryptocore_test.go
@@ -16,7 +16,10 @@ func TestCryptoCoreNew(t *testing.T) {
if c.IVLen != 12 {
t.Fail()
}
- // "New(key, BackendGoGCM, 128)" is tested for Go 1.4 and 1.5+ separately
+ c = New(key, BackendGoGCM, 128)
+ if c.IVLen != 16 {
+ t.Fail()
+ }
}
// "New" should panic on any key not 32 bytes long
diff --git a/internal/cryptocore/gcm_go1.4.go b/internal/cryptocore/gcm_go1.4.go
deleted file mode 100644
index c1aa488..0000000
--- a/internal/cryptocore/gcm_go1.4.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// +build !go1.5
-// = go 1.4 or lower
-
-package cryptocore
-
-import (
- "crypto/cipher"
- "fmt"
-
- "github.com/rfjakob/gocryptfs/internal/tlog"
-)
-
-const (
- // HaveModernGoGCM indicates if Go GCM supports 128-bit nonces
- HaveModernGoGCM = false
-)
-
-// goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go
-// versions 1.4 and lower that lack NewGCMWithNonceSize().
-// 128 bit GCM IVs will not work when using built-in Go crypto, obviously, when
-// compiled on 1.4.
-func goGCMWrapper(bc cipher.Block, nonceSize int) (cipher.AEAD, error) {
- if nonceSize != 12 {
- tlog.Warn.Printf("128 bit GCM IVs are not supported by Go 1.4 and lower.")
- tlog.Warn.Printf("Please use openssl crypto or recompile using a newer Go runtime.")
- return nil, fmt.Errorf("128 bit GCM IVs are not supported by Go 1.4 and lower")
- }
- return cipher.NewGCM(bc)
-}
diff --git a/internal/cryptocore/gcm_go1.5.go b/internal/cryptocore/gcm_go1.5.go
deleted file mode 100644
index 3c38357..0000000
--- a/internal/cryptocore/gcm_go1.5.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// +build go1.5
-// = go 1.5 or higher
-
-package cryptocore
-
-import (
- "crypto/cipher"
-)
-
-const (
- // HaveModernGoGCM indicates if Go GCM supports 128-bit nonces
- HaveModernGoGCM = true
-)
-
-// goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go
-// versions 1.4 and lower that lack NewGCMWithNonceSize().
-// 128 bit GCM IVs will not work when using built-in Go crypto, obviously, when
-// compiled on 1.4.
-func goGCMWrapper(bc cipher.Block, nonceSize int) (cipher.AEAD, error) {
- return cipher.NewGCMWithNonceSize(bc, nonceSize)
-}
diff --git a/internal/nametransform/names.go b/internal/nametransform/names.go
index feec017..83724fb 100644
--- a/internal/nametransform/names.go
+++ b/internal/nametransform/names.go
@@ -24,7 +24,7 @@ type NameTransform struct {
func New(e *eme.EMECipher, longNames bool, raw64 bool) *NameTransform {
b64 := base64.URLEncoding
if raw64 {
- b64 = getRaw64Encoding()
+ b64 = base64.RawURLEncoding
}
return &NameTransform{
emeCipher: e,
diff --git a/internal/nametransform/raw64_go1.4.go b/internal/nametransform/raw64_go1.4.go
deleted file mode 100644
index bbffb69..0000000
--- a/internal/nametransform/raw64_go1.4.go
+++ /dev/null
@@ -1,18 +0,0 @@
-//+build !go1.5
-
-package nametransform
-
-import (
- "encoding/base64"
- "log"
-)
-
-const (
- HaveRaw64 = false
-)
-
-func getRaw64Encoding() *base64.Encoding {
- log.Panicf("Tried to use base64.RawURLEncoding but your Go version does not provide it.\n" +
- "You need Go 1.5 or higher.")
- return nil
-}
diff --git a/internal/nametransform/raw64_go1.5.go b/internal/nametransform/raw64_go1.5.go
deleted file mode 100644
index 1896be3..0000000
--- a/internal/nametransform/raw64_go1.5.go
+++ /dev/null
@@ -1,16 +0,0 @@
-//+build go1.5
-
-package nametransform
-
-import (
- "encoding/base64"
-)
-
-const (
- // HaveRaw64 is true when Go is new enough to have base64.RawURLEncoding
- HaveRaw64 = true
-)
-
-func getRaw64Encoding() *base64.Encoding {
- return base64.RawURLEncoding
-}
diff --git a/internal/speed/speed.go b/internal/speed/speed.go
index bc829d4..f9bf93c 100644
--- a/internal/speed/speed.go
+++ b/internal/speed/speed.go
@@ -1,5 +1,3 @@
-// +build go1.5
-
// Package speed implements the "-speed" command-line option,
// similar to "openssl speed".
// It benchmarks the crypto algorithms and libraries used by
diff --git a/internal/speed/speed_go1.4.go b/internal/speed/speed_go1.4.go
deleted file mode 100644
index 9c0125c..0000000
--- a/internal/speed/speed_go1.4.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// +build !go1.5
-
-package speed
-
-import (
- "fmt"
-)
-
-func Run() {
- fmt.Printf("Compile with Go 1.5 or higher to run the benchmarks\n")
-}
diff --git a/internal/speed/speed_test.go b/internal/speed/speed_test.go
index d6bc187..1e9d859 100644
--- a/internal/speed/speed_test.go
+++ b/internal/speed/speed_test.go
@@ -1,5 +1,3 @@
-// +build go1.5
-
package speed
/*
diff --git a/internal/stupidgcm/stupidgcm_test.go b/internal/stupidgcm/stupidgcm_test.go
index ba25855..3081085 100644
--- a/internal/stupidgcm/stupidgcm_test.go
+++ b/internal/stupidgcm/stupidgcm_test.go
@@ -1,10 +1,6 @@
-// +build go1.5
-// = go 1.5 or higher
-//
// 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.
-
package stupidgcm
import (
diff --git a/internal/tlog/log.go b/internal/tlog/log.go
index bd8844b..720bb88 100644
--- a/internal/tlog/log.go
+++ b/internal/tlog/log.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"log"
+ "log/syslog"
"os"
"golang.org/x/crypto/ssh/terminal"
@@ -117,3 +118,27 @@ func init() {
postfix: ColorReset,
}
}
+
+// SwitchToSyslog redirects the output of this logger to syslog.
+func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
+ w, err := syslog.New(p, ProgramName)
+ if err != nil {
+ Warn.Printf("SwitchToSyslog: %v", err)
+ } else {
+ l.SetOutput(w)
+ }
+}
+
+// SwitchLoggerToSyslog redirects the default log.Logger that the go-fuse lib uses
+// to syslog.
+func SwitchLoggerToSyslog(p syslog.Priority) {
+ w, err := syslog.New(p, ProgramName)
+ if err != nil {
+ Warn.Printf("SwitchLoggerToSyslog: %v", err)
+ } else {
+ log.SetPrefix("go-fuse: ")
+ // Disable printing the timestamp, syslog already provides that
+ log.SetFlags(0)
+ log.SetOutput(w)
+ }
+}
diff --git a/internal/tlog/log_go1.4.go b/internal/tlog/log_go1.4.go
deleted file mode 100644
index 98d69db..0000000
--- a/internal/tlog/log_go1.4.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// +build !go1.5
-// = go 1.4 or lower
-
-package tlog
-
-import (
- "log/syslog"
-)
-
-func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
- Info.Printf("Cannot switch to syslog - need Go 1.5 or higher")
-}
-
-func SwitchLoggerToSyslog(p syslog.Priority) {
- Info.Printf("Cannot switch to syslog - need Go 1.5 or higher")
-}
diff --git a/internal/tlog/log_go1.5.go b/internal/tlog/log_go1.5.go
deleted file mode 100644
index 9c152d9..0000000
--- a/internal/tlog/log_go1.5.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// +build go1.5
-// = go 1.5 or higher
-
-package tlog
-
-import (
- "log"
- "log/syslog"
-)
-
-func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
- w, err := syslog.New(p, ProgramName)
- if err != nil {
- Warn.Printf("SwitchToSyslog: %v", err)
- } else {
- l.SetOutput(w)
- }
-}
-
-// SwitchLoggerToSyslog redirects the default log.Logger that the go-fuse lib uses
-// to syslog.
-func SwitchLoggerToSyslog(p syslog.Priority) {
- w, err := syslog.New(p, ProgramName)
- if err != nil {
- Warn.Printf("SwitchLoggerToSyslog: %v", err)
- } else {
- log.SetPrefix("go-fuse: ")
- // Disable printing the timestamp, syslog already provides that
- log.SetFlags(0)
- log.SetOutput(w)
- }
-}