message

package
v0.0.0-...-611f1dd Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: AGPL-3.0 Imports: 17 Imported by: 1

Documentation

Overview

Package message defines protocol messages.

Index

Constants

View Source
const (
	// CiphertextVersion is the current version of ciphertext messages.
	CiphertextVersion = 3
	// SenderKeyVersion is the current version of sender-key messages.
	SenderKeyVersion = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Ciphertext

type Ciphertext interface {
	// Type is the CiphertextType of the message.
	Type() CiphertextType
	// Bytes returns an encoding of the Ciphertext message.
	Bytes() []byte
}

Ciphertext defines a ciphertext message.

func NewPreKey

func NewPreKey(cfg PreKeyConfig) (Ciphertext, error)

func NewPreKeyFromBytes

func NewPreKeyFromBytes(bytes []byte) (Ciphertext, error)

func NewSignal

func NewSignal(cfg SignalConfig) (Ciphertext, error)

func NewSignalFromBytes

func NewSignalFromBytes(bytes []byte) (Ciphertext, error)

type CiphertextType

type CiphertextType int

CiphertextType represents a protocol message type.

const (
	WhisperType   CiphertextType = 2
	PreKeyType    CiphertextType = 3
	SenderKeyType CiphertextType = 7
	PlaintextType CiphertextType = 8
)

func (CiphertextType) String

func (i CiphertextType) String() string

type Plaintext

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

Plaintext represents a plaintext message.

func NewPlaintextFromBytes

func NewPlaintextFromBytes(bytes []byte) (*Plaintext, error)

func (*Plaintext) Bytes

func (p *Plaintext) Bytes() []byte

func (*Plaintext) Message

func (p *Plaintext) Message() []byte

func (*Plaintext) Type

func (*Plaintext) Type() CiphertextType

type PreKey

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

PreKey represents a pre-key message.

func (*PreKey) BaseKey

func (p *PreKey) BaseKey() curve.PublicKey

func (*PreKey) Bytes

func (p *PreKey) Bytes() []byte

func (*PreKey) IdentityKey

func (p *PreKey) IdentityKey() identity.Key

func (*PreKey) Message

func (p *PreKey) Message() *Signal

func (*PreKey) PreKeyID

func (p *PreKey) PreKeyID() *prekey.ID

func (*PreKey) RegistrationID

func (p *PreKey) RegistrationID() uint32

func (*PreKey) SignedPreKeyID

func (p *PreKey) SignedPreKeyID() prekey.ID

func (*PreKey) Type

func (*PreKey) Type() CiphertextType

func (*PreKey) Version

func (p *PreKey) Version() uint8

type PreKeyConfig

type PreKeyConfig struct {
	Version        uint8
	RegistrationID uint32
	PreKeyID       *prekey.ID
	SignedPreKeyID prekey.ID
	BaseKey        curve.PublicKey
	IdentityKey    identity.Key
	Message        *Signal
}

PreKeyConfig represents the configuration for a PreKey message.

type SenderKey

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

SenderKey represents a sender key message for group messaging.

func NewSenderKey

func NewSenderKey(random io.Reader, cfg SenderKeyConfig) (*SenderKey, error)

func NewSenderKeyFromBytes

func NewSenderKeyFromBytes(bytes []byte) (*SenderKey, error)

func (*SenderKey) Bytes

func (s *SenderKey) Bytes() []byte

func (*SenderKey) ChainID

func (s *SenderKey) ChainID() uint32

func (*SenderKey) DistributionID

func (s *SenderKey) DistributionID() distribution.ID

func (*SenderKey) Iteration

func (s *SenderKey) Iteration() uint32

func (*SenderKey) Message

func (s *SenderKey) Message() []byte

func (*SenderKey) Type

func (*SenderKey) Type() CiphertextType

func (*SenderKey) VerifySignature

func (s *SenderKey) VerifySignature(signatureKey curve.PublicKey) (bool, error)

VerifySignature verifies the signature is a valid signature of the messages by the public key.

func (*SenderKey) Version

func (s *SenderKey) Version() uint8

type SenderKeyConfig

type SenderKeyConfig struct {
	Version      uint8
	DistID       distribution.ID
	ChainID      uint32
	Iteration    uint32
	Ciphertext   []byte
	SignatureKey curve.PrivateKey
}

SenderKeyConfig represents the configuration for a SenderKey message.

type SenderKeyDistConfig

type SenderKeyDistConfig struct {
	Version    uint8
	DistID     distribution.ID
	ChainID    uint32
	Iteration  uint32
	ChainKey   []byte
	SigningKey curve.PublicKey
}

SenderKeyDistConfig represents the configuration for a SenderKeyDistribution message.

type SenderKeyDistribution

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

SenderKeyDistribution represents a sender key distribution message for group messaging.

func NewSenderKeyDistribution

func NewSenderKeyDistribution(cfg SenderKeyDistConfig) (*SenderKeyDistribution, error)

func NewSenderKeyDistributionFromBytes

func NewSenderKeyDistributionFromBytes(bytes []byte) (*SenderKeyDistribution, error)

func (*SenderKeyDistribution) Bytes

func (s *SenderKeyDistribution) Bytes() []byte

func (*SenderKeyDistribution) ChainID

func (s *SenderKeyDistribution) ChainID() uint32

func (*SenderKeyDistribution) ChainKey

func (s *SenderKeyDistribution) ChainKey() []byte

func (*SenderKeyDistribution) DistributionID

func (s *SenderKeyDistribution) DistributionID() distribution.ID

func (*SenderKeyDistribution) Iteration

func (s *SenderKeyDistribution) Iteration() uint32

func (*SenderKeyDistribution) SigningKey

func (s *SenderKeyDistribution) SigningKey() curve.PublicKey

func (*SenderKeyDistribution) Version

func (s *SenderKeyDistribution) Version() uint8

type Signal

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

Signal represents a typical ciphertext message.

func (*Signal) Bytes

func (s *Signal) Bytes() []byte

func (*Signal) Counter

func (s *Signal) Counter() uint32

func (*Signal) Message

func (s *Signal) Message() []byte

func (*Signal) SenderRatchetKey

func (s *Signal) SenderRatchetKey() curve.PublicKey

func (*Signal) Type

func (*Signal) Type() CiphertextType

func (*Signal) VerifyMAC

func (s *Signal) VerifyMAC(macKey []byte, senderIdentityKey, receiverIdentityKey identity.Key) (bool, error)

VerifyMAC verifies the message authentication code (MAC) sent with the signal message matches our computed MAC.

The MAC is expected to be an HMAC.

func (*Signal) Version

func (s *Signal) Version() uint8

type SignalConfig

type SignalConfig struct {
	Version             uint8
	MACKey              []byte
	SenderRatchetKey    curve.PublicKey
	PreviousCounter     uint32
	Counter             uint32
	Ciphertext          []byte
	SenderIdentityKey   identity.Key
	ReceiverIdentityKey identity.Key
}

SignalConfig represents the configuration for a Signal message.

Jump to

Keyboard shortcuts

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