crypt

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Unlicense Imports: 16 Imported by: 0

Documentation

Overview

Package crypt is an onion message layer which specifies that subsequent content will be encrypted.

The cloaked receiver key, and the ephemeral per-message/per-packet "from" keys are intended to be single use only (generated via scalar multiplication with pairs of secrets).

todo: note reference of this algorithm.

Index

Constants

View Source
const (
	CryptMagic = "cryp"
)

Variables

This section is empty.

Functions

func Gen

func Gen() codec.Codec

Gen is a factory function to generate an Crypt.

func New

func New(toHdr, toPld *crypto.Pub, from *crypto.Prv, iv nonce.IV,
	depth int) ont.Onion

New creates a new crypt message with an empty slot for more messages.

Types

type Crypt

type Crypt struct {

	// Depth is used with RoutingHeaders to indicate which of the 3 layers in a
	// ReverseCrypt section.
	Depth int

	// ToHeaderPub, ToPayloadPub are the public keys of the session.
	ToHeaderPub, ToPayloadPub *crypto.Pub

	// From is usually a one-time generated private key for which the public
	// counterpart combined with the recipient's private key generates the same
	// secret via ECDH.
	From *crypto.Prv

	// IV is the Initialization Vector for the AES-CTR encryption used in a Crypt.
	IV nonce.IV

	// Cloak is the obfuscated receiver key.
	Cloak crypto.CloakedPubKey

	// ToPriv is the private key the receiver knows.
	ToPriv *crypto.Prv

	// FromPub is the public key encoded into the Crypt header.
	FromPub *crypto.Pub

	// Onion contains the rest of the message.
	ont.Onion
}

Crypt is an encrypted message, and forms the "skins" of the onions.

func (*Crypt) Account

func (x *Crypt) Account(res *sess.Data, sm *sess.Manager, s *sessions.Data,
	last bool) (skip bool, sd *sessions.Data)

Account attaches the session, which is tied to the keys used in the crypt, to the pending result.

func (*Crypt) Decode

func (x *Crypt) Decode(s *splice.Splice) (e error)

Decode a splice.Splice's next bytes into a Crypt.

func (*Crypt) Decrypt

func (x *Crypt) Decrypt(prk *crypto.Prv, s *splice.Splice)

Decrypt requires the prv.Pub to be located from the Cloak, using the FromPub key to derive the shared secret, and then decrypts the rest of the message.

func (*Crypt) Encode

func (x *Crypt) Encode(s *splice.Splice) (e error)

Encode a Crypt into a splice.Splice's next bytes.

The crypt renders the inner contents first and once complete returns and encrypts everything after the Crypt header.

func (*Crypt) Handle

func (x *Crypt) Handle(s *splice.Splice, p ont.Onion, ng ont.Ngin) (e error)

Handle provides relay and accounting processing logic for receiving a Crypt message.

func (*Crypt) Len

func (x *Crypt) Len() int

Len returns the length of bytes required to encode the Crypt.

func (*Crypt) Magic

func (x *Crypt) Magic() string

Magic bytes that identify this message

func (*Crypt) Unwrap

func (x *Crypt) Unwrap() interface{}

Unwrap returns the layers inside the crypt..

func (*Crypt) Wrap

func (x *Crypt) Wrap(inner ont.Onion)

Wrap inserts an onion inside a Crypt.

Jump to

Keyboard shortcuts

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