@@ -201,7 +201,8 @@ mod tests {
201
201
extern crate alloc;
202
202
203
203
use super :: { super :: overlapping:: IndexError , * } ;
204
- use crate :: { error, test} ;
204
+ use crate :: error;
205
+ use crate :: testutil as test;
205
206
use alloc:: vec;
206
207
207
208
const MAX_ALIGNMENT_AND_OFFSET : ( usize , usize ) = ( 15 , 259 ) ;
@@ -252,38 +253,41 @@ mod tests {
252
253
// Reuse a buffer to avoid slowing down the tests with allocations.
253
254
let mut buf = vec ! [ 0u8 ; 1300 ] ;
254
255
255
- test:: run ( test_file ! ( "chacha_tests.txt" ) , move |section, test_case| {
256
- assert_eq ! ( section, "" ) ;
257
-
258
- let key = test_case. consume_bytes ( "Key" ) ;
259
- let key: & [ u8 ; KEY_LEN ] = key. as_slice ( ) . try_into ( ) ?;
260
- let key = Key :: new ( * key) ;
261
-
262
- let ctr = test_case. consume_usize ( "Ctr" ) ;
263
- let nonce = test_case. consume_bytes ( "Nonce" ) ;
264
- let input = test_case. consume_bytes ( "Input" ) ;
265
- let output = test_case. consume_bytes ( "Output" ) ;
266
-
267
- // Run the test case over all prefixes of the input because the
268
- // behavior of ChaCha20 implementation changes dependent on the
269
- // length of the input.
270
- for len in 0 ..=input. len ( ) {
271
- #[ allow( clippy:: cast_possible_truncation) ]
272
- chacha20_test_case_inner (
273
- & key,
274
- & nonce,
275
- ctr as u32 ,
276
- & input[ ..len] ,
277
- & output[ ..len] ,
278
- & mut buf,
279
- max_alignment_and_offset,
280
- cpu,
281
- & f,
282
- ) ;
283
- }
256
+ test:: run (
257
+ test_vector_file ! ( "chacha_tests.txt" ) ,
258
+ move |section, test_case| {
259
+ assert_eq ! ( section, "" ) ;
260
+
261
+ let key = test_case. consume_bytes ( "Key" ) ;
262
+ let key: & [ u8 ; KEY_LEN ] = key. as_slice ( ) . try_into ( ) ?;
263
+ let key = Key :: new ( * key) ;
264
+
265
+ let ctr = test_case. consume_usize ( "Ctr" ) ;
266
+ let nonce = test_case. consume_bytes ( "Nonce" ) ;
267
+ let input = test_case. consume_bytes ( "Input" ) ;
268
+ let output = test_case. consume_bytes ( "Output" ) ;
269
+
270
+ // Run the test case over all prefixes of the input because the
271
+ // behavior of ChaCha20 implementation changes dependent on the
272
+ // length of the input.
273
+ for len in 0 ..=input. len ( ) {
274
+ #[ allow( clippy:: cast_possible_truncation) ]
275
+ chacha20_test_case_inner (
276
+ & key,
277
+ & nonce,
278
+ ctr as u32 ,
279
+ & input[ ..len] ,
280
+ & output[ ..len] ,
281
+ & mut buf,
282
+ max_alignment_and_offset,
283
+ cpu,
284
+ & f,
285
+ ) ;
286
+ }
284
287
285
- Ok ( ( ) )
286
- } ) ;
288
+ Ok ( ( ) )
289
+ } ,
290
+ ) ;
287
291
}
288
292
289
293
fn chacha20_test_case_inner (
0 commit comments