@@ -31,7 +31,7 @@ macro_rules! fsb_impl {
3131 fn update_blocks( & mut self , blocks: & [ Block <Self >] ) {
3232 self . blocks_len += blocks. len( ) as u64 ;
3333 for block in blocks {
34- Self :: compress( & mut self . state, Self :: convert ( block) ) ;
34+ Self :: compress( & mut self . state, block) ;
3535 }
3636 }
3737 }
@@ -42,7 +42,7 @@ macro_rules! fsb_impl {
4242 let block_bytes = self . blocks_len * Self :: BlockSize :: U64 ;
4343 let bit_len = 8 * ( block_bytes + buffer. get_pos( ) as u64 ) ;
4444 let mut h = self . state;
45- buffer. len64_padding_be( bit_len, |b| Self :: compress( & mut h, Self :: convert ( b ) ) ) ;
45+ buffer. len64_padding_be( bit_len, |b| Self :: compress( & mut h, b ) ) ;
4646
4747 let res = whirlpool:: Whirlpool :: digest( & h[ ..] ) ;
4848 let n = out. len( ) ;
@@ -111,7 +111,7 @@ macro_rules! fsb_impl {
111111 /// $W_i = i \times (n / w) + IV_i + M_i \times 2^{r / w}.
112112 fn computing_w_indices(
113113 input_vector: & [ u8 ; Self :: SIZE_OUTPUT_COMPRESS ] ,
114- message: & [ u8 ; Self :: SIZE_MSG_CHUNKS ] ,
114+ message: & Block < Self > ,
115115 ) -> [ u32 ; $w] {
116116 let mut wind: [ u32 ; $w] = [ 0 ; $w] ;
117117 let divided_message: [ u8 ; $w] = Self :: dividing_bits( message, ( $s - $r) / $w) ;
@@ -129,10 +129,7 @@ macro_rules! fsb_impl {
129129 /// This function servers the purpose presented in table 3, of breaking a bit array into
130130 /// batches of size not multiple of 8. Note that the IV will be broken always in size 8, which
131131 /// is quite convenient. Also, the only numbers we'll have to worry for are 5 and 6.
132- fn dividing_bits(
133- input_bits: & [ u8 ; Self :: SIZE_MSG_CHUNKS ] ,
134- size_batches: usize ,
135- ) -> [ u8 ; $w] {
132+ fn dividing_bits( input_bits: & Block <Self >, size_batches: usize ) -> [ u8 ; $w] {
136133 if size_batches != 5usize && size_batches != 6usize {
137134 panic!(
138135 "Expecting batches of size 5 or 6. Other values do not follow \
@@ -164,10 +161,7 @@ macro_rules! fsb_impl {
164161 }
165162
166163 /// This function outputs r bits, which are used to chain to the next iteration.
167- fn compress(
168- hash: & mut [ u8 ; Self :: SIZE_OUTPUT_COMPRESS ] ,
169- message_block: & [ u8 ; Self :: SIZE_MSG_CHUNKS ] ,
170- ) {
164+ fn compress( hash: & mut [ u8 ; Self :: SIZE_OUTPUT_COMPRESS ] , message_block: & Block <Self >) {
171165 let mut initial_vector = [ 0u8 ; Self :: SIZE_OUTPUT_COMPRESS ] ;
172166
173167 let w_indices = Self :: computing_w_indices( hash, message_block) ;
@@ -284,10 +278,6 @@ macro_rules! fsb_impl {
284278 }
285279 truncated
286280 }
287-
288- fn convert( block: & GenericArray <u8 , $blocksize>) -> & [ u8 ; Self :: SIZE_MSG_CHUNKS ] {
289- unsafe { & * ( block. as_ptr( ) as * const [ u8 ; Self :: SIZE_MSG_CHUNKS ] ) }
290- }
291281 }
292282 } ;
293283}
0 commit comments