Documentation ¶
Overview ¶
Package mixcrypt implements the client-mix-client message encryption.
Index ¶
- Constants
- Variables
- func CalculateSharedSecret(peerPublicKey, myPrivateKey, nonceIn *[KeySize]byte) (secret, nonceOut *[KeySize]byte)
- func Decrypt(lookupKey KeyFunc, encryptedData []byte) ([]byte, error)
- func Encrypt(peerPublicKey, myPrivateKey *[KeySize]byte, cleartextData []byte) ([]byte, error)
- func ExpandSecret(nonce, key []byte) *[KeySize]byte
- func GCMDecrypt(nonce, key, encryptedData []byte) ([]byte, error)
- func GCMEncrypt(nonce, key, cleartextData []byte) ([]byte, error)
- func ReceiveFromMix(receiveTemplate nymaddr.AddressTemplate, MailboxAddress, msg []byte) (decMessage, Nym []byte, err error)
- type ClientMixHeader
- func (cl ClientMixHeader) Marshal() []byte
- func (cl *ClientMixHeader) NewForwardMessage(NextHop string, NextHopKey *[KeySize]byte, msg []byte) (message []byte, deliverAddress string, err error)
- func (cl *ClientMixHeader) NewRelayMessage(NymAddress []byte, msg []byte) (message []byte, deliverAddress string, err error)
- func (cl *ClientMixHeader) Unmarshal(d []byte) (header *ClientMixHeader, headerlen uint16, err error)
- type KeyFunc
- type ReceiveStruct
- type UniquenessData
Constants ¶
const ( // MessageTypeForward is a message that is forwarded to another mix MessageTypeForward = 1 + iota // MessageTypeRelay is a message that is relayed to a recipient MessageTypeRelay )
const KeySize = 32
KeySize is the size of a public/private key.
Variables ¶
var ( // ExpireReceive is the expiration time for incoming header uniqueness checks ExpireReceive = int64(172800) // ForwardMinSize is the minimum size of a forward message ForwardMinSize = 1024 // ForwardMaxSize is the maximum size of a forward message ForwardMaxSize = 65536 // RelayMinSize is the minimum size of a relay message RelayMinSize = 4096 // RelayMaxSize is the maximum size of a relay message RelayMaxSize = 65536 )
var ( // ErrNoKeys is returned if not enough keys are known ErrNoKeys = errors.New("mixcrypt: keys missing") // ErrTooShort is returned if a message is too short ErrTooShort = errors.New("mixcrypt: too short") // ErrSize is returned if a message is too long/short ErrSize = errors.New("mixcrypt: message out of bounds") // ErrBadSystem is returned if a message for a wrong system was received ErrBadSystem = errors.New("mixcrypt: bad system") )
var MuteSystemDomain = "mute.one"
MuteSystemDomain is the domain of the Mute System.
var Rand = rand.Reader
Rand is the random source of this package.
Functions ¶
func CalculateSharedSecret ¶
func CalculateSharedSecret(peerPublicKey, myPrivateKey, nonceIn *[KeySize]byte) (secret, nonceOut *[KeySize]byte)
CalculateSharedSecret calculates a shared secret from the given parameters. If myPrivateKey is nil, it will return only nils. If Nonce is nil, a nonce will be created
func ExpandSecret ¶
ExpandSecret expands a nonce/key for multi-use encryption (unique nonces, constant keys)
func GCMDecrypt ¶
GCMDecrypt data with AES-GCM
func GCMEncrypt ¶
GCMEncrypt data with AES-GCM
func ReceiveFromMix ¶
func ReceiveFromMix(receiveTemplate nymaddr.AddressTemplate, MailboxAddress, msg []byte) (decMessage, Nym []byte, err error)
ReceiveFromMix decrypts a message received from the mix
Types ¶
type ClientMixHeader ¶
type ClientMixHeader struct { MessageType int32 // The type of the message (forward/relay). Forward does not have NymAddress/RevokeID set SenderMinDelay, SenderMaxDelay int32 Token []byte // Payment Token Address []byte // NymAddress for relay, next mix for forward RevokeID []byte // Revokation secret }
ClientMixHeader contains fields meant by the Client for the Mix
func (ClientMixHeader) Marshal ¶
func (cl ClientMixHeader) Marshal() []byte
Marshal a ClientMixHeader
func (*ClientMixHeader) NewForwardMessage ¶
func (cl *ClientMixHeader) NewForwardMessage(NextHop string, NextHopKey *[KeySize]byte, msg []byte) (message []byte, deliverAddress string, err error)
NewForwardMessage creates a new message with type MessageTypeForward. Uses ClientMixHeader SenderMinDelay,SenderMaxDelay,Token
func (*ClientMixHeader) NewRelayMessage ¶
func (cl *ClientMixHeader) NewRelayMessage(NymAddress []byte, msg []byte) (message []byte, deliverAddress string, err error)
NewRelayMessage creates a new message with type MessageTypeRelay. Uses ClientMixHeader SenderMinDelay,SenderMaxDelay,Token. Sets revokeID
func (*ClientMixHeader) Unmarshal ¶
func (cl *ClientMixHeader) Unmarshal(d []byte) (header *ClientMixHeader, headerlen uint16, err error)
Unmarshal a binary ClientMixHeader. Returns header length to allow working with full-message slices
type ReceiveStruct ¶
type ReceiveStruct struct { MixHeader *ClientMixHeader NymAddress *nymaddr.Address NymAddressPrivate *nymaddr.AddressPrivate UniqueTest []UniquenessData Message []byte }
ReceiveStruct contains data gathered from receiving a message
func ReceiveMessage ¶
func ReceiveMessage(lookupKey KeyFunc, message []byte) (*ReceiveStruct, error)
ReceiveMessage receives a Client-Mix message
type UniquenessData ¶
UniquenessData contains the hash and expire time for a uniqueness-check