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
|
|
|
|
|
|
|
package cryptfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/cipher"
|
2015-12-13 20:10:52 +01:00
|
|
|
"fmt"
|
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-01-20 20:55:56 +01:00
|
|
|
Warn.Printf("128 bit GCM IVs are not supported by Go 1.4 and lower.")
|
|
|
|
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)
|
|
|
|
}
|