cryptocore

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cryptocore wraps OpenSSL and Go GCM crypto and provides a nonce generator.

Index

Constants

View Source
const (
	// HaveModernGoGCM indicates if Go GCM supports 128-bit nonces
	HaveModernGoGCM = true
)

Variables

This section is empty.

Functions

func RandBytes

func RandBytes(n int) []byte

RandBytes gets "n" random bytes from /dev/urandom or panics

func RandUint64

func RandUint64() uint64

RandUint64 returns a secure random uint64

Types

type BackendTypeEnum

type BackendTypeEnum int

BackendTypeEnum indicates the type of backend in use.

const (
	// KeyLen is the cipher key length in bytes.  32 for AES-256.
	KeyLen = 32
	// AuthTagLen is the length of a GCM auth tag in bytes.
	AuthTagLen = 16

	// BackendOpenSSL specifies the OpenSSL backend.
	BackendOpenSSL BackendTypeEnum = iota
	// BackendGoGCM specifies the Go based GCM backend.
	BackendGoGCM BackendTypeEnum = iota
	// BackendAESSIV specifies an AESSIV backend.
	BackendAESSIV BackendTypeEnum = iota
)

type CryptoCore

type CryptoCore struct {
	// AES-256 block cipher. This is used for EME filename encryption.
	BlockCipher cipher.Block
	// GCM or AES-SIV. This is used for content encryption.
	AEADCipher cipher.AEAD
	// Which backend is behind AEADCipher?
	AEADBackend BackendTypeEnum
	// GCM needs unique IVs (nonces)
	IVGenerator *nonceGenerator
	IVLen       int
}

CryptoCore is the low level crypto implementation.

func New

func New(key []byte, backend BackendTypeEnum, IVBitLen int) *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 are used for encrypting the master key in gocryptfs.conf.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL