File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,16 @@ impl DuplexSpongeInterface for KeccakDuplexSponge {
9797 self . squeeze_index = self . rate ;
9898
9999 while !input. is_empty ( ) {
100- if self . absorb_index < self . rate {
101- self . state . state [ self . absorb_index ] = input[ 0 ] ;
102- self . absorb_index += 1 ;
103- input = & input[ 1 ..] ;
104- } else {
100+ if self . absorb_index == self . rate {
105101 self . state . permute ( ) ;
106102 self . absorb_index = 0 ;
107103 }
104+
105+ let chunk_size = usize:: min ( self . rate - self . absorb_index , input. len ( ) ) ;
106+ let dest = & mut self . state . state [ self . absorb_index ..self . absorb_index + chunk_size] ;
107+ dest. copy_from_slice ( & input[ ..chunk_size] ) ;
108+ self . absorb_index += chunk_size;
109+ input = & input[ chunk_size..] ;
108110 }
109111 }
110112
You can’t perform that action at this time.
0 commit comments