pub struct HMACKey(_);
Expand description

Key used for authentication and message integrity

Examples:

 // Creates a new long term credential key using MD5 algorithm
 let algorithm = Algorithm::from(AlgorithmId::MD5);
 let key = HMACKey::new_long_term("user", "realm", "pass", algorithm)?;
 assert_eq!(key.credential_mechanism(), CredentialMechanism::LongTerm);

 let expected_hash = [
     0x84, 0x93, 0xFB, 0xC5, 0x3B, 0xA5, 0x82, 0xFB,
     0x4C, 0x04, 0x4C, 0x45, 0x6B, 0xDC, 0x40, 0xEB,
 ];
 assert_eq!(key.as_bytes(), expected_hash);

Implementations

Creates a CredentialMechanism::ShortTerm key

Returns

The new HMACKey used for short term credential mechanism, or a StunError if the password can not be processed using the opaque string profile.

Creates a CredentialMechanism::LongTerm key.

Arguments:
  • username - The user name
  • realm - The realm.
  • algorithm- Optional value for the algorithm used to generate the key. If algorithm is None, AlgorithmId::MD5 will be used. The resulting key length is 16 bytes when MD5 is used, or 32 bytes if SHA-256 algorithm is used.
Returns

The new HMACKey used for long term credential mechanism, or a StunError if username, realm or password can not be processed using the opaque string profile.

Gets the bytes representation of the key

Gets the bytes representation of the key

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.