Fixed HMAC blocking mode.

This commit is contained in:
Caleb Garrett 2024-02-12 20:33:04 -05:00
parent f0f1f2d14c
commit 14a678fe45

View file

@ -215,7 +215,7 @@ impl<'d, T: Instance, D> Hash<'d, T, D> {
self.accumulate_blocking(key); self.accumulate_blocking(key);
T::regs().str().write(|w| w.set_dcal(true)); T::regs().str().write(|w| w.set_dcal(true));
// Block waiting for digest. // Block waiting for digest.
while !T::regs().sr().read().dcis() {} while !T::regs().sr().read().dinis() {}
} }
ctx.key_sent = true; ctx.key_sent = true;
} }
@ -365,16 +365,16 @@ impl<'d, T: Instance, D> Hash<'d, T, D> {
//Start the digest calculation. //Start the digest calculation.
T::regs().str().write(|w| w.set_dcal(true)); T::regs().str().write(|w| w.set_dcal(true));
// Block waiting for digest.
while !T::regs().sr().read().dcis() {}
// Load the HMAC key if provided. // Load the HMAC key if provided.
if let Some(key) = ctx.key { if let Some(key) = ctx.key {
while !T::regs().sr().read().dinis() {}
self.accumulate_blocking(key); self.accumulate_blocking(key);
T::regs().str().write(|w| w.set_dcal(true)); T::regs().str().write(|w| w.set_dcal(true));
while !T::regs().sr().read().dcis() {}
} }
// Block until digest computation is complete.
while !T::regs().sr().read().dcis() {}
// Return the digest. // Return the digest.
let digest_words = match ctx.algo { let digest_words = match ctx.algo {
Algorithm::SHA1 => 5, Algorithm::SHA1 => 5,