From 2f3cf06c16539bac4f9b9fa309d9ad445ff1fbf8 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 26 Sep 2025 22:57:10 +0800 Subject: [PATCH] helps to actually copy the data into the hash engine --- bao1x-boot/sha2-bao1x/src/sha256.rs | 3 +-- bao1x-boot/sha2-bao1x/src/sha512.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bao1x-boot/sha2-bao1x/src/sha256.rs b/bao1x-boot/sha2-bao1x/src/sha256.rs index 0faa02f8c..22b1724d5 100644 --- a/bao1x-boot/sha2-bao1x/src/sha256.rs +++ b/bao1x-boot/sha2-bao1x/src/sha256.rs @@ -29,14 +29,13 @@ fn compress(csr: &mut CSR, blocks: &[[u8; BLOCK_LEN]]) { const BUF_BLOCKS: usize = utralib::HW_SEG_MSG_MEM_LEN / BLOCK_LEN; // safety: this is the actual location of the message buffer and its length according to the hardware // spec. only safe because this is machine mode and no-std (no threads, no concurrency) - #[cfg(feature = "debug")] let msg_blocks: &mut [[u8; BLOCK_LEN]; BUF_BLOCKS] = unsafe { &mut *(utralib::HW_SEG_MSG_MEM as *mut [[u8; BLOCK_LEN]; BUF_BLOCKS]) }; for block_chunk in blocks.chunks(BUF_BLOCKS) { // block_chunk has a length equal to or less than msg_buf due to .chunks() iterator above - #[cfg(feature = "debug")] for (src, dst) in block_chunk.iter().zip(msg_blocks.iter_mut()) { + #[cfg(feature = "debug")] crate::println!(" {:x?}", src); dst.copy_from_slice(src); } diff --git a/bao1x-boot/sha2-bao1x/src/sha512.rs b/bao1x-boot/sha2-bao1x/src/sha512.rs index aaa989459..bbe2949e8 100644 --- a/bao1x-boot/sha2-bao1x/src/sha512.rs +++ b/bao1x-boot/sha2-bao1x/src/sha512.rs @@ -29,14 +29,13 @@ fn compress(csr: &mut CSR, blocks: &[[u8; BLOCK_LEN]]) { const BUF_BLOCKS: usize = utralib::HW_SEG_MSG_MEM_LEN / BLOCK_LEN; // safety: this is the actual location of the message buffer and its length according to the hardware // spec. only safe because this is machine mode and no-std (no threads, no concurrency) - #[cfg(feature = "debug")] let msg_blocks: &mut [[u8; BLOCK_LEN]; BUF_BLOCKS] = unsafe { &mut *(utralib::HW_SEG_MSG_MEM as *mut [[u8; BLOCK_LEN]; BUF_BLOCKS]) }; for block_chunk in blocks.chunks(BUF_BLOCKS) { // block_chunk has a length equal to or less than msg_buf due to .chunks() iterator above - #[cfg(feature = "debug")] for (src, dst) in block_chunk.iter().zip(msg_blocks.iter_mut()) { + #[cfg(feature = "debug")] crate::println!(" {:x?}", src); dst.copy_from_slice(src); }