box2

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeySize = 256 / 8

	MaxSlots = 32
)

Variables

View Source
var (
	ErrTooManyRecipients = stderr.New("box2: too many recipients")
	ErrCouldNotDecrypt   = stderr.New("box2: could not decrypt")
	ErrInvalid           = stderr.New("box2: message is invalid")
	ErrEmptyPlaintext    = stderr.New("box2: won't encrypt empty plaintext")
	ErrInvalidOffset     = stderr.New("box2: precalculated body offset does not match real body offset")
)

API and processing errors

Functions

func DeriveTo

func DeriveTo(out, key []byte, infos ...[]byte) error

func GetCiphertextFromMessage

func GetCiphertextFromMessage(m refs.Message) ([]byte, error)

Types

type Boxer

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

func NewBoxer

func NewBoxer(rand io.Reader) *Boxer

func (*Boxer) Decrypt

func (bxr *Boxer) Decrypt(ctxt []byte, author refs.FeedRef, prev refs.MessageRef, candidates []keys.Recipient) ([]byte, error)

Decrypt takes the ciphertext, it's auther and the previous hash of the message and some canddiates to try to decrypt with. It returns the decrypted cleartext or an error.

func (*Boxer) Encrypt

func (bxr *Boxer) Encrypt(plain []byte, author refs.FeedRef, prev refs.MessageRef, recpts []keys.Recipient) ([]byte, error)

Encrypt takes a buffer to write into (out), the plaintext to encrypt, the (author) of the message, her (prev)ious message hash and a list of recipients (recpts). If out is too small to hold the full message, additonal allocations will be made. The ciphertext is returned as the first return value.

func (*Boxer) GetReadKey

func (bxr *Boxer) GetReadKey(ctxt []byte, author refs.FeedRef, prev refs.MessageRef, candidates []keys.Recipient) ([]byte, error)

type Message

type Message struct {
	Raw []byte

	HeaderBox   []byte
	AfterHeader []byte

	OffBody  int
	RawSlots []byte
	BodyBox  []byte
}

Jump to

Keyboard shortcuts

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