lcrypt

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package lcrypt provides crypto operations for lyra

Package lcrypt provides crypto operations for lyra

Index

Constants

View Source
const Iterations uint32 = 4

Iterations uint32 number of times argon2 is to be run with args

View Source
const KeyLen uint32 = 32

KeyLen uint32 the size of the key to be generated

View Source
const Memory uint32 = 64 * 1024

Memory uint32 size of memory cost

View Source
const NonceSize = 12

NonceSize defines size of nonce in bytes, NIST specifies for GCM, a nonce size of 12 bytes or 96 bits.

View Source
const SaltSize uint16 = 16

SaltSize uint8 is the salt length

View Source
const Threads uint8 = 4

Threads uint8 the number of threads to be adjusted

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(ciphertxt, nonce, key []byte) ([]byte, error)

AesDecrypt decrypts and authenticates a ciphertxt, all values must be decoded into raw values and can not be in string hex representation.

func AesEncrypt

func AesEncrypt(plain, nonce, key []byte) ([]byte, error)

AesEncrypt encrypts and authenticates a plaintext via the AES encryption scheme in GCM, all values must be in decoded into raw values and can not be in string representation.

func GenKey

func GenKey(pass []byte, salt []byte) []byte

GenKey generates a cipher key from pass. Key is generated via argon2id with parameters specified via Iterations, Memory, Threads and KeyLen

func GenNonce

func GenNonce(dst []byte) ([]byte, error)

GenNonce generates a nonce via a cryptographicaly secure number generator to dst or if dst is nil returns a nonce of size NonceSize.

func GenSalt

func GenSalt() ([]byte, error)

GenSalt generates a random salt of SaltSize

Types

type KeyManager

type KeyManager interface {

	//DestroyKey safely destroys a key that has been stored in memory.
	DestroyKey() error

	//GetKey gets a key
	GetKey() []byte
	// contains filtered or unexported methods
}

KeyManager implements encryption Key management

type LKey

type LKey struct {
	// contains filtered or unexported fields
}

LKey represents an immutable encryption key. This key is protected from unintended swap, buffer overflows and underflows. However the most important is that it can be securely destroyed.

func NewLKey

func NewLKey(passphrase, salt []byte) (*LKey, error)

NewLKey returns a new encryption key init to passphrase and salt, if no salt is specified, a new salt will be generated for the new key.

func (*LKey) DestroyKey

func (k *LKey) DestroyKey() error

DestroyKey safely destroy the encryption from memory,

func (*LKey) GetKey

func (k *LKey) GetKey() []byte

GetKey returns a reference to the key.

func (*LKey) GetSalt

func (k *LKey) GetSalt() []byte

GetSalt returns a reference to the salt of the key.

Jump to

Keyboard shortcuts

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