A whimsical STROBE based encryption protocol
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Get clippied

Tidy up the herding kat's harness code to satisfy clippy and not get whipped

+7 -11
+7 -11
src/herding_kats/harness.rs
··· 2 2 3 3 use std::{boxed::Box, string::String, vec::Vec}; 4 4 5 - use hex; 6 5 use serde::{Deserialize, Deserializer, de}; 7 6 8 7 use crate::strobe::{SecurityParameter, StrobeState}; ··· 38 37 Length(usize), 39 38 } 40 39 40 + /// A boxed closure type, representing the operation to be executed by our Kat. 41 + type KatClosure<'s> = Box<dyn for<'a> Fn(&mut StrobeState, DataOrLength<'a>, bool) + 's>; 42 + 41 43 // Given the name of the operation and meta flag, returns a closure that performs this operation. 42 - // The types are kind of a mess, because the input and output types of the closure have to fit all 43 - // possible STROBE operations. 44 - fn get_operation<'s>( 45 - op_name: &'s str, 46 - meta: bool, 47 - ) -> Box<dyn for<'a> Fn(&mut StrobeState, DataOrLength<'a>, bool) + 's> { 44 + // Returns a boxed closure, because the input and output types of the closure have to fit all 45 + // possible STROBE operations and it is easier to erase that via boxing. 46 + fn get_operation<'s>(op_name: &'s str, meta: bool) -> KatClosure<'s> { 48 47 let f = move |s: &mut StrobeState, dol: DataOrLength, more: bool| { 49 48 let data = match dol { 50 49 DataOrLength::Length(len) => { ··· 153 152 154 153 fn security_param_from_bits<'de, D: Deserializer<'de>>( 155 154 deserializer: D, 156 - ) -> Result<SecurityParameter, D::Error> 157 - where 158 - D: Deserializer<'de>, 159 - { 155 + ) -> Result<SecurityParameter, D::Error> { 160 156 match u64::deserialize(deserializer)? { 161 157 128 => Ok(SecurityParameter::B128), 162 158 256 => Ok(SecurityParameter::B256),