@@ -240,20 +240,36 @@ macro_rules! impl_turbo_shake {
240
240
#[ allow( non_camel_case_types) ]
241
241
pub struct $name {
242
242
domain_separation: u8 ,
243
+ round_count: usize ,
243
244
state: Sha3State ,
244
245
}
245
246
246
247
impl $name {
247
248
/// Creates a new TurboSHAKE instance with the given domain separation.
248
249
/// Note that the domain separation needs to be a byte with a value in
249
- /// the range [0x01, . . . , 0x7F]
250
+ /// the range [0x01, . . . , 0x7F].
250
251
pub fn new( domain_separation: u8 ) -> Self {
251
252
assert!( ( 0x01 ..=0x7F ) . contains( & domain_separation) ) ;
252
253
Self {
253
254
domain_separation,
255
+ round_count: TURBO_SHAKE_ROUND_COUNT ,
254
256
state: Sha3State :: new( TURBO_SHAKE_ROUND_COUNT ) ,
255
257
}
256
258
}
259
+
260
+ /// Creates a new TurboSHAKE instance with the given domain separation
261
+ /// and round_count.
262
+ /// This is a low-level "hazmat" API.
263
+ /// Note that the domain separation needs to be a byte with a value in
264
+ /// the range [0x01, . . . , 0x7F].
265
+ pub fn new_with_round_count( domain_separation: u8 , round_count: usize ) -> Self {
266
+ assert!( ( 0x01 ..=0x7F ) . contains( & domain_separation) ) ;
267
+ Self {
268
+ domain_separation,
269
+ round_count,
270
+ state: Sha3State :: new( round_count) ,
271
+ }
272
+ }
257
273
}
258
274
259
275
impl HashMarker for $name { }
@@ -296,7 +312,7 @@ macro_rules! impl_turbo_shake {
296
312
impl Reset for $name {
297
313
#[ inline]
298
314
fn reset( & mut self ) {
299
- * self = Self :: new ( self . domain_separation) ;
315
+ * self = Self :: new_with_round_count ( self . domain_separation, self . round_count ) ;
300
316
}
301
317
}
302
318
0 commit comments