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_RANDOMfor 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_SMALLfor 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
BadAccountKeyif the key doesn’t match the one the account was encrypted withInvalidBase64if decoding the suppliedpickledstring 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_SMALLfor 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_SMALLfor 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_RANDOMfor 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_SMALLfor 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_IDwhen the account doesn’t hold a matching one time key
pub fn create_inbound_session(
&self,
message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
pub fn create_inbound_session(
&self,
message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
pub fn create_inbound_session_from(
&self,
their_identity_key: &str,
message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
pub fn create_inbound_session_from(
&self,
their_identity_key: &str,
message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
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
InvalidBase64BadMessageVersionBadMessageFormatBadMessageKeyId
pub fn create_outbound_session(
&self,
their_identity_key: &str,
their_one_time_key: &str
) -> Result<OlmSession, OlmSessionError>
pub fn create_outbound_session(
&self,
their_identity_key: &str,
their_one_time_key: &str
) -> Result<OlmSession, OlmSessionError>
Trait Implementations
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.