pub struct OlmInboundGroupSession { /* private fields */ }
Expand description
An in-bound group session is responsible for decrypting incoming communication in a Megolm session.
Implementations§
Source§impl OlmInboundGroupSession
impl OlmInboundGroupSession
Sourcepub fn new(key: &str) -> Result<Self, OlmGroupSessionError>
pub fn new(key: &str) -> Result<Self, OlmGroupSessionError>
Creates a new instance of OlmInboundGroupSession
.
§C-API equivalent
olm_init_inbound_group_session
§Errors
InvalidBase64
if session key is invalid base64BadSessionKey
if session key is invalid
Sourcepub fn import(key: &str) -> Result<Self, OlmGroupSessionError>
pub fn import(key: &str) -> Result<Self, OlmGroupSessionError>
Sourcepub fn pickle(&self, mode: PicklingMode) -> String
pub fn pickle(&self, mode: PicklingMode) -> String
Serialises an OlmInboundGroupSession
to encrypted Base64.
§C-API equivalent
olm_pickle_inbound_group_session
§Panics
OutputBufferTooSmall
forOlmInboundGroupSession
’s pickled buffer- on malfromed UTF-8 coding of the pickling provided by libolm
Sourcepub fn unpickle(
pickled: String,
mode: PicklingMode,
) -> Result<Self, OlmGroupSessionError>
pub fn unpickle( pickled: String, mode: PicklingMode, ) -> Result<Self, OlmGroupSessionError>
Deserialises from encrypted Base64 that was previously obtained by pickling an OlmInboundGroupSession
.
§C-API equivalent
olm_unpickle_inbound_group_session
§Errors
BadAccountKey
if the key doesn’t match the one the session was encrypted withInvalidBase64
if decoding the suppliedpickled
string slice fails
Sourcepub fn decrypt(
&self,
message: String,
) -> Result<(String, u32), OlmGroupSessionError>
pub fn decrypt( &self, message: String, ) -> Result<(String, u32), OlmGroupSessionError>
Decrypts ciphertext received for this group session. Decoding is lossy, meaing if
the decrypted plaintext contains invalid UTF-8 symbols, they will
be returned as U+FFFD
(�).
Returns both plaintext and message index.
§C-API equivalent
olm_group_decrypt
§Errors
InvalidBase64
if the message is invalid base64BadMessageVersion
if the message was encrypted with an unsupported version of the protocolBadMessageFormat
if the message headers could not be decodedBadMessageMac
if the message could not be verifiedUnknownMessageIndex
if we do not have a session key corresponding to the message’s index (ie, it was sent before the session key was shared with us)
§Panics
OutputBufferTooSmall
for decrypted ciphertext
Sourcepub fn export(&self, message_index: u32) -> Result<String, OlmGroupSessionError>
pub fn export(&self, message_index: u32) -> Result<String, OlmGroupSessionError>
Export the base64-encoded ratchet key for this session, at the given index, in a format which can be used by import
§C-API equivalent
olm_export_inbound_group_session
§Errors
UnkownMessageIndex
if we do not have a session key corresponding to the given index (ie, it was sent before the session key was shared with us)
§Panics
OutputBufferTooSmall
for export buffer- on malformed UTF-8 coding of the exported session provided by libolm
Sourcepub fn first_known_index(&self) -> u32
pub fn first_known_index(&self) -> u32
Get the first message index we know how to decrypt.
§C-API equivalent
olm_inbound_group_session_first_known_index
Sourcepub fn session_id(&self) -> String
pub fn session_id(&self) -> String
Sourcepub fn session_is_verified(&self) -> bool
pub fn session_is_verified(&self) -> bool
Check if the session has been verified as a valid session.
(A session is verified either because the original session share was signed, or because we have subsequently successfully decrypted a message.)
This is mainly intended for the unit tests (in libolm), currently.
§C-API equivalent
olm_inbound_group_session_is_verified