Documentation ¶
Overview ¶
session provides the different types of sessions for en/decrypting of messages
Index ¶
- type MegolmInboundSession
- func (o *MegolmInboundSession) Decrypt(ciphertext []byte) ([]byte, error)
- func (o *MegolmInboundSession) ExportMessage() ([]byte, error)
- func (o *MegolmInboundSession) Pickle(key []byte) ([]byte, error)
- func (o *MegolmInboundSession) SessionID() []byte
- func (o *MegolmInboundSession) Unpickle(pickled, key []byte) error
- type MegolmOutboundSession
- type OlmSession
- func NewInboundOlmSession(identityKeyAlice crypto.Curve25519PublicKey, receivedOTKMsg []byte, ...) (*OlmSession, error)
- func NewOlmSession() *OlmSession
- func NewOutboundOlmSession(identityKeyAlice crypto.Curve25519KeyPair, ...) (*OlmSession, error)
- func OlmSessionFromPickled(pickled, key []byte) (*OlmSession, error)
- func (s *OlmSession) Decrypt(crypttext []byte, msgType id.OlmMsgType) ([]byte, error)
- func (s *OlmSession) Encrypt(plaintext []byte) (id.OlmMsgType, []byte, error)
- func (s *OlmSession) EncryptMsgType() id.OlmMsgType
- func (s *OlmSession) HasReceivedMessage() bool
- func (s *OlmSession) ID() id.SessionID
- func (s *OlmSession) MatchesInboundSession(theirIdentityKey, oneTimeKeyMsg []byte) (bool, error)
- func (a *OlmSession) Pickle(key []byte) ([]byte, error)
- func (a *OlmSession) Unpickle(pickled, key []byte) error
- type SearchOTKFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MegolmInboundSession ¶
type MegolmInboundSession struct { Ratchet *megolm.Ratchet `json:"ratchet"` SigningKey crypto.Ed25519PublicKey `json:"signingKey"` InitialRatchet *megolm.Ratchet `json:"initalRatchet"` SigningKeyVerified bool `json:"signingKeyVerified"` //not used for now }
MegolmInboundSession stores information about the sessions of receive.
func NewMegolmInboundSession ¶
func NewMegolmInboundSession(input []byte) (*MegolmInboundSession, error)
NewMegolmInboundSession creates a new MegolmInboundSession from a base64 encoded session sharing message.
func NewMegolmInboundSessionFromExport ¶
func NewMegolmInboundSessionFromExport(input []byte) (*MegolmInboundSession, error)
NewMegolmInboundSessionFromExport creates a new MegolmInboundSession from a base64 encoded session export message.
func (*MegolmInboundSession) Decrypt ¶
func (o *MegolmInboundSession) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt decrypts a base64 encoded group message.
func (*MegolmInboundSession) ExportMessage ¶
func (o *MegolmInboundSession) ExportMessage() ([]byte, error)
ExportMessage creates an base64 encoded export of the session.
func (*MegolmInboundSession) Pickle ¶
func (o *MegolmInboundSession) Pickle(key []byte) ([]byte, error)
Pickle returns an MegolmInboundSession as a base64 string encrypted using the supplied key.
func (*MegolmInboundSession) SessionID ¶
func (o *MegolmInboundSession) SessionID() []byte
SessionID returns the base64 endoded signing key
func (*MegolmInboundSession) Unpickle ¶
func (o *MegolmInboundSession) Unpickle(pickled, key []byte) error
Unpickle updates an MegolmInboundSession by a base64 encrypted string with the key.
type MegolmOutboundSession ¶
type MegolmOutboundSession struct { Ratchet *megolm.Ratchet `json:"ratchet"` SigningKey *crypto.Ed25519KeyPair `json:"signingKey"` }
MegolmOutboundSession stores information about the sessions to send.
func NewMegolmOutboundSession ¶
func NewMegolmOutboundSession() (*MegolmOutboundSession, error)
NewMegolmOutboundSession creates a new MegolmOutboundSession.
func (*MegolmOutboundSession) Encrypt ¶
func (o *MegolmOutboundSession) Encrypt(plaintext []byte) ([]byte, error)
Encrypt encrypts the plaintext as a base64 encoded group message.
func (*MegolmOutboundSession) Pickle ¶
func (a *MegolmOutboundSession) Pickle(key []byte) ([]byte, error)
Pickle returns an MegolmOutboundSession as a base64 string encrypted using the supplied key.
func (*MegolmOutboundSession) SessionID ¶
func (o *MegolmOutboundSession) SessionID() []byte
SessionID returns the base64 endoded public signing key
func (*MegolmOutboundSession) Unpickle ¶
func (a *MegolmOutboundSession) Unpickle(pickled, key []byte) error
Unpickle updates an MegolmOutboundSession by a base64 encrypted string with the key
type OlmSession ¶
type OlmSession struct { RecievedMessage bool `json:"recievedMessage"` AliceIdKey crypto.Curve25519PublicKey `json:"aliceIdKey"` AliceBaseKey crypto.Curve25519PublicKey `json:"aliceBaseKey"` BobOneTimeKey crypto.Curve25519PublicKey `json:"bobOnTimeKey"` Ratchet *olm.Ratchet `json:"ratchet"` }
OlmSession stores all information for an olm session
func NewInboundOlmSession ¶
func NewInboundOlmSession(identityKeyAlice crypto.Curve25519PublicKey, receivedOTKMsg []byte, searchBobOTK SearchOTKFunc, identityKeyBob crypto.Curve25519KeyPair) (*OlmSession, error)
NewInboundOlmSession creates a new inbound session from receiving the first message.
func NewOutboundOlmSession ¶
func NewOutboundOlmSession(identityKeyAlice crypto.Curve25519KeyPair, identityKeyBob crypto.Curve25519PublicKey, oneTimeKeyBob crypto.Curve25519PublicKey) (*OlmSession, error)
NewOutboundSession creates a new outbound session for sending the first message to a given curve25519 identityKey and oneTimeKey.
func OlmSessionFromPickled ¶
func OlmSessionFromPickled(pickled, key []byte) (*OlmSession, error)
OlmSessionFromPickled loads an OlmSession from a pickled base64 string. Decrypts the Session using the supplied key.
func (*OlmSession) Decrypt ¶
func (s *OlmSession) Decrypt(crypttext []byte, msgType id.OlmMsgType) ([]byte, error)
Decrypt decrypts a base64 encoded message using the Session.
func (*OlmSession) Encrypt ¶
func (s *OlmSession) Encrypt(plaintext []byte) (id.OlmMsgType, []byte, error)
Encrypt encrypts a message using the Session. Returns the encrypted message base64 encoded.
func (*OlmSession) EncryptMsgType ¶
func (s *OlmSession) EncryptMsgType() id.OlmMsgType
EncryptMsgType returns the type of the next message that Encrypt will return. Returns MsgTypePreKey if the message will be a oneTimeKeyMsg. Returns MsgTypeMsg if the message will be a normal message.
func (*OlmSession) HasReceivedMessage ¶
func (s *OlmSession) HasReceivedMessage() bool
HasReceivedMessage returns true if this session has received any message.
func (*OlmSession) ID ¶
func (s *OlmSession) ID() id.SessionID
ID returns an identifier for this Session. Will be the same for both ends of the conversation. Generated by hashing the public keys used to create the session.
func (*OlmSession) MatchesInboundSession ¶
func (s *OlmSession) MatchesInboundSession(theirIdentityKey, oneTimeKeyMsg []byte) (bool, error)
MatchesInboundSession checks if the oneTimeKeyMsg message is set for this inbound Session. This can happen if multiple messages are sent to this Account before this Account sends a message in reply. Returns true if the session matches. Returns false if the session does not match.
func (*OlmSession) Pickle ¶
func (a *OlmSession) Pickle(key []byte) ([]byte, error)
Pickle returns an Session as a base64 string encrypted using the supplied key.
func (*OlmSession) Unpickle ¶
func (a *OlmSession) Unpickle(pickled, key []byte) error
Unpickle updates an Session by a base64 encrypted string with the key.
type SearchOTKFunc ¶
type SearchOTKFunc = func(crypto.Curve25519PublicKey) *crypto.OneTimeKey
used to retrieve a crypto.OneTimeKey from a public key.