snacl

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: ISC, ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Expose secretbox's Overhead const here for convenience.
	Overhead  = secretbox.Overhead
	KeySize   = 32
	NonceSize = 24
	DefaultN  = 16384 // 2^14
	DefaultR  = 8
	DefaultP  = 1
)

Various constants needed for encryption scheme.

Variables

View Source
var (
	ErrInvalidPassword = errors.New("invalid password")
	ErrMalformed       = errors.New("malformed data")
	ErrDecryptFailed   = errors.New("unable to decrypt")
)

Error types and messages.

Functions

This section is empty.

Types

type CryptoKey

type CryptoKey [KeySize]byte

func GenerateCryptoKey

func GenerateCryptoKey() (*CryptoKey, error)

GenerateCryptoKey generates a new crypotgraphically random key.

func (*CryptoKey) Decrypt

func (ck *CryptoKey) Decrypt(in []byte) ([]byte, error)

function.

func (*CryptoKey) Encrypt

func (ck *CryptoKey) Encrypt(in []byte) ([]byte, error)

Encrypt encrypts the passed data.

func (*CryptoKey) Zero

func (ck *CryptoKey) Zero()

key is no longer usable after this call.

type Parameters

type Parameters struct {
	Salt   [KeySize]byte
	Digest [sha256.Size]byte
	N      int
	R      int
	P      int
}

type SecretKey

type SecretKey struct {
	Key        *CryptoKey
	Parameters Parameters
}

func NewSecretKey

func NewSecretKey(

	password *[]byte, N, r, p int) (*SecretKey, error)

NewSecretKey returns a SecretKey structure based on the passed parameters.

func (*SecretKey) Decrypt

func (sk *SecretKey) Decrypt(in []byte) ([]byte, error)

Decrypt takes in a JSON blob and returns it's decrypted form.

func (*SecretKey) DeriveKey

func (sk *SecretKey) DeriveKey(password *[]byte) error

Zero function or on an initial Unmarshal.

func (*SecretKey) Encrypt

func (sk *SecretKey) Encrypt(in []byte) ([]byte, error)

Encrypt encrypts in bytes and returns a JSON blob.

func (*SecretKey) Marshal

func (sk *SecretKey) Marshal() []byte

storage. This result of this can be stored in clear text.

func (*SecretKey) Unmarshal

func (sk *SecretKey) Unmarshal(marshalled []byte) error

passphrase into sk.

func (*SecretKey) Zero

func (sk *SecretKey) Zero()

DeriveKey function.

Jump to

Keyboard shortcuts

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