// loadu/storeu support unaligned loads/stores
loadu/storeu support unaligned loads/stores
loadu / storeu support unaligned loads / stores
pub fn apply_keystream(&self, counter: u64, output: &mut [u8]) {
        debug_assert_eq!(output.len(), BUFFER_SIZE);
        unsafe {
            let state = State {
                a: self.v0,
                b: self.v1,
                c: self.v2,
                d: iv_setup(self.iv, counter),
            };
            let state = self.rounds(state);
            for i in 0..BLOCKS {
                for (chunk, a) in output[i * BLOCK_SIZE..(i + 1) * BLOCK_SIZE]
                    .chunks_mut(0x10)
                    .zip(
                        [state.a, state.b, state.c, state.d]
                            .iter()
                            .map(|s| s.blocks[i]),
                    )
                {
                    let b = _mm_loadu_si128(chunk.as_ptr() as *const __m128i);
                    let out = _mm_xor_si128(a, b);
                    _mm_storeu_si128(chunk.as_mut_ptr() as *mut __m128i, out);
                }
            }
        }
    }
pub fn apply_keystream ( & self , counter : u64 , output : & mut [ u8 ] ) { debug_assert_eq ! ( output len ( ) BUFFER_SIZE ) ; unsafe { let state = State { a : self . v0 , b : self . v1 , c : self . v2 , d : iv_setup ( self . iv , counter ) , } ; let state = self . rounds ( state ) ; for i in 0 .. BLOCKS { for ( chunk , a ) in output [ i * BLOCK_SIZE .. ( i + 1 ) * BLOCK_SIZE ] . chunks_mut ( 0x10 ) . zip ( [ state . a , state . b , state . c , state . d ] . iter ( ) . map ( | s | s . blocks [ i ] ) , ) { let b = _mm_loadu_si128 ( chunk . as_ptr ( ) as * const __m128i ) ; let out = _mm_xor_si128 ( a , b ) ; _mm_storeu_si128 ( chunk . as_mut_ptr ( ) as * mut __m128i , out ) ; } } } }
loadu/storeu support unaligned loads/stores
loadu / storeu support unaligned loads / stores
&self
counter
u64
output
&mut [u8]