OlmSas

Struct OlmSas 

Source
pub struct OlmSas { /* private fields */ }

Implementations§

Source§

impl OlmSas

Source

pub fn new() -> Self

Source

pub fn public_key(&self) -> String

Get the public key for the SAS object.

This returns the public key of the SAS object that can then be shared with another user to perform the authentication process.

Source

pub fn set_their_public_key( &mut self, public_key: String, ) -> Result<(), OlmSasError>

Set the public key of the other user.

This sets the public key of the other user, it needs to be set before bytes can be generated for the authentication string and a MAC can be calculated.

Returns an error if the public key was too short or invalid.

§Arguments
  • public_key - The public key of the other user.
Source

pub fn generate_bytes( &self, extra_info: &str, length: usize, ) -> Result<Vec<u8>, OlmSasError>

Generate bytes to use for the short authentication string.

Note the other public key needs to be set for this method to work. Returns an error if it isn’t set.

§Arguments
  • extra_info - Extra information to mix in when generating the bytes.

  • length - The number of bytes to generate.

Source

pub fn calculate_mac( &self, message: &str, extra_info: &str, ) -> Result<String, OlmSasError>

Generate a message authentication code based on the shared secret.

Note the other public key needs to be set for this method to work. Returns an error if it isn’t set.

§Arguments
  • message - The message to produce the authentication code for.

  • extra_info - Extra information to mix in when generating the MAC.

Trait Implementations§

Source§

impl Default for OlmSas

Source§

fn default() -> Self

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

impl Drop for OlmSas

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for OlmSas

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.