pub struct OlmSas { /* private fields */ }
Implementations§
Source§impl OlmSas
impl OlmSas
pub fn new() -> Self
Sourcepub fn public_key(&self) -> String
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.
Sourcepub fn set_their_public_key(
&mut self,
public_key: String,
) -> Result<(), OlmSasError>
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.
Sourcepub fn generate_bytes(
&self,
extra_info: &str,
length: usize,
) -> Result<Vec<u8>, OlmSasError>
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.
Sourcepub fn calculate_mac(
&self,
message: &str,
extra_info: &str,
) -> Result<String, OlmSasError>
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.