File tree Expand file tree Collapse file tree 11 files changed +15
-15
lines changed
Expand file tree Collapse file tree 11 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ mod peripherals {
5555 I2C0 ,
5656 I2C1 ,
5757 RNG ,
58+ SHA ,
5859 SPI0 ,
5960 SPI1 ,
6061 SPI2 ,
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ mod peripherals {
3636 crate :: create_peripherals! {
3737 I2C0 ,
3838 RNG ,
39+ SHA ,
3940 SPI0 ,
4041 SPI1 ,
4142 SPI2 ,
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ mod peripherals {
4747 crate :: create_peripherals! {
4848 I2C0 ,
4949 RNG ,
50+ SHA ,
5051 SPI0 ,
5152 SPI1 ,
5253 SPI2 ,
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ mod peripherals {
5353 I2C0 ,
5454 I2C1 ,
5555 RNG ,
56+ SHA ,
5657 SPI0 ,
5758 SPI1 ,
5859 SPI2 ,
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ mod peripherals {
6464 I2C0 ,
6565 I2C1 ,
6666 RNG ,
67+ SHA ,
6768 SPI0 ,
6869 SPI1 ,
6970 SPI2 ,
Original file line number Diff line number Diff line change 11use core:: convert:: Infallible ;
22
3- use crate :: pac:: SHA ;
3+ use crate :: {
4+ peripheral:: { Peripheral , PeripheralRef } ,
5+ peripherals:: SHA ,
6+ } ;
47
58// All the hash algorithms introduced in FIPS PUB 180-4 Spec.
69// – SHA-1
@@ -157,9 +160,8 @@ impl AlignmentHelper {
157160 }
158161}
159162
160- #[ derive( Debug ) ]
161- pub struct Sha {
162- sha : SHA ,
163+ pub struct Sha < ' d > {
164+ sha : PeripheralRef < ' d , SHA > ,
163165 mode : ShaMode ,
164166 alignment_helper : AlignmentHelper ,
165167 cursor : usize ,
@@ -224,8 +226,10 @@ fn mode_as_bits(mode: ShaMode) -> u8 {
224226
225227// This implementation might fail after u32::MAX/8 bytes, to increase please see
226228// ::finish() length/self.cursor usage
227- impl Sha {
228- pub fn new ( sha : SHA , mode : ShaMode ) -> Self {
229+ impl < ' d > Sha < ' d > {
230+ pub fn new ( sha : impl Peripheral < P = SHA > + ' d , mode : ShaMode ) -> Self {
231+ crate :: into_ref!( sha) ;
232+
229233 // Setup SHA Mode
230234 #[ cfg( not( esp32) ) ]
231235 sha. mode
@@ -508,8 +512,4 @@ impl Sha {
508512
509513 Ok ( ( ) )
510514 }
511-
512- pub fn free ( self ) -> SHA {
513- self . sha
514- }
515515}
Original file line number Diff line number Diff line change @@ -66,7 +66,6 @@ fn main() -> ! {
6666 let hw_time = post_calc - pre_calc;
6767 println ! ( "Took {} cycles" , hw_time) ;
6868 println ! ( "SHA512 Hash output {:02x?}" , output) ;
69- let _usha = hasher. free ( ) ;
7069
7170 let pre_calc = xtensa_lx:: timer:: get_cycle_count ( ) ;
7271 let mut hasher = Sha512 :: new ( ) ;
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ fn main() -> ! {
6565 // let hw_time = post_calc - pre_calc;
6666 // println!("Took {} cycles", hw_time);
6767 println ! ( "SHA256 Hash output {:02x?}" , output) ;
68- let _usha = hasher. free ( ) ;
6968
7069 // let pre_calc = xtensa_lx::timer::get_cycle_count();
7170 let mut hasher = Sha256 :: new ( ) ;
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ fn main() -> ! {
6565 // let hw_time = post_calc - pre_calc;
6666 // println!("Took {} cycles", hw_time);
6767 println ! ( "SHA256 Hash output {:02x?}" , output) ;
68- let _usha = hasher. free ( ) ;
6968
7069 // let pre_calc = xtensa_lx::timer::get_cycle_count();
7170 let mut hasher = Sha256 :: new ( ) ;
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ fn main() -> ! {
6565 let hw_time = post_calc - pre_calc;
6666 println ! ( "Took {} cycles" , hw_time) ;
6767 println ! ( "SHA512 Hash output {:02x?}" , output) ;
68- let _usha = hasher. free ( ) ;
6968
7069 let pre_calc = xtensa_lx:: timer:: get_cycle_count ( ) ;
7170 let mut hasher = Sha512 :: new ( ) ;
You can’t perform that action at this time.
0 commit comments