@@ -7,7 +7,9 @@ use cipher::{
7
7
StreamCipherSeekCore , StreamClosure ,
8
8
} ;
9
9
10
- use crate :: { variants:: Ietf , ChaChaCore , Rounds , CONSTANTS , R12 , R20 , R8 , STATE_WORDS } ;
10
+ use crate :: {
11
+ quarter_round, variants:: Ietf , ChaChaCore , Rounds , CONSTANTS , R12 , R20 , R8 , STATE_WORDS ,
12
+ } ;
11
13
12
14
#[ cfg( feature = "zeroize" ) ]
13
15
use zeroize:: ZeroizeOnDrop ;
@@ -151,26 +153,6 @@ pub fn hchacha<R: Rounds>(key: &Key, input: &Array<u8, U16>) -> Array<u8, U32> {
151
153
output
152
154
}
153
155
154
- /// The ChaCha20 quarter round function
155
- // for simplicity this function is copied from the software backend
156
- fn quarter_round ( a : usize , b : usize , c : usize , d : usize , state : & mut [ u32 ; STATE_WORDS ] ) {
157
- state[ a] = state[ a] . wrapping_add ( state[ b] ) ;
158
- state[ d] ^= state[ a] ;
159
- state[ d] = state[ d] . rotate_left ( 16 ) ;
160
-
161
- state[ c] = state[ c] . wrapping_add ( state[ d] ) ;
162
- state[ b] ^= state[ c] ;
163
- state[ b] = state[ b] . rotate_left ( 12 ) ;
164
-
165
- state[ a] = state[ a] . wrapping_add ( state[ b] ) ;
166
- state[ d] ^= state[ a] ;
167
- state[ d] = state[ d] . rotate_left ( 8 ) ;
168
-
169
- state[ c] = state[ c] . wrapping_add ( state[ d] ) ;
170
- state[ b] ^= state[ c] ;
171
- state[ b] = state[ b] . rotate_left ( 7 ) ;
172
- }
173
-
174
156
#[ cfg( test) ]
175
157
mod hchacha20_tests {
176
158
use super :: * ;
0 commit comments