Documentation ¶
Overview ¶
olm provides the ratchet used by the olm protocol
Index ¶
- Variables
- type Ratchet
- func (r *Ratchet) Decrypt(input []byte) ([]byte, error)
- func (r *Ratchet) Encrypt(plaintext []byte, reader io.Reader) ([]byte, error)
- func (r *Ratchet) InitializeAsAlice(sharedSecret []byte, ourRatchetKey crypto.Curve25519KeyPair) error
- func (r *Ratchet) InitializeAsBob(sharedSecret []byte, theirRatchetKey crypto.Curve25519PublicKey) error
- func (r Ratchet) PickleAsJSON(key []byte) ([]byte, error)
- func (r Ratchet) PickleLen() int
- func (r Ratchet) PickleLenMin() int
- func (r Ratchet) PickleLibOlm(target []byte) (int, error)
- func (r *Ratchet) UnpickleAsJSON(pickled, key []byte) error
- func (r *Ratchet) UnpickleLibOlm(value []byte, includesChainIndex bool) (int, error)
Constants ¶
This section is empty.
Variables ¶
var KdfInfo = struct { Root []byte Ratchet []byte }{ Root: []byte("OLM_ROOT"), Ratchet: []byte("OLM_RATCHET"), }
KdfInfo has the infos used for the kdf
var RatchetCipher = cipher.NewAESSHA256([]byte("OLM_KEYS"))
Functions ¶
This section is empty.
Types ¶
type Ratchet ¶
type Ratchet struct { // The root key is used to generate chain keys from the ephemeral keys. // A new root_key is derived each time a new chain is started. RootKey crypto.Curve25519PublicKey `json:"root_key"` // The sender chain is used to send messages. Each time a new ephemeral // key is received from the remote server we generate a new sender chain // with a new ephemeral key when we next send a message. SenderChains senderChain `json:"sender_chain"` // The receiver chain is used to decrypt received messages. We store the // last few chains so we can decrypt any out of order messages we haven't // received yet. // New chains are prepended for easier access. ReceiverChains []receiverChain `json:"receiver_chains"` // Storing the keys of missed messages for future use. // The order of the elements is not important. SkippedMessageKeys []skippedMessageKey `json:"skipped_message_keys"` }
Ratchet represents the olm ratchet as described in
https://gitlab.matrix.org/matrix-org/olm/-/blob/master/docs/olm.md
func (*Ratchet) Decrypt ¶
Decrypt decrypts the ciphertext and verifies the MAC. If reader is nil, crypto/rand is used for key generations.
func (*Ratchet) Encrypt ¶
Encrypt encrypts the message in a message.Message with MAC. If reader is nil, crypto/rand is used for key generations.
func (*Ratchet) InitializeAsAlice ¶
func (r *Ratchet) InitializeAsAlice(sharedSecret []byte, ourRatchetKey crypto.Curve25519KeyPair) error
InitializeAsAlice initializes this ratchet from a sending point of view (only first message).
func (*Ratchet) InitializeAsBob ¶
func (r *Ratchet) InitializeAsBob(sharedSecret []byte, theirRatchetKey crypto.Curve25519PublicKey) error
InitializeAsBob initializes this ratchet from a receiving point of view (only first message).
func (Ratchet) PickleAsJSON ¶
PickleAsJSON returns a ratchet as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.
func (Ratchet) PickleLen ¶
PickleLen returns the actual number of bytes the pickled ratchet will have.
func (Ratchet) PickleLenMin ¶
PickleLen returns the minimum number of bytes the pickled ratchet must have.
func (Ratchet) PickleLibOlm ¶
PickleLibOlm encodes the ratchet into target. target has to have a size of at least PickleLen() and is written to from index 0. It returns the number of bytes written.
func (*Ratchet) UnpickleAsJSON ¶
UnpickleAsJSON updates a ratchet by a base64 encrypted string using the supplied key. The unencrypted representation has to be in JSON format.