Struct olm_rs::account::OlmAccount [−][src]
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_RANDOMfor 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_SMALLfor 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]
mut pickled: String,
mode: PicklingMode
) -> Result<Self, OlmAccountError>
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
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_SMALLfor 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_SMALLfor 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_RANDOMfor 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_SMALLfor 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]
&self,
session: &OlmSession
) -> Result<(), OlmAccountError>
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>[src]
&self,
message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>
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
InvalidBase64BadMessageVersionBadMessageFormatBadMessageKeyId
pub fn create_inbound_session_from(
&self,
their_identity_key: &str,
message: PreKeyMessage
) -> Result<OlmSession, OlmSessionError>[src]
&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>[src]
&self,
their_identity_key: &str,
their_one_time_key: &str
) -> Result<OlmSession, OlmSessionError>
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
impl RefUnwindSafe for OlmAccount[src]
impl !Sync for OlmAccount[src]
impl Unpin for OlmAccount[src]
impl UnwindSafe for OlmAccount[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,