Struct vodozemac::sas::EstablishedSas

source ·
pub struct EstablishedSas { /* private fields */ }
Expand description

A struct representing a short auth string verification object where the shared secret has been established.

This object can be used to generate the short auth string and calculate and verify a MAC that protects information about the keys being verified.

Implementations§

source§

impl EstablishedSas

source

pub fn bytes(&self, info: &str) -> SasBytes

Generate SasBytes using HKDF with the shared secret as the input key material.

The info string should be agreed upon beforehand, both parties need to use the same info string.

source

pub fn bytes_raw( &self, info: &str, count: usize, ) -> Result<Vec<u8>, InvalidCount>

Generate the given number of bytes using HKDF with the shared secret as the input key material.

The info string should be agreed upon beforehand, both parties need to use the same info string.

The number of bytes we can generate is limited, we can generate up to 32 * 255 bytes. The function will not fail if the given count is smaller than the limit.

source

pub fn calculate_mac(&self, input: &str, info: &str) -> Mac

Calculate a MAC for the given input using the info string as additional data.

This should be used to calculate a MAC of the ed25519 identity key of an Account

The MAC is returned as a base64 encoded string.

source

pub fn calculate_mac_invalid_base64(&self, input: &str, info: &str) -> String

Calculate a MAC for the given input using the info string as additional data, the MAC is returned as an invalid base64 encoded string.

Warning: This method should never be used unless you require libolm compatibility. Libolm used to incorrectly encode their MAC because the input buffer was reused as the output buffer. This method replicates the buggy behaviour.

source

pub fn verify_mac( &self, input: &str, info: &str, tag: &Mac, ) -> Result<(), SasError>

Verify a MAC that was previously created using the EstablishedSas::calculate_mac() method.

Users should calculate a MAC and send it to the other side, they should then verify each other’s MAC using this method.

source

pub const fn our_public_key(&self) -> Curve25519PublicKey

Get the public key that was created by us, that was used to establish the shared secret.

source

pub const fn their_public_key(&self) -> Curve25519PublicKey

Get the public key that was created by the other party, that was used to establish the shared secret.

Trait Implementations§

source§

impl Debug for EstablishedSas

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V