| 1 |
// Overwrite intra-crate links |
| 2 |
//! [`Reset`]: digest::Reset |
| 3 |
//! [`Digest`]: digest::Digest |
| 4 |
//! [`FixedOutputReset`]: digest::FixedOutputReset |
| 5 |
//! [`Hmac`]: Hmac |
| 6 |
//! [`HmacReset`]: HmacReset |
| 7 |
//! [`SimpleHmac`]: SimpleHmac |
| 8 |
//! [`SimpleHmacReset`]: SimpleHmacReset |
| 9 |
//! [`block_api::HmacCore`]: block_api::HmacCore |
| 10 |
//! [`block_api::HmacResetCore`]: block_api::HmacResetCore |
| 11 |
|
| 12 |
#![no_std] |
| 13 |
#![doc = include_str!("../README.md")] |
| 14 |
#![doc( |
| 15 |
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg", |
| 16 |
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg" |
| 17 |
)] |
| 18 |
#![cfg_attr(docsrs, feature(doc_cfg))] |
| 19 |
|
| 20 |
pub use digest::{self, KeyInit, Mac, block_api::EagerHash}; |
| 21 |
|
| 22 |
/// Block-level implementation. |
| 23 |
pub mod block_api; |
| 24 |
mod simple; |
| 25 |
mod simple_reset; |
| 26 |
mod utils; |
| 27 |
|
| 28 |
pub use simple::SimpleHmac; |
| 29 |
pub use simple_reset::SimpleHmacReset; |
| 30 |
|
| 31 |
use core::fmt; |
| 32 |
use digest::block_api::{AlgorithmName, CoreProxy}; |
| 33 |
|
| 34 |
digest::buffer_fixed!( |
| 35 |
/// Generic HMAC instance. |
| 36 |
#[derive(Clone)] |
| 37 |
pub struct Hmac<D: EagerHash>(block_api::HmacCore<D>); |
| 38 |
impl: MacTraits KeyInit; |
| 39 |
); |
| 40 |
|
| 41 |
impl<D: EagerHash + AlgorithmName> AlgorithmName for Hmac<D> { |
| 42 |
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 43 |
<Self as CoreProxy>::Core::write_alg_name(f) |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
digest::buffer_fixed!( |
| 48 |
/// Generic HMAC instance with reset support. |
| 49 |
#[derive(Clone)] |
| 50 |
pub struct HmacReset<D: EagerHash>(block_api::HmacResetCore<D>); |
| 51 |
impl: ResetMacTraits KeyInit; |
| 52 |
); |
| 53 |
|
| 54 |
impl<D: EagerHash + AlgorithmName> AlgorithmName for HmacReset<D> { |
| 55 |
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 56 |
<Self as CoreProxy>::Core::write_alg_name(f) |
| 57 |
} |
| 58 |
} |