2015-12-10 20:52:59 +01:00
|
|
|
// +build !go1.5
|
2016-01-22 21:39:16 +01:00
|
|
|
// = go 1.4 or lower
|
2015-12-10 20:52:59 +01:00
|
|
|
|
2016-02-06 19:20:54 +01:00
|
|
|
package cryptocore
|
2015-12-10 20:52:59 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/cipher"
|
2015-12-13 20:10:52 +01:00
|
|
|
"fmt"
|
2016-03-03 00:48:32 +01:00
|
|
|
|
2016-06-15 23:30:44 +02:00
|
|
|
"github.com/rfjakob/gocryptfs/internal/tlog"
|
2015-12-10 20:52:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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.
|
2015-12-13 20:10:52 +01:00
|
|
|
func goGCMWrapper(bc cipher.Block, nonceSize int) (cipher.AEAD, error) {
|
2015-12-10 20:52:59 +01:00
|
|
|
if nonceSize != 12 {
|
2016-06-15 23:30:44 +02:00
|
|
|
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.")
|
2015-12-10 20:52:59 +01:00
|
|
|
return nil, fmt.Errorf("128 bit GCM IVs are not supported by Go 1.4 and lower")
|
|
|
|
}
|
|
|
|
return cipher.NewGCM(bc)
|
|
|
|
}
|