pub struct Hmac<'d> { /* private fields */ }Expand description
Provides an interface for interacting with the HMAC hardware peripheral. Computes HMACs for cryptographic purposes and ensures data integrity and authenticity.
Implementations§
Source§impl<'d> Hmac<'d>
impl<'d> Hmac<'d>
Sourcepub fn new(hmac: HMAC<'d>, sha: SHA<'d>) -> Self
pub fn new(hmac: HMAC<'d>, sha: SHA<'d>) -> Self
Creates a new instance of the HMAC peripheral.
The HMAC peripheral uses the SHA accelerator, so the driver owns the SHA peripheral and
turns on its clock. A program that creates a Sha or a ShaBackend while the driver is in
use does not compile.
An unfinished HMAC corrupts the next SHA digest. To prevent this, the drop resets the HMAC peripheral.
§Examples
Pass SHA with reborrow so that another driver can use it after the drop.
use esp_hal::{hmac::Hmac, sha::Sha};
let hmac = Hmac::new(peripherals.HMAC, peripherals.SHA.reborrow());
// Calculate the HMACs.
drop(hmac);
let sha = Sha::new(peripherals.SHA);Sourcepub fn configure(&mut self, m: HmacPurpose, key_id: KeyId) -> Result<(), Error>
pub fn configure(&mut self, m: HmacPurpose, key_id: KeyId) -> Result<(), Error>
Configures HMAC keys and key purposes.