Documentation
¶
Index ¶
Constants ¶
const (
// Extension is the number of bytes a plaintext is enlarged by encrypting it.
Extension = ivSize + macSize
)
Variables ¶
var DefaultKDFParams = Params{ N: sscrypt.DefaultParams.N, R: sscrypt.DefaultParams.R, P: sscrypt.DefaultParams.P, }
DefaultKDFParams are the default parameters used for Calibrate and KDF().
var ( // ErrUnauthenticated is returned when ciphertext verification has failed. ErrUnauthenticated = fmt.Errorf("ciphertext verification failed") )
Functions ¶
func CiphertextLength ¶
CiphertextLength returns the encrypted length of a blob with plaintextSize bytes.
func NewBlobBuffer ¶
NewBlobBuffer returns a buffer that is large enough to hold a blob of size plaintext bytes, including the crypto overhead.
func NewRandomNonce ¶
func NewRandomNonce() []byte
NewRandomNonce returns a new random nonce. It panics on error so that the program is safely terminated.
func NewSalt ¶
NewSalt returns new random salt bytes to use with KDF(). If NewSalt returns an error, this is a grave situation and the program must abort and terminate.
func PlaintextLength ¶
PlaintextLength returns the plaintext length of a blob with ciphertextSize bytes.
Types ¶
type EncryptionKey ¶
type EncryptionKey [32]byte
EncryptionKey is key used for encryption
func (*EncryptionKey) Valid ¶
func (k *EncryptionKey) Valid() bool
Valid tests whether the key k is valid (i.e. not zero).
type Key ¶
type Key struct { MACKey `json:"mac"` EncryptionKey `json:"encrypt"` }
func KDF ¶
KDF derives encryption and message authentication keys from the password using the supplied parameters N, R and P and the Salt.
func NewRandomKey ¶
func NewRandomKey() *Key
NewRandomKey returns new encryption and message authentication keys.