@@ -7,7 +7,9 @@ use cipher::{
77 StreamCipherSeekCore , StreamClosure ,
88} ;
99
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+ } ;
1113
1214#[ cfg( feature = "zeroize" ) ]
1315use zeroize:: ZeroizeOnDrop ;
@@ -151,26 +153,6 @@ pub fn hchacha<R: Rounds>(key: &Key, input: &Array<u8, U16>) -> Array<u8, U32> {
151153 output
152154}
153155
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-
174156#[ cfg( test) ]
175157mod hchacha20_tests {
176158 use super :: * ;
0 commit comments