@@ -14,7 +14,7 @@ use ppv_lite86::{dispatch, dispatch_light128};
14
14
pub use ppv_lite86:: Machine ;
15
15
use ppv_lite86:: { vec128_storage, ArithOps , BitOps32 , LaneWords4 , MultiLane , StoreBytes , Vec4 } ;
16
16
17
- pub ( crate ) const BLOCK : usize = 64 ;
17
+ pub ( crate ) const BLOCK : usize = 16 ;
18
18
pub ( crate ) const BLOCK64 : u64 = BLOCK as u64 ;
19
19
const LOG2_BUFBLOCKS : u64 = 2 ;
20
20
const BUFBLOCKS : u64 = 1 << LOG2_BUFBLOCKS ;
@@ -81,7 +81,7 @@ impl ChaCha {
81
81
82
82
/// Produce 4 blocks of output, advancing the state
83
83
#[ inline( always) ]
84
- pub fn refill4 ( & mut self , drounds : u32 , out : & mut [ u8 ; BUFSZ ] ) {
84
+ pub fn refill4 ( & mut self , drounds : u32 , out : & mut [ u32 ; BUFSZ ] ) {
85
85
refill_wide ( self , drounds, out)
86
86
}
87
87
@@ -114,7 +114,7 @@ impl ChaCha {
114
114
#[ allow( clippy:: many_single_char_names) ]
115
115
#[ inline( always) ]
116
116
fn refill_wide_impl < Mach : Machine > (
117
- m : Mach , state : & mut ChaCha , drounds : u32 , out : & mut [ u8 ; BUFSZ ] ,
117
+ m : Mach , state : & mut ChaCha , drounds : u32 , out : & mut [ u32 ; BUFSZ ] ,
118
118
) {
119
119
let k = m. vec ( [ 0x6170_7865 , 0x3320_646e , 0x7962_2d32 , 0x6b20_6574 ] ) ;
120
120
let mut pos = state. pos64 ( m) ;
@@ -159,17 +159,17 @@ fn refill_wide_impl<Mach: Machine>(
159
159
let sc = m. unpack ( state. c ) ;
160
160
let sd = [ m. unpack ( state. d ) , d1, d2, d3] ;
161
161
state. d = d4. into ( ) ;
162
- let mut words = out. chunks_exact_mut ( 16 ) ;
162
+ let mut words = out. chunks_exact_mut ( 4 ) ;
163
163
for ( ( ( ( & a, & b) , & c) , & d) , & sd) in a. iter ( ) . zip ( & b) . zip ( & c) . zip ( & d) . zip ( & sd) {
164
- ( a + k) . write_le ( words . next ( ) . unwrap ( ) ) ;
165
- ( b + sb) . write_le ( words . next ( ) . unwrap ( ) ) ;
166
- ( c + sc) . write_le ( words . next ( ) . unwrap ( ) ) ;
167
- ( d + sd) . write_le ( words . next ( ) . unwrap ( ) ) ;
164
+ words . next ( ) . unwrap ( ) . copy_from_slice ( & ( a + k) . to_lanes ( ) ) ;
165
+ words . next ( ) . unwrap ( ) . copy_from_slice ( & ( b + sb) . to_lanes ( ) ) ;
166
+ words . next ( ) . unwrap ( ) . copy_from_slice ( & ( c + sc) . to_lanes ( ) ) ;
167
+ words . next ( ) . unwrap ( ) . copy_from_slice ( & ( d + sd) . to_lanes ( ) ) ;
168
168
}
169
169
}
170
170
171
171
dispatch ! ( m, Mach , {
172
- fn refill_wide( state: & mut ChaCha , drounds: u32 , out: & mut [ u8 ; BUFSZ ] ) {
172
+ fn refill_wide( state: & mut ChaCha , drounds: u32 , out: & mut [ u32 ; BUFSZ ] ) {
173
173
refill_wide_impl( m, state, drounds, out) ;
174
174
}
175
175
} ) ;
0 commit comments