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
sourceimpl EstablishedSas
impl EstablishedSas
sourcepub fn bytes(&self, info: &str) -> SasBytes
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.
sourcepub fn bytes_raw(
&self,
info: &str,
count: usize
) -> Result<Vec<u8>, InvalidCount>
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.
sourcepub fn calculate_mac(&self, input: &str, info: &str) -> Mac
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.
sourcepub fn calculate_mac_invalid_base64(&self, input: &str, info: &str) -> String
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.
sourcepub fn verify_mac(
&self,
input: &str,
info: &str,
tag: &Mac
) -> Result<(), SasError>
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.
sourcepub fn our_public_key(&self) -> Curve25519PublicKey
pub fn our_public_key(&self) -> Curve25519PublicKey
Get the public key that was created by us, that was used to establish the shared secret.
sourcepub fn their_public_key(&self) -> Curve25519PublicKey
pub 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
Auto Trait Implementations
impl RefUnwindSafe for EstablishedSas
impl Send for EstablishedSas
impl Sync for EstablishedSas
impl Unpin for EstablishedSas
impl UnwindSafe for EstablishedSas
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more