Documentation ¶
Index ¶
- type GroupMessage
- func (r *GroupMessage) Decode(input []byte) error
- func (r *GroupMessage) EncodeAndMacAndSign(macKey []byte, cipher cipher.Cipher, signKey *crypto.Ed25519KeyPair) ([]byte, error)
- func (r *GroupMessage) MAC(key []byte, cipher cipher.Cipher, message []byte) ([]byte, error)
- func (r *GroupMessage) VerifyMAC(key []byte, cipher cipher.Cipher, message, givenMAC []byte) (bool, error)
- func (r *GroupMessage) VerifyMACInline(key []byte, cipher cipher.Cipher, message []byte) (bool, error)
- func (r *GroupMessage) VerifySignature(key crypto.Ed25519PublicKey, message, givenSignature []byte) bool
- func (r *GroupMessage) VerifySignatureInline(key crypto.Ed25519PublicKey, message []byte) bool
- type MegolmSessionExport
- type MegolmSessionSharing
- type Message
- func (r *Message) Decode(input []byte) error
- func (r *Message) EncodeAndMAC(key []byte, cipher cipher.Cipher) ([]byte, error)
- func (r *Message) VerifyMAC(key []byte, cipher cipher.Cipher, message, givenMAC []byte) (bool, error)
- func (r *Message) VerifyMACInline(key []byte, cipher cipher.Cipher, message []byte) (bool, error)
- type PreKeyMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GroupMessage ¶
type GroupMessage struct { Version byte `json:"version"` MessageIndex uint32 `json:"index"` Ciphertext []byte `json:"ciphertext"` HasMessageIndex bool `json:"has_index"` }
GroupMessage represents a message in the group message format.
func (*GroupMessage) Decode ¶
func (r *GroupMessage) Decode(input []byte) error
Decodes decodes the input and populates the corresponding fileds. MAC and signature are ignored but have to be present.
func (*GroupMessage) EncodeAndMacAndSign ¶
func (r *GroupMessage) EncodeAndMacAndSign(macKey []byte, cipher cipher.Cipher, signKey *crypto.Ed25519KeyPair) ([]byte, error)
EncodeAndMacAndSign encodes the message, creates the mac with the key and the cipher and signs the message. If macKey or cipher is nil, no mac is appended. If signKey is nil, no signature is appended.
func (*GroupMessage) MAC ¶
MAC returns the MAC of the message calculated with cipher and key. The length of the MAC is truncated to the correct length.
func (*GroupMessage) VerifyMAC ¶
func (r *GroupMessage) VerifyMAC(key []byte, cipher cipher.Cipher, message, givenMAC []byte) (bool, error)
VerifyMAC verifies the givenMAC to the calculated MAC of the message.
func (*GroupMessage) VerifyMACInline ¶
func (r *GroupMessage) VerifyMACInline(key []byte, cipher cipher.Cipher, message []byte) (bool, error)
VerifyMACInline verifies the MAC taken from the message to the calculated MAC of the message.
func (*GroupMessage) VerifySignature ¶
func (r *GroupMessage) VerifySignature(key crypto.Ed25519PublicKey, message, givenSignature []byte) bool
VerifySignature verifies the givenSignature to the calculated signature of the message.
func (*GroupMessage) VerifySignatureInline ¶
func (r *GroupMessage) VerifySignatureInline(key crypto.Ed25519PublicKey, message []byte) bool
VerifySignature verifies the signature taken from the message to the calculated signature of the message.
type MegolmSessionExport ¶
type MegolmSessionExport struct { Counter uint32 `json:"counter"` RatchetData [128]byte `json:"data"` PublicKey crypto.Ed25519PublicKey `json:"public_key"` }
MegolmSessionExport represents a message in the session export format.
func (*MegolmSessionExport) Decode ¶
func (s *MegolmSessionExport) Decode(input []byte) error
Decode populates the struct with the data encoded in input.
func (MegolmSessionExport) Encode ¶
func (s MegolmSessionExport) Encode() []byte
Encode returns the encoded message in the correct format.
type MegolmSessionSharing ¶
type MegolmSessionSharing struct { Counter uint32 `json:"counter"` RatchetData [128]byte `json:"data"` PublicKey crypto.Ed25519PublicKey `json:"-"` //only used when decrypting messages }
MegolmSessionSharing represents a message in the session sharing format.
func (MegolmSessionSharing) EncodeAndSign ¶
func (s MegolmSessionSharing) EncodeAndSign(key crypto.Ed25519KeyPair) []byte
Encode returns the encoded message in the correct format with the signature by key appended.
func (*MegolmSessionSharing) VerifyAndDecode ¶
func (s *MegolmSessionSharing) VerifyAndDecode(input []byte) error
VerifyAndDecode verifies the input and populates the struct with the data encoded in input.
type Message ¶
type Message struct { Version byte `json:"version"` HasCounter bool `json:"has_counter"` Counter uint32 `json:"counter"` RatchetKey crypto.Curve25519PublicKey `json:"ratchet_key"` Ciphertext []byte `json:"ciphertext"` }
GroupMessage represents a message in the message format.
func (*Message) Decode ¶
Decodes decodes the input and populates the corresponding fileds. MAC is ignored but has to be present.
func (*Message) EncodeAndMAC ¶
EncodeAndMAC encodes the message and creates the MAC with the key and the cipher. If key or cipher is nil, no MAC is appended.
type PreKeyMessage ¶
type PreKeyMessage struct { Version byte `json:"version"` IdentityKey crypto.Curve25519PublicKey `json:"id_key"` BaseKey crypto.Curve25519PublicKey `json:"base_key"` OneTimeKey crypto.Curve25519PublicKey `json:"one_time_key"` Message []byte `json:"message"` }
func (*PreKeyMessage) CheckFields ¶
func (r *PreKeyMessage) CheckFields(theirIdentityKey *crypto.Curve25519PublicKey) bool
CheckField verifies the fields. If theirIdentityKey is nil, it is not compared to the key in the message.
func (*PreKeyMessage) Decode ¶
func (r *PreKeyMessage) Decode(input []byte) error
Decodes decodes the input and populates the corresponding fileds.
func (*PreKeyMessage) Encode ¶
func (r *PreKeyMessage) Encode() ([]byte, error)
Encode encodes the message.