Documentation ¶
Overview ¶
Package cryptocore wraps OpenSSL and Go GCM crypto and provides a nonce generator.
Index ¶
Constants ¶
const ( // KeyLen is the cipher key length in bytes. All backends use 32 bytes. KeyLen = 32 // AuthTagLen is the length of a authentication tag in bytes. // All backends use 16 bytes. AuthTagLen = 16 )
Variables ¶
var BackendAESSIV = AEADTypeEnum{"AES-SIV-512", "Go", siv_aead.NonceSize}
BackendAESSIV specifies an AESSIV backend. "AES-SIV-512-Go" in gocryptfs -speed.
var BackendGoGCM = AEADTypeEnum{"AES-GCM-256", "Go", 16}
BackendGoGCM specifies the Go based AES-256-GCM backend. "AES-GCM-256-Go" in gocryptfs -speed.
var BackendOpenSSL = AEADTypeEnum{"AES-GCM-256", "OpenSSL", 16}
BackendOpenSSL specifies the OpenSSL AES-256-GCM backend. "AES-GCM-256-OpenSSL" in gocryptfs -speed.
var BackendXChaCha20Poly1305 = AEADTypeEnum{"XChaCha20-Poly1305", "Go", chacha20poly1305.NonceSizeX}
BackendXChaCha20Poly1305 specifies XChaCha20-Poly1305-Go. "XChaCha20-Poly1305-Go" in gocryptfs -speed.
var BackendXChaCha20Poly1305OpenSSL = AEADTypeEnum{"XChaCha20-Poly1305", "OpenSSL", chacha20poly1305.NonceSizeX}
BackendXChaCha20Poly1305OpenSSL specifies XChaCha20-Poly1305-OpenSSL.
Functions ¶
Types ¶
type AEADTypeEnum ¶
type AEADTypeEnum struct { // Algo is the encryption algorithm. Example: "AES-GCM-256" Algo string // Lib is the library where Algo is implemented. Either "Go" or "OpenSSL". Lib string NonceSize int }
AEADTypeEnum indicates the type of AEAD backend in use.
func (AEADTypeEnum) String ¶ added in v2.2.1
func (a AEADTypeEnum) String() string
String returns something like "AES-GCM-256-OpenSSL"
type CryptoCore ¶
type CryptoCore struct { // EME is used for filename encryption. EMECipher *eme.EMECipher // GCM or AES-SIV. This is used for content encryption. AEADCipher cipher.AEAD // Which backend is behind AEADCipher? AEADBackend AEADTypeEnum // GCM needs unique IVs (nonces) IVGenerator *nonceGenerator // IVLen in bytes IVLen int }
CryptoCore is the low level crypto implementation.
func New ¶
func New(key []byte, aeadType AEADTypeEnum, IVBitLen int, useHKDF bool) *CryptoCore
New returns a new CryptoCore object or panics.
Even though the "GCMIV128" feature flag is now mandatory, we must still support 96-bit IVs here because they were used for encrypting the master key in gocryptfs.conf up to gocryptfs v1.2. v1.3 switched to 128 bits.
Note: "key" is either the scrypt hash of the password (when decrypting a config file) or the masterkey (when finally mounting the filesystem).
func (*CryptoCore) Wipe ¶
func (c *CryptoCore) Wipe()
Wipe tries to wipe secret keys from memory by overwriting them with zeros and/or setting references to nil.
This is not bulletproof due to possible GC copies, but still raises to bar for extracting the key.