@@ -11,10 +11,9 @@ pub use digest::{self, Digest};
1111
1212use core:: { convert:: TryInto , fmt, slice:: from_ref} ;
1313use digest:: {
14- array:: Array ,
1514 block_buffer:: Eager ,
1615 core_api:: {
17- AlgorithmName , Block , BlockSizeUser , Buffer , BufferKindUser , CoreWrapper , FixedOutputCore ,
16+ AlgorithmName , BlockSizeUser , Buffer , BufferKindUser , CoreWrapper , FixedOutputCore ,
1817 OutputSizeUser , Reset , UpdateCore ,
1918 } ,
2019 crypto_common:: hazmat:: { DeserializeStateError , SerializableState , SerializedState } ,
@@ -34,6 +33,9 @@ pub use compress::compress;
3433const STATE_LEN : usize = 5 ;
3534const BLOCK_SIZE : usize = <Sha1Core as BlockSizeUser >:: BlockSize :: USIZE ;
3635
36+ /// Block for SHA-1
37+ pub type Block = digest:: block_buffer:: Block < Sha1Core > ;
38+
3739/// Core SHA-1 hasher state.
3840#[ derive( Clone ) ]
3941pub struct Sha1Core {
@@ -60,9 +62,8 @@ impl OutputSizeUser for Sha1Core {
6062
6163impl UpdateCore for Sha1Core {
6264 #[ inline]
63- fn update_blocks ( & mut self , blocks : & [ Block < Self > ] ) {
65+ fn update_blocks ( & mut self , blocks : & [ Block ] ) {
6466 self . block_len += blocks. len ( ) as u64 ;
65- let blocks = Array :: cast_slice_to_core ( blocks) ;
6667 compress ( & mut self . h , blocks) ;
6768 }
6869}
@@ -74,7 +75,7 @@ impl FixedOutputCore for Sha1Core {
7475 let bit_len = 8 * ( buffer. get_pos ( ) as u64 + bs * self . block_len ) ;
7576
7677 let mut h = self . h ;
77- buffer. len64_padding_be ( bit_len, |b| compress ( & mut h, from_ref ( & b . 0 ) ) ) ;
78+ buffer. len64_padding_be ( bit_len, |b| compress ( & mut h, from_ref ( b ) ) ) ;
7879 for ( chunk, v) in out. chunks_exact_mut ( 4 ) . zip ( h. iter ( ) ) {
7980 chunk. copy_from_slice ( & v. to_be_bytes ( ) ) ;
8081 }
0 commit comments