11use crate :: { consts, sha256:: compress256, sha512:: compress512} ;
22use core:: { convert:: TryInto , fmt, slice:: from_ref} ;
33use digest:: {
4- array:: Array ,
54 block_buffer:: Eager ,
65 core_api:: {
76 AlgorithmName , Block , BlockSizeUser , Buffer , BufferKindUser , OutputSizeUser , TruncSide ,
@@ -39,7 +38,6 @@ impl UpdateCore for Sha256VarCore {
3938 #[ inline]
4039 fn update_blocks ( & mut self , blocks : & [ Block < Self > ] ) {
4140 self . block_len += blocks. len ( ) as u64 ;
42- let blocks = Array :: cast_slice_to_core ( blocks) ;
4341 compress256 ( & mut self . state , blocks) ;
4442 }
4543}
@@ -66,7 +64,7 @@ impl VariableOutputCore for Sha256VarCore {
6664 fn finalize_variable_core ( & mut self , buffer : & mut Buffer < Self > , out : & mut Output < Self > ) {
6765 let bs = Self :: BlockSize :: U64 ;
6866 let bit_len = 8 * ( buffer. get_pos ( ) as u64 + bs * self . block_len ) ;
69- buffer. len64_padding_be ( bit_len, |b| compress256 ( & mut self . state , from_ref ( & b . 0 ) ) ) ;
67+ buffer. len64_padding_be ( bit_len, |b| compress256 ( & mut self . state , from_ref ( b ) ) ) ;
7068
7169 for ( chunk, v) in out. chunks_exact_mut ( 4 ) . zip ( self . state . iter ( ) ) {
7270 chunk. copy_from_slice ( & v. to_be_bytes ( ) ) ;
@@ -155,7 +153,6 @@ impl UpdateCore for Sha512VarCore {
155153 #[ inline]
156154 fn update_blocks ( & mut self , blocks : & [ Block < Self > ] ) {
157155 self . block_len += blocks. len ( ) as u128 ;
158- let blocks = Array :: cast_slice_to_core ( blocks) ;
159156 compress512 ( & mut self . state , blocks) ;
160157 }
161158}
@@ -184,7 +181,7 @@ impl VariableOutputCore for Sha512VarCore {
184181 fn finalize_variable_core ( & mut self , buffer : & mut Buffer < Self > , out : & mut Output < Self > ) {
185182 let bs = Self :: BlockSize :: U64 as u128 ;
186183 let bit_len = 8 * ( buffer. get_pos ( ) as u128 + bs * self . block_len ) ;
187- buffer. len128_padding_be ( bit_len, |b| compress512 ( & mut self . state , from_ref ( & b . 0 ) ) ) ;
184+ buffer. len128_padding_be ( bit_len, |b| compress512 ( & mut self . state , from_ref ( b ) ) ) ;
188185
189186 for ( chunk, v) in out. chunks_exact_mut ( 8 ) . zip ( self . state . iter ( ) ) {
190187 chunk. copy_from_slice ( & v. to_be_bytes ( ) ) ;
0 commit comments