vodozemac::sas

Struct 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

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V