Struct ring::hmac::Key [−][src]
A key to use for HMAC signing.
Implementations
impl Key
[src]
pub fn generate(
algorithm: Algorithm,
rng: &dyn SecureRandom
) -> Result<Self, Unspecified>
[src]
algorithm: Algorithm,
rng: &dyn SecureRandom
) -> Result<Self, Unspecified>
Generate an HMAC signing key using the given digest algorithm with a
random value generated from rng
.
The key will be digest_alg.output_len
bytes long, based on the
recommendation in RFC 2104 Section 3.
pub fn new(algorithm: Algorithm, key_value: &[u8]) -> Self
[src]
Construct an HMAC signing key using the given digest algorithm and key value.
key_value
should be a value generated using a secure random number
generator (e.g. the key_value
output by
SealingKey::generate_serializable()
) or derived from a random key by
a key derivation function (e.g. ring::hkdf
). In particular,
key_value
shouldn’t be a password.
As specified in RFC 2104, if key_value
is shorter than the digest
algorithm’s block length (as returned by digest::Algorithm::block_len
,
not the digest length returned by digest::Algorithm::output_len
) then
it will be padded with zeros. Similarly, if it is longer than the block
length then it will be compressed using the digest algorithm.
You should not use keys larger than the digest_alg.block_len
because
the truncation described above reduces their strength to only
digest_alg.output_len * 8
bits. Support for such keys is likely to be
removed in a future version of ring.
pub fn algorithm(&self) -> Algorithm
[src]
The digest algorithm for the key.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,