Struct olm_rs::account::OlmAccount[][src]

pub struct OlmAccount { /* fields omitted */ }

An olm account manages all cryptographic keys used on a device.

use olm_rs::account::OlmAccount;

let olm_account = OlmAccount::new();
println!("{:?}", olm_account.identity_keys());

Implementations

impl OlmAccount[src]

pub fn new() -> Self[src]

Creates a new instance of OlmAccount. During the instantiation the Ed25519 fingerprint key pair and the Curve25519 identity key pair are generated. For more information see here.

C-API equivalent

olm_create_account

Panics

  • NOT_ENOUGH_RANDOM for OlmAccount's creation

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

Serialises an OlmAccount to encrypted Base64.

C-API equivalent

olm_pickle_account

Example

use olm_rs::account::OlmAccount;
use olm_rs::PicklingMode;

let identity_keys;
let olm_account = OlmAccount::new();
identity_keys = olm_account.identity_keys();
let pickled = olm_account.pickle(PicklingMode::Unencrypted);
let olm_account_2 = OlmAccount::unpickle(pickled, PicklingMode::Unencrypted).unwrap();
let identity_keys_2 = olm_account_2.identity_keys();

assert_eq!(identity_keys, identity_keys_2);

Panics

  • OUTPUT_BUFFER_TOO_SMALL for OlmAccount's pickled buffer
  • on malformed UTF-8 coding for pickling provided by libolm

pub fn unpickle(
    mut pickled: String,
    mode: PicklingMode
) -> Result<Self, OlmAccountError>
[src]

Deserialises from encrypted Base64 that was previously obtained by pickling an OlmAccount.

C-API equivalent

olm_unpickle_account

Errors

  • BadAccountKey if the key doesn't match the one the account was encrypted with
  • InvalidBase64 if decoding the supplied pickled string slice fails

pub fn identity_keys(&self) -> String[src]

Returns the account's public identity keys already formatted as JSON and BASE64.

C-API equivalent

olm_account_identity_keys

Panics

  • OUTPUT_BUFFER_TOO_SMALL for supplied identity keys buffer
  • on malformed UTF-8 coding of the identity keys provided by libolm

pub fn parsed_identity_keys(&self) -> IdentityKeys[src]

Returns the account's public identity keys.

pub fn sign(&self, message: &str) -> String[src]

Returns the signature of the supplied byte slice.

C-API equivalent

olm_account_sign

Panics

  • OUTPUT_BUFFER_TOO_SMALL for supplied signature buffer
  • on malformed UTF-8 coding of the signature provided by libolm

pub fn max_number_of_one_time_keys(&self) -> usize[src]

Maximum number of one time keys that this OlmAccount can currently hold.

C-API equivalent

olm_account_max_number_of_one_time_keys

pub fn generate_one_time_keys(&self, number_of_keys: usize)[src]

Generates the supplied number of one time keys.

C-API equivalent

olm_account_generate_one_time_keys

Panics

  • NOT_ENOUGH_RANDOM for the creation of one time keys

pub fn one_time_keys(&self) -> String[src]

Gets the OlmAccount's one time keys formatted as JSON.

C-API equivalent

olm_account_one_time_keys

Panics

  • OUTPUT_BUFFER_TOO_SMALL for supplied one time keys buffer
  • on malformed UTF-8 coding of the keys provided by libolm

pub fn parsed_one_time_keys(&self) -> OneTimeKeys[src]

Returns the account's one-time keys.

pub fn mark_keys_as_published(&self)[src]

Mark the current set of one time keys as published.

C-API equivalent

olm_account_mark_keys_as_published

pub fn remove_one_time_keys(
    &self,
    session: &OlmSession
) -> Result<(), OlmAccountError>
[src]

Remove the one time key used to create the supplied session.

C-API equivalent

olm_remove_one_time_keys

Errors

  • BAD_MESSAGE_KEY_ID when the account doesn't hold a matching one time key

pub fn create_inbound_session(
    &self,
    message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
[src]

Creates an inbound session for sending/receiving messages from a received 'prekey' message.

Arguments

  • message - An Olm pre-key message that was encrypted for this account.

Errors

  • InvalidBase64
  • BadMessageVersion
  • BadMessageFormat
  • BadMessageKeyId

pub fn create_inbound_session_from(
    &self,
    their_identity_key: &str,
    message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
[src]

Creates an inbound session for sending/receiving messages from a received 'prekey' message.

  • their_identity_key - The identity key of an Olm account that encrypted this Olm message.

  • message - An Olm pre-key message that was encrypted for this account.

Errors

  • InvalidBase64
  • BadMessageVersion
  • BadMessageFormat
  • BadMessageKeyId

pub fn create_outbound_session(
    &self,
    their_identity_key: &str,
    their_one_time_key: &str
) -> Result<OlmSession, OlmSessionError>
[src]

Creates an outbound session for sending messages to a specific identity and one time key.

Errors

  • InvalidBase64 for invalid base64 coding on supplied arguments

Panics

  • NotEnoughRandom if not enough random data was supplied

Trait Implementations

impl Default for OlmAccount[src]

impl Drop for OlmAccount[src]

impl Send for OlmAccount[src]

Marking these as Send is safe because nothing will modify the pointer under us from the C side. Sync on the other hand is unsafe since libolm doesn't do any synchronization.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.