OlmInboundGroupSession

Struct OlmInboundGroupSession 

Source
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

Source

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 base64
  • BadSessionKey if session key is invalid
Source

pub fn import(key: &str) -> Result<Self, OlmGroupSessionError>

Import an inbound group session, from a previous export.

§C-API equivalent

olm_import_inbound_group_session

§Errors
  • InvalidBase64 if session key is invalid base64
  • BadSessionKey if session key is invalid
Source

pub fn pickle(&self, mode: PicklingMode) -> String

Serialises an OlmInboundGroupSession to encrypted Base64.

§C-API equivalent

olm_pickle_inbound_group_session

§Panics
  • OutputBufferTooSmall for OlmInboundGroupSession’s pickled buffer
  • on malfromed UTF-8 coding of the pickling provided by libolm
Source

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 with
  • InvalidBase64 if decoding the supplied pickled string slice fails
Source

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 base64
  • BadMessageVersion if the message was encrypted with an unsupported version of the protocol
  • BadMessageFormat if the message headers could not be decoded
  • BadMessageMac if the message could not be verified
  • UnknownMessageIndex 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
Source

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
Source

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
Source

pub fn session_id(&self) -> String

Get a base64-encoded identifier for this session.

§C-API equivalent
  • olm_inbound_group_session_id
§Panics
  • OutputBufferTooSmall for session ID buffer
  • on malformed UTF-8 coding of the session ID provided by libolm
Source

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

Trait Implementations§

Source§

impl Drop for OlmInboundGroupSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for OlmInboundGroupSession

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.