Lines Matching +full:- +full:- +full:algorithm
15 //! HMAC-based Extract-and-Expand Key Derivation Function.
23 /// An HKDF algorithm.
25 pub struct Algorithm(hmac::Algorithm); struct
27 impl Algorithm { impl
28 /// The underlying HMAC algorithm.
30 pub fn hmac_algorithm(&self) -> hmac::Algorithm { in hmac_algorithm() argument
35 /// HKDF using HMAC-SHA-1. Obsolete.
36 pub static HKDF_SHA1_FOR_LEGACY_USE_ONLY: Algorithm =
37 Algorithm(hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY);
39 /// HKDF using HMAC-SHA-256.
40 pub static HKDF_SHA256: Algorithm = Algorithm(hmac::HMAC_SHA256);
42 /// HKDF using HMAC-SHA-384.
43 pub static HKDF_SHA384: Algorithm = Algorithm(hmac::HMAC_SHA384);
45 /// HKDF using HMAC-SHA-512.
46 pub static HKDF_SHA512: Algorithm = Algorithm(hmac::HMAC_SHA512);
48 impl KeyType for Algorithm { implementation
49 fn len(&self) -> usize { in len()
60 /// algorithm.
63 /// `Salt` object instead of re-constructing `Salt`s with the same value.
64 pub fn new(algorithm: Algorithm, value: &[u8]) -> Self { in new() argument
65 Self(hmac::Key::new(algorithm.0, value)) in new()
68 /// The [HKDF-Extract] operation.
70 /// [HKDF-Extract]: https://tools.ietf.org/html/rfc5869#section-2.2
71 pub fn extract(&self, secret: &[u8]) -> Prk { in extract()
74 // already zero-padded to the block length, which is larger than the output in extract()
77 // zero-length string. in extract()
80 Prk(hmac::Key::new(salt.algorithm(), prk.as_ref())) in extract()
83 /// The algorithm used to derive this salt.
85 pub fn algorithm(&self) -> Algorithm { in algorithm() argument
86 Algorithm(self.0.algorithm()) in algorithm()
90 impl From<Okm<'_, Algorithm>> for Salt {
91 fn from(okm: Okm<'_, Algorithm>) -> Self { in from()
104 fn len(&self) -> usize; in len()
117 pub fn new_less_safe(algorithm: Algorithm, value: &[u8]) -> Self { in new_less_safe() argument
118 Self(hmac::Key::new(algorithm.hmac_algorithm(), value)) in new_less_safe()
121 /// The [HKDF-Expand] operation.
123 /// [HKDF-Expand]: https://tools.ietf.org/html/rfc5869#section-2.3
131 ) -> Result<Okm<'a, L>, error::Unspecified> { in expand()
133 if len_cached > 255 * self.0.algorithm().digest_algorithm().output_len { in expand()
145 impl From<Okm<'_, Algorithm>> for Prk {
146 fn from(okm: Okm<Algorithm>) -> Self { in from()
171 pub fn len(&self) -> &L { in len()
175 /// Fills `out` with the output of the HKDF-Expand operation for the given
179 /// times the size of the digest algorithm's output. (This is the limit
183 pub fn fill(self, out: &mut [u8]) -> Result<(), error::Unspecified> { in fill()
193 ) -> Result<(), error::Unspecified> { in fill_okm()
198 let digest_alg = prk.0.algorithm().digest_algorithm(); in fill_okm()