nacl

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNonceRead is returned when the provided reader fails to generate a nonce.
	ErrNonceRead = errors.New("failed to read nonce value")

	// ErrDecrypt is returned when opening an encrypted message fails.
	ErrDecrypt = errors.New("failed to decrypt value")
)

Functions

This section is empty.

Types

type Box

type Box interface {
	Seal(message []byte) ([]byte, error)
	Open(encrypted []byte) ([]byte, error)
	GetSecretKeySig() string
}

Box opens and seals secrets.

type MultiSecretBox

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

MultiSecretBox wraps multiple SecretBox.

func NewMultiSecretBox

func NewMultiSecretBox(boxes ...*SecretBox) *MultiSecretBox

NewMultiSecretBox creates a MultiSecretBox which wraps the provided SecretBox.

func (*MultiSecretBox) GetSecretKeySig

func (m *MultiSecretBox) GetSecretKeySig() string

GetSecretKeySig returns the md5 hash sum of the key

func (*MultiSecretBox) Open

func (m *MultiSecretBox) Open(encrypted []byte) (message []byte, err error)

Open attempts to decrypt the provided message with all available SecretBox.

func (*MultiSecretBox) Seal

func (m *MultiSecretBox) Seal(message []byte) ([]byte, error)

Seal encrypts the provided message with the first SecretBox.

type SecretBox

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

SecretBox provides nacl secretbox encryption.

func NewSecretBox

func NewSecretBox(key *[32]byte, nonceReader io.Reader) *SecretBox

NewSecretBox creates a new SecretBox with the provided secret key and optional nonce reader.

func (*SecretBox) GetSecretKeySig

func (s *SecretBox) GetSecretKeySig() string

GetSecretKeySig returns the md5 hash sum of the key

func (*SecretBox) Open

func (s *SecretBox) Open(encrypted []byte) ([]byte, error)

Open decrypts the provided message.

func (*SecretBox) Seal

func (s *SecretBox) Seal(message []byte) ([]byte, error)

Seal encrypts the provided message.

type Signer

type Signer interface {
	Sign(data []byte) []byte
	Verify(data, sum []byte) bool
}

Signer allows you to sign and verify data.

func NewMultiSigner

func NewMultiSigner(signers ...Signer) Signer

NewMultiSigner allows you to create multiple signers which is useful for doing cred rolls.

func NewSigner

func NewSigner(key *[32]byte) Signer

NewSigner creates a single signer with the given key.

Jump to

Keyboard shortcuts

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