Skip to content

Commit 56cb038

Browse files
committed
final bug, now we are ready
1 parent c83edee commit 56cb038

11 files changed

Lines changed: 1419 additions & 1558 deletions

File tree

boards/nucleo_u545re_q/src/main.rs

Lines changed: 35 additions & 395 deletions
Large diffs are not rendered by default.

chips/stm32u5xx/src/chip.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Stm32u5xxDefaultPeripherals<'a> {
3535
pub dma1: &'a Dma,
3636
pub gpio_a: gpio::Port<'a>,
3737
pub gpio_c: gpio::Port<'a>,
38-
pub hash: &'a hash::Hash<'a>,
38+
pub hash: &'a hash::core_unit::Hash<'a>,
3939
}
4040

4141
fn enable_tim2_clock() {
@@ -48,7 +48,7 @@ impl<'a> Stm32u5xxDefaultPeripherals<'a> {
4848
usart1: &'a usart::Usart<'a>,
4949
exti: &'a exti::Exti<'a>,
5050
dma1: &'a Dma,
51-
hash: &'a hash::Hash<'a>,
51+
hash: &'a hash::core_unit::Hash<'a>,
5252
) -> Self {
5353
Self {
5454
rcc: rcc::Rcc::new(rcc::RCC_BASE),
@@ -83,7 +83,7 @@ impl<'a> Stm32u5xxDefaultPeripherals<'a> {
8383
}
8484

8585
if let Some(tx) = hash_channel {
86-
hash::Hash::set_dma(self.hash, self.dma1, tx);
86+
hash::core_unit::Hash::set_dma(self.hash, self.dma1, tx);
8787
}
8888
}
8989
}

chips/stm32u5xx/src/hash/core_unit.rs

Lines changed: 1189 additions & 0 deletions
Large diffs are not rendered by default.

chips/stm32u5xx/src/hash/md5.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use kernel::hil::digest;
66
use kernel::utilities::cells::OptionalCell;
77
use kernel::ErrorCode;
88

9-
use crate::hash::traits::HashAdaptee;
10-
use crate::hash::{Hash, HashAdapter, HashClient};
9+
use crate::hash::{core_unit::Hash, utils::HashClient};
1110

1211
const MD5_DIGEST_LEN: usize = 16;
1312

@@ -25,8 +24,8 @@ impl<'a> Md5Adapter<'a> {
2524
}
2625
}
2726

28-
impl<'a> HashAdapter<'a, Hash<'a>> for Md5Adapter<'a> {
29-
fn add_data_done(
27+
impl Md5Adapter<'_> {
28+
pub(crate) fn add_data_done(
3029
&self,
3130
result: Result<(), kernel::ErrorCode>,
3231
data: kernel::utilities::leasable_buffer::SubSlice<'static, u8>,
@@ -36,7 +35,7 @@ impl<'a> HashAdapter<'a, Hash<'a>> for Md5Adapter<'a> {
3635
});
3736
}
3837

39-
fn add_mut_data_done(
38+
pub(crate) fn add_mut_data_done(
4039
&self,
4140
result: Result<(), kernel::ErrorCode>,
4241
data: kernel::utilities::leasable_buffer::SubSliceMut<'static, u8>,
@@ -46,13 +45,17 @@ impl<'a> HashAdapter<'a, Hash<'a>> for Md5Adapter<'a> {
4645
});
4746
}
4847

49-
fn hash_done(&self, result: Result<(), kernel::ErrorCode>, digest: &'static mut [u8]) {
48+
pub(crate) fn hash_done(
49+
&self,
50+
result: Result<(), kernel::ErrorCode>,
51+
digest: &'static mut [u8],
52+
) {
5053
// terrible
5154
self.client
5255
.map(|client| client.hash_done(result, digest.try_into().unwrap()));
5356
}
5457

55-
fn verification_done(
58+
pub(crate) fn verification_done(
5659
&self,
5760
result: Result<bool, kernel::ErrorCode>,
5861
compare: &'static mut [u8],
@@ -98,9 +101,6 @@ impl<'a> digest::DigestData<'a, MD5_DIGEST_LEN> for Md5Adapter<'a> {
98101
),
99102
> {
100103
self.hash.add_mut_data(data)
101-
102-
// self.hash
103-
// .map_or(Err((ErrorCode::FAIL, data)), |hash| hash.add_mut_data(data))
104104
}
105105

106106
fn clear_data(&self) {
@@ -128,9 +128,6 @@ impl<'a> digest::DigestHash<'a, MD5_DIGEST_LEN> for Md5Adapter<'a> {
128128
let correct_buf: &'static mut [u8; MD5_DIGEST_LEN] = buf.try_into().unwrap();
129129
(e, correct_buf)
130130
})
131-
132-
// self.hash
133-
// .map(|hash| hash.run(digest).inspect_err(|(e, buf)| {}))
134131
}
135132
}
136133

@@ -157,12 +154,6 @@ impl<'a> digest::DigestVerify<'a, MD5_DIGEST_LEN> for Md5Adapter<'a> {
157154
let correct_buf: &'static mut [u8; MD5_DIGEST_LEN] = buf.try_into().unwrap();
158155
(e, correct_buf)
159156
})
160-
161-
// self.hash.verify(compare).map_err(|(error, buf)| {
162-
// // terrible
163-
// let correct_buf: &'static mut [u8; 32] = buf.try_into().unwrap();
164-
// (error, correct_buf)
165-
// })
166157
}
167158
}
168159

0 commit comments

Comments
 (0)