@@ -15,6 +15,7 @@ use core::{fmt, slice::from_ref};
1515#[ cfg( feature = "oid" ) ]
1616use digest:: const_oid:: { AssociatedOid , ObjectIdentifier } ;
1717use digest:: {
18+ array:: ArrayOps ,
1819 block_buffer:: Eager ,
1920 core_api:: {
2021 AlgorithmName , Block , BlockSizeUser , Buffer , BufferKindUser , CoreWrapper , FixedOutputCore ,
@@ -49,7 +50,8 @@ impl UpdateCore for Md5Core {
4950 #[ inline]
5051 fn update_blocks ( & mut self , blocks : & [ Block < Self > ] ) {
5152 self . block_len = self . block_len . wrapping_add ( blocks. len ( ) as u64 ) ;
52- compress:: compress ( & mut self . state , convert ( blocks) )
53+ let blocks = ArrayOps :: cast_slice_to_core ( blocks) ;
54+ compress:: compress ( & mut self . state , blocks)
5355 }
5456}
5557
@@ -62,9 +64,7 @@ impl FixedOutputCore for Md5Core {
6264 . wrapping_add ( buffer. get_pos ( ) as u64 )
6365 . wrapping_mul ( 8 ) ;
6466 let mut s = self . state ;
65- buffer. len64_padding_le ( bit_len, |b| {
66- compress:: compress ( & mut s, convert ( from_ref ( b) ) )
67- } ) ;
67+ buffer. len64_padding_le ( bit_len, |b| compress:: compress ( & mut s, from_ref ( & b. 0 ) ) ) ;
6868 for ( chunk, v) in out. chunks_exact_mut ( 4 ) . zip ( s. iter ( ) ) {
6969 chunk. copy_from_slice ( & v. to_le_bytes ( ) ) ;
7070 }
@@ -108,13 +108,3 @@ impl AssociatedOid for Md5Core {
108108
109109/// MD5 hasher state.
110110pub type Md5 = CoreWrapper < Md5Core > ;
111-
112- const BLOCK_SIZE : usize = <Md5Core as BlockSizeUser >:: BlockSize :: USIZE ;
113-
114- #[ inline( always) ]
115- fn convert ( blocks : & [ Block < Md5Core > ] ) -> & [ [ u8 ; BLOCK_SIZE ] ] {
116- // SAFETY: Array<u8, U64> and [u8; 64] have
117- // exactly the same memory layout
118- let p = blocks. as_ptr ( ) as * const [ u8 ; BLOCK_SIZE ] ;
119- unsafe { core:: slice:: from_raw_parts ( p, blocks. len ( ) ) }
120- }
0 commit comments