msg

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Overview

Package msg defines messages in Mute. Specification: https://github.com/mutecomm/mute/blob/master/doc/messages.md

Index

Constants

View Source
const (
	StatusOK    = 0
	StatusReset = 1
	StatusError = 2
)

Possible header status codes.

View Source
const AverageSessionSize = 1000

AverageSessionSize defines the average session size. That is, the number of keys used in a session before a new session is started. For every encrypted message there is the probability of 1/AverageSessionSize that it starts a new session.

View Source
const DefaultCiphersuite = "CURVE25519 XSALSA20 POLY1305"

DefaultCiphersuite is the default ciphersuite used for Mute messages.

View Source
const EncodedMsgSize = 65536 // 64KB

EncodedMsgSize is the size of a base64 encoded encrypted message.

View Source
const MaxContentLength = UnencodedMsgSize - preHeaderSize - encryptedHeaderSize -
	cryptoSetupSize - encryptedPacketSize - signatureSize - innerHeaderSize -

	hmacSize // 41691

MaxContentLength is the maximum length the content of a message can have.

View Source
const NumOfFutureKeys = 50

NumOfFutureKeys defines the default number of future message keys which are precomputed.

View Source
const SendTime = 172800 // 48h

SendTime defines how long key material can be used for sending.

View Source
const UnencodedMsgSize = EncodedMsgSize / 4 * 3 // 49152

UnencodedMsgSize is the size of unencoded encrypted message.

View Source
const Version = 1

Version is the current version number of Mute messages.

Variables

View Source
var CleanupTime uint64

CleanupTime defines the time how long key material should be retained. Initialized via def.InitMute().

View Source
var ErrHMACsDiffer = errors.New("msg: HMACs differ")

ErrHMACsDiffer is raised when the HMACs differ.

View Source
var ErrInvalidSignature = errors.New("msg: signature invalid")

ErrInvalidSignature is raised when a signature verification failed.

View Source
var ErrNoPreHeaderKey = errors.New("msg: could not find key to decrypt pre-header")

ErrNoPreHeaderKey is raised when the key to decrypt the pre-header could not be found.

View Source
var ErrNotCryptoSetup = errors.New("msg: message doesn't have crypto setup header")

ErrNotCryptoSetup is raised when a message doesn't has a crypto setup header after the encrypted header.

View Source
var ErrNotData = errors.New("msg: expected inner data header")

ErrNotData is raised when an inner data header was expected.

View Source
var ErrNotEncryptedHeader = errors.New("msg: message doesn't have encrypted header")

ErrNotEncryptedHeader is raised when a message doesn't has an encrypted header after the pre-header.

View Source
var ErrNotEncryptedPacket = errors.New("msg: expected encrypted packet")

ErrNotEncryptedPacket is raised when an encrypted packet was expected.

View Source
var ErrNotHMACPacket = errors.New("msg: expected HMAC packet")

ErrNotHMACPacket is raised when an HMAC packet was expected.

View Source
var ErrNotPaddingPacket = errors.New("msg: expected padding packet")

ErrNotPaddingPacket is raised when a padding packet was expected.

View Source
var ErrNotPreHeader = errors.New("msg: message doesn't start with pre-header")

ErrNotPreHeader is raised when a message doesn't start with a pre-header.

View Source
var ErrNotSignaturePacket = errors.New("msg: expected signature packet")

ErrNotSignaturePacket is raised when a signature packet was expected.

View Source
var ErrReflection = errors.New("msg: reflection attack detected")

ErrReflection is raised when a possible reflection attack has been detected.

View Source
var ErrStatusError = errors.New("msg: StatusCode == StatusError")

ErrStatusError is raised when a decryption operation lead to a StatusCode StatusError.

View Source
var ErrWrongCount = errors.New("msg: wrong outer header count")

ErrWrongCount is raised when an outer header count is wrong.

View Source
var ErrWrongCryptoSetup = errors.New("msg: crypto setup header has the wrong length")

ErrWrongCryptoSetup is raised when a crypto setup header has the wrong length.

View Source
var ErrWrongSignatureLength = errors.New("msg: wrong signature length")

ErrWrongSignatureLength is raised when a signature has the wrong length.

Functions

func Decrypt

func Decrypt(args *DecryptArgs) (senderID, sig string, err error)

Decrypt decrypts a message with the argument given in args. The senderID is returned. If the message was signed and the signature could be verified successfully the base64 encoded signature is returned. If the message was signed and the signature could not be verfied an error is returned.

func Encrypt

func Encrypt(args *EncryptArgs) (nymAddress string, err error)

Encrypt encrypts a message with the argument given in args and returns the nymAddress the message should be delivered to.

func ReadFirstOuterHeader

func ReadFirstOuterHeader(r io.Reader) (version uint16, preHeader []byte, err error)

ReadFirstOuterHeader reads the first outer header from the base64 decoder r and returns the version and the preHeader for further processing. This function is intended to be used outside the msg package to allow to check for incompatible message format changes down the line.

Types

type DecryptArgs

type DecryptArgs struct {
	Writer     io.Writer      // decrypted message is written here
	Identities []*uid.Message // list of recipient UID messages
	PreHeader  []byte         // preHeader read with ReadFirstOuterHeader()
	Reader     io.Reader      // data to decrypt is read here (not base64 encoded)
	NumOfKeys  uint64         // number of generated sessions keys (default: NumOfFutureKeys)
	Rand       io.Reader      // random source
	KeyStore   session.Store  // for managing session keys
}

DecryptArgs contains all arguments for a message decryption.

type EncryptArgs

type EncryptArgs struct {
	Writer                 io.Writer     // encrypted messagte is written here (base64 encoded)
	From                   *uid.Message  // sender UID
	To                     *uid.Message  // recipient UID
	NymAddress             string        // address to receive future messages at
	SenderLastKeychainHash string        // last hash chain entry known to the sender
	PrivateSigKey          *[64]byte     // if this is s not nil the message is signed with the key
	Reader                 io.Reader     // data to encrypt is read here (only for StatusCode == StatusOK)
	NumOfKeys              uint64        // number of generated sessions keys (default: NumOfFutureKeys)
	AvgSessionSize         uint          // average session size (default: AverageSessionSize)
	Rand                   io.Reader     // random source
	KeyStore               session.Store // for managing session keys
	StatusCode             StatusCode    // status code of the encrypted message
}

EncryptArgs contains all arguments for a message encryption.

type StatusCode

type StatusCode uint8

StatusCode is the type of header status codes.

Directories

Path Synopsis
Package mime implements the MIME encoding used for messages in Mute.
Package mime implements the MIME encoding used for messages in Mute.
Package msgid contains helper functions for message ID generation and parsing.
Package msgid contains helper functions for message ID generation and parsing.
Package padding contains helper functions to generate cheap paddings.
Package padding contains helper functions to generate cheap paddings.
Package session defines session states and session stores in Mute.
Package session defines session states and session stores in Mute.
memstore
Package memstore implements a key store in memory (for testing purposes).
Package memstore implements a key store in memory (for testing purposes).

Jump to

Keyboard shortcuts

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