Documentation ¶
Index ¶
- Variables
- type DeviceIdentity
- type ExpirationMixin
- type GobStore
- func (gs *GobStore) AddSession(senderKey id.SenderKey, session *OlmSession) error
- func (gs *GobStore) FilterTrackedUsers(users []id.UserID) []id.UserID
- func (gs *GobStore) Flush() error
- func (gs *GobStore) GetAccount() (*OlmAccount, error)
- func (gs *GobStore) GetDevices(userID id.UserID) (map[id.DeviceID]*DeviceIdentity, error)
- func (gs *GobStore) GetGroupSession(roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID) (*InboundGroupSession, error)
- func (gs *GobStore) GetLatestSession(senderKey id.SenderKey) (*OlmSession, error)
- func (gs *GobStore) GetOutboundGroupSession(roomID id.RoomID) (*OutboundGroupSession, error)
- func (gs *GobStore) GetSessions(senderKey id.SenderKey) (OlmSessionList, error)
- func (gs *GobStore) HasSession(senderKey id.SenderKey) bool
- func (gs *GobStore) PopOutboundGroupSession(roomID id.RoomID) error
- func (gs *GobStore) PutAccount(account *OlmAccount) error
- func (gs *GobStore) PutDevices(userID id.UserID, devices map[id.DeviceID]*DeviceIdentity) error
- func (gs *GobStore) PutGroupSession(roomID id.RoomID, senderKey id.SenderKey, sessionID id.SessionID, ...) error
- func (gs *GobStore) PutOutboundGroupSession(roomID id.RoomID, session *OutboundGroupSession) error
- func (gs *GobStore) ValidateMessageIndex(senderKey id.SenderKey, sessionID id.SessionID, eventID id.EventID, index uint, ...) bool
- type InboundGroupSession
- type Logger
- type MegolmEvent
- type OGSState
- type OlmAccount
- type OlmEvent
- type OlmEventKeys
- type OlmMachine
- func (mach *OlmMachine) DecryptMegolmEvent(evt *event.Event) (*event.Event, error)
- func (mach *OlmMachine) EncryptMegolmEvent(roomID id.RoomID, evtType event.Type, content event.Content) (*event.EncryptedEventContent, error)
- func (mach *OlmMachine) Fingerprint() string
- func (mach *OlmMachine) FlushStore() error
- func (mach *OlmMachine) HandleMemberEvent(evt *event.Event)
- func (mach *OlmMachine) HandleToDeviceEvent(evt *event.Event)
- func (mach *OlmMachine) Load() (err error)
- func (mach *OlmMachine) OnDevicesChanged(userID id.UserID)
- func (mach *OlmMachine) ProcessSyncResponse(resp *mautrix.RespSync, since string)
- func (mach *OlmMachine) SaveAccount()
- func (mach *OlmMachine) ShareGroupSession(roomID id.RoomID, users []id.UserID) error
- func (mach *OlmMachine) ShareKeys() error
- type OlmSession
- type OlmSessionList
- type OutboundGroupSession
- type StateStore
- type Store
- type TimeMixin
- type TrustState
- type UserDevice
Constants ¶
This section is empty.
Variables ¶
View Source
var ( IncorrectEncryptedContentType = errors.New("event content is not instance of *event.EncryptedEventContent") NoSessionFound = errors.New("failed to decrypt megolm event: no session with given ID found") DuplicateMessageIndex = errors.New("duplicate message index") WrongRoom = errors.New("encrypted megolm event is not intended for this room") )
View Source
var ( UnsupportedAlgorithm = errors.New("unsupported event encryption algorithm") NotEncryptedForMe = errors.New("olm event doesn't contain ciphertext for this device") UnsupportedOlmMessageType = errors.New("unsupported olm message type") DecryptionFailedWithMatchingSession = errors.New("decryption failed with matching session") DecryptionFailedForNormalMessage = errors.New("decryption failed for normal message") SenderMismatch = errors.New("mismatched sender in olm payload") RecipientMismatch = errors.New("mismatched recipient in olm payload") RecipientKeyMismatch = errors.New("mismatched recipient key in olm payload") )
View Source
var ( MismatchingDeviceID = errors.New("mismatching device ID in parameter and keys object") MismatchingUserID = errors.New("mismatching user ID in parameter and keys object") MismatchingSigningKey = errors.New("received update for device with different signing key") NoSigningKeyFound = errors.New("didn't find ed25519 signing key") NoIdentityKeyFound = errors.New("didn't find curve25519 identity key") InvalidKeySignature = errors.New("invalid signature on device keys") )
View Source
var ( NoGroupSession = errors.New("no group session created") )
View Source
var ( SessionExpired = errors.New("session has expired") )
Functions ¶
This section is empty.
Types ¶
type DeviceIdentity ¶
type ExpirationMixin ¶
func (*ExpirationMixin) Expired ¶
func (exp *ExpirationMixin) Expired() bool
type GobStore ¶
type GobStore struct { Account *OlmAccount Sessions map[id.SenderKey]OlmSessionList GroupSessions map[id.RoomID]map[id.SenderKey]map[id.SessionID]*InboundGroupSession OutGroupSessions map[id.RoomID]*OutboundGroupSession MessageIndices map[messageIndexKey]messageIndexValue Devices map[id.UserID]map[id.DeviceID]*DeviceIdentity // contains filtered or unexported fields }
func NewGobStore ¶
func (*GobStore) AddSession ¶
func (gs *GobStore) AddSession(senderKey id.SenderKey, session *OlmSession) error
func (*GobStore) FilterTrackedUsers ¶ added in v0.3.1
func (*GobStore) GetAccount ¶
func (gs *GobStore) GetAccount() (*OlmAccount, error)
func (*GobStore) GetDevices ¶
func (*GobStore) GetGroupSession ¶
func (*GobStore) GetLatestSession ¶
func (gs *GobStore) GetLatestSession(senderKey id.SenderKey) (*OlmSession, error)
func (*GobStore) GetOutboundGroupSession ¶
func (gs *GobStore) GetOutboundGroupSession(roomID id.RoomID) (*OutboundGroupSession, error)
func (*GobStore) GetSessions ¶
func (gs *GobStore) GetSessions(senderKey id.SenderKey) (OlmSessionList, error)
func (*GobStore) PopOutboundGroupSession ¶
func (*GobStore) PutAccount ¶
func (gs *GobStore) PutAccount(account *OlmAccount) error
func (*GobStore) PutDevices ¶
func (*GobStore) PutGroupSession ¶
func (*GobStore) PutOutboundGroupSession ¶
func (gs *GobStore) PutOutboundGroupSession(roomID id.RoomID, session *OutboundGroupSession) error
type InboundGroupSession ¶
type InboundGroupSession struct { Internal olm.InboundGroupSession SigningKey id.Ed25519 SenderKey id.Curve25519 RoomID id.RoomID ForwardingChains []string // contains filtered or unexported fields }
func NewInboundGroupSession ¶
func (*InboundGroupSession) ID ¶
func (igs *InboundGroupSession) ID() id.SessionID
type MegolmEvent ¶
type OlmAccount ¶
func NewOlmAccount ¶ added in v0.4.1
func NewOlmAccount() *OlmAccount
func (*OlmAccount) NewInboundSessionFrom ¶
func (account *OlmAccount) NewInboundSessionFrom(senderKey id.Curve25519, ciphertext string) (*OlmSession, error)
type OlmEvent ¶
type OlmEvent struct { Source *event.Event `json:"-"` SenderKey id.SenderKey `json:"-"` Sender id.UserID `json:"sender"` SenderDevice id.DeviceID `json:"sender_device"` Keys OlmEventKeys `json:"keys"` Recipient id.UserID `json:"recipient"` RecipientKeys OlmEventKeys `json:"recipient_keys"` Type event.Type `json:"type"` Content event.Content `json:"content"` }
type OlmEventKeys ¶
type OlmMachine ¶
type OlmMachine struct { Client *mautrix.Client Log Logger CryptoStore Store StateStore StateStore // contains filtered or unexported fields }
func NewOlmMachine ¶
func NewOlmMachine(client *mautrix.Client, log Logger, cryptoStore Store, stateStore StateStore) *OlmMachine
func (*OlmMachine) DecryptMegolmEvent ¶
func (*OlmMachine) EncryptMegolmEvent ¶
func (mach *OlmMachine) EncryptMegolmEvent(roomID id.RoomID, evtType event.Type, content event.Content) (*event.EncryptedEventContent, error)
func (*OlmMachine) Fingerprint ¶ added in v0.3.3
func (mach *OlmMachine) Fingerprint() string
func (*OlmMachine) FlushStore ¶
func (mach *OlmMachine) FlushStore() error
func (*OlmMachine) HandleMemberEvent ¶
func (mach *OlmMachine) HandleMemberEvent(evt *event.Event)
func (*OlmMachine) HandleToDeviceEvent ¶
func (mach *OlmMachine) HandleToDeviceEvent(evt *event.Event)
func (*OlmMachine) Load ¶
func (mach *OlmMachine) Load() (err error)
func (*OlmMachine) OnDevicesChanged ¶
func (mach *OlmMachine) OnDevicesChanged(userID id.UserID)
func (*OlmMachine) ProcessSyncResponse ¶
func (mach *OlmMachine) ProcessSyncResponse(resp *mautrix.RespSync, since string)
func (*OlmMachine) SaveAccount ¶
func (mach *OlmMachine) SaveAccount()
func (*OlmMachine) ShareGroupSession ¶
func (*OlmMachine) ShareKeys ¶
func (mach *OlmMachine) ShareKeys() error
ShareKeys returns a key upload request.
type OlmSession ¶
type OlmSession struct { Internal olm.Session ExpirationMixin // contains filtered or unexported fields }
func (*OlmSession) Decrypt ¶
func (session *OlmSession) Decrypt(ciphertext string, msgType id.OlmMsgType) ([]byte, error)
func (*OlmSession) Encrypt ¶
func (session *OlmSession) Encrypt(plaintext []byte) (id.OlmMsgType, []byte)
func (*OlmSession) ID ¶
func (session *OlmSession) ID() id.SessionID
type OlmSessionList ¶
type OlmSessionList []*OlmSession
OlmSessionList is a list of OlmSessions. It implements sort.Interface in a way that sorts items in reverse alphabetic order, which means the newest session is first.
func (OlmSessionList) Len ¶
func (o OlmSessionList) Len() int
func (OlmSessionList) Less ¶
func (o OlmSessionList) Less(i, j int) bool
func (OlmSessionList) Swap ¶
func (o OlmSessionList) Swap(i, j int)
type OutboundGroupSession ¶
type OutboundGroupSession struct { Internal olm.OutboundGroupSession ExpirationMixin MaxMessages int MessageCount int Users map[UserDevice]OGSState RoomID id.RoomID // contains filtered or unexported fields }
func NewOutboundGroupSession ¶
func NewOutboundGroupSession(roomID id.RoomID) *OutboundGroupSession
func (*OutboundGroupSession) Encrypt ¶
func (ogs *OutboundGroupSession) Encrypt(plaintext []byte) ([]byte, error)
func (*OutboundGroupSession) Expired ¶
func (ogs *OutboundGroupSession) Expired() bool
func (*OutboundGroupSession) ID ¶
func (ogs *OutboundGroupSession) ID() id.SessionID
func (*OutboundGroupSession) ShareContent ¶
func (ogs *OutboundGroupSession) ShareContent() event.Content
type StateStore ¶
type Store ¶
type Store interface { Flush() error PutAccount(*OlmAccount) error GetAccount() (*OlmAccount, error) HasSession(id.SenderKey) bool GetSessions(id.SenderKey) (OlmSessionList, error) GetLatestSession(id.SenderKey) (*OlmSession, error) AddSession(id.SenderKey, *OlmSession) error PutGroupSession(id.RoomID, id.SenderKey, id.SessionID, *InboundGroupSession) error GetGroupSession(id.RoomID, id.SenderKey, id.SessionID) (*InboundGroupSession, error) PutOutboundGroupSession(id.RoomID, *OutboundGroupSession) error GetOutboundGroupSession(id.RoomID) (*OutboundGroupSession, error) PopOutboundGroupSession(id.RoomID) error ValidateMessageIndex(senderKey id.SenderKey, sessionID id.SessionID, eventID id.EventID, index uint, timestamp int64) bool GetDevices(id.UserID) (map[id.DeviceID]*DeviceIdentity, error) PutDevices(id.UserID, map[id.DeviceID]*DeviceIdentity) error FilterTrackedUsers([]id.UserID) []id.UserID }
type TrustState ¶
type TrustState int
const ( TrustStateUnset TrustState = iota TrustStateVerified TrustStateBlacklisted TrustStateIgnored )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.