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
- func Gen() codec.Codec
- func New(toHdr, toPld *crypto.Pub, from *crypto.Prv, iv nonce.IV, depth int) ont.Onion
- type Crypt
- func (x *Crypt) Account(res *sess.Data, sm *sess.Manager, s *sessions.Data, last bool) (skip bool, sd *sessions.Data)
- func (x *Crypt) Decode(s *splice.Splice) (e error)
- func (x *Crypt) Decrypt(prk *crypto.Prv, s *splice.Splice)
- func (x *Crypt) Encode(s *splice.Splice) (e error)
- func (x *Crypt) Handle(s *splice.Splice, p ont.Onion, ng ont.Ngin) (e error)
- func (x *Crypt) Len() int
- func (x *Crypt) Magic() string
- func (x *Crypt) Unwrap() interface{}
- func (x *Crypt) Wrap(inner ont.Onion)
Constants ¶
const (
CryptMagic = "cryp"
)
Variables ¶
This section is empty.
Functions ¶
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) Decrypt ¶
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 ¶
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 ¶
Handle provides relay and accounting processing logic for receiving a Crypt message.