crypto

package
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EpochSize length of epoch
	EpochSize = 4
	// MessageOffset offset for the message without overhead
	MessageOffset = EpochSize + 4
)

Variables

This section is empty.

Functions

func Signature

func Signature(value uint32) []byte

Signature signature is used in the message encryption to validate signature of the message signature is added to the destination slice

func SignatureToUint32

func SignatureToUint32(sig []byte) uint32

SignatureToUint32 returns uint32 for signature

Types

type MAC

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

MAC has the ability to encrypt and decrypt (short) messages as long as they share the same key and the same epoch.

func New

func New(key []byte) (*MAC, error)

New builds a new MAC using a 256-bit/32 byte encryption key, a numeric epoch and numeric pseudo-random salt

func (*MAC) Decrypt

func (m *MAC) Decrypt(dst, src []byte) ([]byte, error)

Decrypt decrypts src and appends to dst, returning the resulting byte slice or an error if the input cannot be authenticated.

func (*MAC) Encrypt

func (m *MAC) Encrypt(dst, src []byte) []byte

Encrypt encrypts src and appends to dst, returning the resulting byte slice

func (*MAC) Overhead

func (m *MAC) Overhead() int

Overhead returns the maximum difference between the lengths of a plaintext and its ciphertext.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL