Documentation ¶
Overview ¶
session provides the different types of sessions for en/decrypting of messages
Index ¶
- type MegolmInboundSession
- func (o *MegolmInboundSession) Decrypt(ciphertext []byte) ([]byte, uint32, error)
- func (o MegolmInboundSession) Pickle(key []byte) ([]byte, error)
- func (o MegolmInboundSession) PickleAsJSON(key []byte) ([]byte, error)
- func (o MegolmInboundSession) PickleLen() int
- func (o MegolmInboundSession) PickleLibOlm(target []byte) (int, error)
- func (o MegolmInboundSession) SessionExportMessage(messageIndex uint32) ([]byte, error)
- func (o MegolmInboundSession) SessionID() id.SessionID
- func (o *MegolmInboundSession) Unpickle(pickled, key []byte) error
- func (o *MegolmInboundSession) UnpickleAsJSON(pickled, key []byte) error
- func (o *MegolmInboundSession) UnpickleLibOlm(value []byte) (int, error)
- type MegolmOutboundSession
- func (o *MegolmOutboundSession) Encrypt(plaintext []byte) ([]byte, error)
- func (o MegolmOutboundSession) Pickle(key []byte) ([]byte, error)
- func (o MegolmOutboundSession) PickleAsJSON(key []byte) ([]byte, error)
- func (o MegolmOutboundSession) PickleLen() int
- func (o MegolmOutboundSession) PickleLibOlm(target []byte) (int, error)
- func (o MegolmOutboundSession) SessionID() id.SessionID
- func (o MegolmOutboundSession) SessionSharingMessage() ([]byte, error)
- func (o *MegolmOutboundSession) Unpickle(pickled, key []byte) error
- func (o *MegolmOutboundSession) UnpickleAsJSON(pickled, key []byte) error
- func (o *MegolmOutboundSession) UnpickleLibOlm(value []byte) (int, error)
- type OlmSession
- func NewInboundOlmSession(identityKeyAlice *crypto.Curve25519PublicKey, receivedOTKMsg []byte, ...) (*OlmSession, error)
- func NewOlmSession() *OlmSession
- func NewOutboundOlmSession(identityKeyAlice crypto.Curve25519KeyPair, ...) (*OlmSession, error)
- func OlmSessionFromJSONPickled(pickled, key []byte) (*OlmSession, error)
- func OlmSessionFromPickled(pickled, key []byte) (*OlmSession, error)
- func (s *OlmSession) Decrypt(crypttext []byte, msgType id.OlmMsgType) ([]byte, error)
- func (o OlmSession) Describe() string
- func (s *OlmSession) Encrypt(plaintext []byte, reader io.Reader) (id.OlmMsgType, []byte, error)
- func (s OlmSession) EncryptMsgType() id.OlmMsgType
- func (s OlmSession) HasReceivedMessage() bool
- func (s OlmSession) ID() id.SessionID
- func (s OlmSession) MatchesInboundSessionFrom(theirIdentityKeyEncoded *id.Curve25519, receivedOTKMsg []byte) (bool, error)
- func (o OlmSession) Pickle(key []byte) ([]byte, error)
- func (a OlmSession) PickleAsJSON(key []byte) ([]byte, error)
- func (o OlmSession) PickleLen() int
- func (o OlmSession) PickleLenMin() int
- func (o OlmSession) PickleLibOlm(target []byte) (int, error)
- func (o *OlmSession) Unpickle(pickled, key []byte) error
- func (a *OlmSession) UnpickleAsJSON(pickled, key []byte) error
- func (o *OlmSession) UnpickleLibOlm(value []byte) (int, 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 MegolmInboundSessionFromPickled ¶ added in v0.2.0
func MegolmInboundSessionFromPickled(pickled, key []byte) (*MegolmInboundSession, error)
MegolmInboundSessionFromPickled loads the MegolmInboundSession details from a pickled base64 string. The input is decrypted with the supplied key.
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, uint32, error)
Decrypt decrypts a base64 encoded group message.
func (MegolmInboundSession) Pickle ¶
func (o MegolmInboundSession) Pickle(key []byte) ([]byte, error)
Pickle returns a base64 encoded and with key encrypted pickled MegolmInboundSession using PickleLibOlm().
func (MegolmInboundSession) PickleAsJSON ¶ added in v0.2.0
func (o MegolmInboundSession) PickleAsJSON(key []byte) ([]byte, error)
PickleAsJSON returns an MegolmInboundSession as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.
func (MegolmInboundSession) PickleLen ¶ added in v0.2.0
func (o MegolmInboundSession) PickleLen() int
PickleLen returns the number of bytes the pickled session will have.
func (MegolmInboundSession) PickleLibOlm ¶ added in v0.2.0
func (o MegolmInboundSession) PickleLibOlm(target []byte) (int, error)
PickleLibOlm encodes the session 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 (MegolmInboundSession) SessionExportMessage ¶ added in v0.2.0
func (o MegolmInboundSession) SessionExportMessage(messageIndex uint32) ([]byte, error)
SessionExportMessage creates an base64 encoded export of the session.
func (MegolmInboundSession) SessionID ¶
func (o MegolmInboundSession) SessionID() id.SessionID
SessionID returns the base64 endoded signing key
func (*MegolmInboundSession) Unpickle ¶
func (o *MegolmInboundSession) Unpickle(pickled, key []byte) error
Unpickle decodes the base64 encoded string and decrypts the result with the key. The decrypted value is then passed to UnpickleLibOlm.
func (*MegolmInboundSession) UnpickleAsJSON ¶ added in v0.2.0
func (o *MegolmInboundSession) UnpickleAsJSON(pickled, key []byte) error
UnpickleAsJSON updates an MegolmInboundSession by a base64 encrypted string using the supplied key. The unencrypted representation has to be in JSON format.
func (*MegolmInboundSession) UnpickleLibOlm ¶ added in v0.2.0
func (o *MegolmInboundSession) UnpickleLibOlm(value []byte) (int, error)
UnpickleLibOlm decodes the unencryted value and populates the Session accordingly. It returns the number of bytes read.
type MegolmOutboundSession ¶
type MegolmOutboundSession struct { Ratchet megolm.Ratchet `json:"ratchet"` SigningKey crypto.Ed25519KeyPair `json:"signingKey"` }
MegolmOutboundSession stores information about the sessions to send.
func MegolmOutboundSessionFromPickled ¶ added in v0.2.0
func MegolmOutboundSessionFromPickled(pickled, key []byte) (*MegolmOutboundSession, error)
MegolmOutboundSessionFromPickled loads the MegolmOutboundSession details from a pickled base64 string. The input is decrypted with the supplied key.
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 (o MegolmOutboundSession) Pickle(key []byte) ([]byte, error)
Pickle returns a base64 encoded and with key encrypted pickled MegolmOutboundSession using PickleLibOlm().
func (MegolmOutboundSession) PickleAsJSON ¶ added in v0.2.0
func (o MegolmOutboundSession) PickleAsJSON(key []byte) ([]byte, error)
PickleAsJSON returns an Session as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.
func (MegolmOutboundSession) PickleLen ¶ added in v0.2.0
func (o MegolmOutboundSession) PickleLen() int
PickleLen returns the number of bytes the pickled session will have.
func (MegolmOutboundSession) PickleLibOlm ¶ added in v0.2.0
func (o MegolmOutboundSession) PickleLibOlm(target []byte) (int, error)
PickleLibOlm encodes the session 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 (MegolmOutboundSession) SessionID ¶
func (o MegolmOutboundSession) SessionID() id.SessionID
SessionID returns the base64 endoded public signing key
func (MegolmOutboundSession) SessionSharingMessage ¶ added in v0.2.0
func (o MegolmOutboundSession) SessionSharingMessage() ([]byte, error)
func (*MegolmOutboundSession) Unpickle ¶
func (o *MegolmOutboundSession) Unpickle(pickled, key []byte) error
Unpickle decodes the base64 encoded string and decrypts the result with the key. The decrypted value is then passed to UnpickleLibOlm.
func (*MegolmOutboundSession) UnpickleAsJSON ¶ added in v0.2.0
func (o *MegolmOutboundSession) UnpickleAsJSON(pickled, key []byte) error
UnpickleAsJSON updates an Session by a base64 encrypted string with the key. The unencrypted representation has to be in JSON format.
func (*MegolmOutboundSession) UnpickleLibOlm ¶ added in v0.2.0
func (o *MegolmOutboundSession) UnpickleLibOlm(value []byte) (int, error)
UnpickleLibOlm decodes the unencryted value and populates the Session accordingly. It returns the number of bytes read.
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 OlmSessionFromJSONPickled ¶ added in v0.2.0
func OlmSessionFromJSONPickled(pickled, key []byte) (*OlmSession, error)
OlmSessionFromJSONPickled loads an OlmSession from a pickled base64 string. Decrypts the Session using the supplied key.
func OlmSessionFromPickled ¶
func OlmSessionFromPickled(pickled, key []byte) (*OlmSession, error)
OlmSessionFromPickled loads the OlmSession details from a pickled base64 string. The input is decrypted with 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) Describe ¶ added in v0.2.0
func (o OlmSession) Describe() string
Describe returns a string describing the current state of the session for debugging.
func (*OlmSession) Encrypt ¶
func (s *OlmSession) Encrypt(plaintext []byte, reader io.Reader) (id.OlmMsgType, []byte, error)
Encrypt encrypts a message using the Session. Returns the encrypted message base64 encoded. If reader is nil, crypto/rand is used for key generations.
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) MatchesInboundSessionFrom ¶ added in v0.2.0
func (s OlmSession) MatchesInboundSessionFrom(theirIdentityKeyEncoded *id.Curve25519, receivedOTKMsg []byte) (bool, error)
MatchesInboundSessionFrom 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 (o OlmSession) Pickle(key []byte) ([]byte, error)
Pickle returns a base64 encoded and with key encrypted pickled olmSession using PickleLibOlm().
func (OlmSession) PickleAsJSON ¶ added in v0.2.0
func (a OlmSession) PickleAsJSON(key []byte) ([]byte, error)
PickleAsJSON returns an Session as a base64 string encrypted using the supplied key. The unencrypted representation of the Account is in JSON format.
func (OlmSession) PickleLen ¶ added in v0.2.0
func (o OlmSession) PickleLen() int
PickleLen returns the actual number of bytes the pickled session will have.
func (OlmSession) PickleLenMin ¶ added in v0.2.0
func (o OlmSession) PickleLenMin() int
PickleLenMin returns the minimum number of bytes the pickled session must have.
func (OlmSession) PickleLibOlm ¶ added in v0.2.0
func (o OlmSession) PickleLibOlm(target []byte) (int, error)
PickleLibOlm encodes the session 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 (*OlmSession) Unpickle ¶
func (o *OlmSession) Unpickle(pickled, key []byte) error
Unpickle decodes the base64 encoded string and decrypts the result with the key. The decrypted value is then passed to UnpickleLibOlm.
func (*OlmSession) UnpickleAsJSON ¶ added in v0.2.0
func (a *OlmSession) UnpickleAsJSON(pickled, key []byte) error
UnpickleAsJSON updates an Session by a base64 encrypted string with the key. The unencrypted representation has to be in JSON format.
func (*OlmSession) UnpickleLibOlm ¶ added in v0.2.0
func (o *OlmSession) UnpickleLibOlm(value []byte) (int, error)
UnpickleLibOlm decodes the unencryted value and populates the Session accordingly. It returns the number of bytes read.
type SearchOTKFunc ¶
type SearchOTKFunc = func(crypto.Curve25519PublicKey) *crypto.OneTimeKey
used to retrieve a crypto.OneTimeKey from a public key.