// - Text and hash is in the same register -> needs an additional load operation to place the hash
fn finish(&self, state: &mut DigestState, output: &mut [u8]) -> nb::Result<(), Infallible> {
// - This means that we need to buffer bytes coming in up to 4 u8's in order to create a full u32
impl<'d, A: ShaAlgorithm, S: BorrowMut<Sha<'d>>> digest_010::HashMarker for ShaDigest<'d, A, S> {}
impl<'d, A: ShaAlgorithm, S: BorrowMut<Sha<'d>>> digest_011::HashMarker for ShaDigest<'d, A, S> {}
impl<'d, A: ShaAlgorithm, S: BorrowMut<Sha<'d>>> digest_010::FixedOutput for ShaDigest<'d, A, S> {
impl<'d, A: ShaAlgorithm, S: BorrowMut<Sha<'d>>> digest_011::FixedOutput for ShaDigest<'d, A, S> {
(algos $( ( $name:ident, $full_name:literal $sizes:tt $security:tt, $mode_bits:literal ) ),*) => {
(algos $( ( $name:ident, $full_name:literal (sizes: $block_size:literal, $digest_len:literal, $message_length_bytes:literal) $security:tt, $mode_bits:literal ) ),*) => {
( $name:ident, $full_name:literal (sizes: $block_size:literal, $digest_len:literal, $message_length_bytes:literal) (insecure_against: $($attack_kind:literal),*), $mode_bits:literal ) => {
/// Manages the context and state required for processing data using the selected hashing algorithm.
#[doc = concat!(" > ⚠️ This algorithm is known to be insecure against ", $attack_kind, " attacks.")]
// for the pointers, are Sync. The pointers are safe to share because they point at data that the
// ESP32 can't save the context, so it can't support interleaved operation. To support the digest
// API, we need to limit the number of concurrent contexts - to 1. Thankfully ESP32 has no DSA/HMAC,
// Currently we fall back to a software implementation if multiple contexts are created. Instead, we
// could save the hash like we do on other MCUs, and continue with software if another context has
impl<const CHUNK_BYTES: usize, const DIGEST_WORDS: usize> ShaContext<CHUNK_BYTES, DIGEST_WORDS> {
( $name:ident, $full_name:literal (sizes: $block_size:literal, $digest_len:literal, $message_length_bytes:literal) $security:tt, $mode_bits:literal ) => {
impl_worker_context!( [<$name Context>], $full_name, ShaAlgorithmKind::$name, $digest_len, $block_size );