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

pub struct OlmAccount { /* fields omitted */ }
Expand description

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

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

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

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

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

Returns the account’s public identity keys.

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

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

C-API equivalent

olm_account_max_number_of_one_time_keys

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

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

Returns the account’s one-time keys.

Mark the current set of one time keys as published.

C-API equivalent

olm_account_mark_keys_as_published

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

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

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

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

Returns the “default value” for a type. Read more

Executes the destructor for this type. Read more

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

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.