1
1
use crate :: { ParBlocks , ParBlocksSizeUser , StreamCipherError } ;
2
2
use crypto_common:: {
3
- array:: { Array , ArraySize } ,
3
+ array:: { slice_as_chunks_mut , Array } ,
4
4
typenum:: Unsigned ,
5
5
Block , BlockSizeUser , BlockSizes ,
6
6
} ;
@@ -190,27 +190,6 @@ macro_rules! impl_counter {
190
190
191
191
impl_counter ! { u32 u64 u128 }
192
192
193
- /// Partition buffer into 2 parts: buffer of arrays and tail.
194
- ///
195
- /// In case if `N` is less or equal to 1, buffer of arrays has length
196
- /// of zero and tail is equal to `self`.
197
- #[ inline]
198
- fn into_chunks < T , N : ArraySize > ( buf : & mut [ T ] ) -> ( & mut [ Array < T , N > ] , & mut [ T ] ) {
199
- use core:: slice;
200
- if N :: USIZE <= 1 {
201
- return ( & mut [ ] , buf) ;
202
- }
203
- let chunks_len = buf. len ( ) / N :: USIZE ;
204
- let tail_pos = N :: USIZE * chunks_len;
205
- let tail_len = buf. len ( ) - tail_pos;
206
- unsafe {
207
- let ptr = buf. as_mut_ptr ( ) ;
208
- let chunks = slice:: from_raw_parts_mut ( ptr as * mut Array < T , N > , chunks_len) ;
209
- let tail = slice:: from_raw_parts_mut ( ptr. add ( tail_pos) , tail_len) ;
210
- ( chunks, tail)
211
- }
212
- }
213
-
214
193
struct WriteBlockCtx < ' a , BS : BlockSizes > {
215
194
block : & ' a mut Block < Self > ,
216
195
}
@@ -234,7 +213,7 @@ impl<'a, BS: BlockSizes> StreamClosure for WriteBlocksCtx<'a, BS> {
234
213
#[ inline( always) ]
235
214
fn call < B : StreamBackend < BlockSize = BS > > ( self , backend : & mut B ) {
236
215
if B :: ParBlocksSize :: USIZE > 1 {
237
- let ( chunks, tail) = into_chunks :: < _ , B :: ParBlocksSize > ( self . blocks ) ;
216
+ let ( chunks, tail) = slice_as_chunks_mut ( self . blocks ) ;
238
217
for chunk in chunks {
239
218
backend. gen_par_ks_blocks ( chunk) ;
240
219
}
0 commit comments