impl $name { /// Creates a new TurboSHAKE instance with the given domain separation. /// Note that the domain separation needs to be a byte with a value in /// the range [0x01, . . . , 0x7F] pubfn new(domain_separation: u8) -> Self {
assert!((0x01..=0x7F).contains(&domain_separation)); Self {
domain_separation,
state: Sha3State::new(TURBO_SHAKE_ROUND_COUNT),
}
}
}
impl HashMarker for $name {}
impl BlockSizeUser for $name { type BlockSize = $rate;
}
impl BufferKindUser for $name { type BufferKind = Eager;
}
impl UpdateCore for $name { #[inline] fn update_blocks(&mutself, blocks: &[Block<Self>]) { for block in blocks { self.state.absorb_block(block)
}
}
}
impl ExtendableOutputCore for $name { type ReaderCore = $reader;
#[inline] fn finalize_xof_core(&mutself, buffer: &>mut Buffer<Self>) -> Self::ReaderCore { let pos = buffer.get_pos(); let block = buffer.pad_with_zeros();
block[pos] = self.domain_separation; let n = block.len();
block[n - 1] |= 0x80;
impl $name { /// Creates a new CSHAKE instance with the given customization. pubfn new(customization: &[u8]) -> Self { Self::new_with_function_name(&[], customization)
}
/// Creates a new CSHAKE instance with the given function name and customization. /// Note that the function name is intended for use by NIST and should only be set to /// values defined by NIST. You probably don't need to use this function. pubfn new_with_function_name(function_name: &[u8], customization: &[u8]) -> Self { letmut state = Sha3State::default(); if function_name.is_empty() && customization.is_empty() { returnSelf {
padding: $shake_pad,
state: state.clone(), #[cfg(feature = "reset")]
initial_state: state,
};
}
letmut buffer = Buffer::<Self>::default(); letmut b = [0u8; 9];
buffer.digest_blocks(left_encode($rate::to_u64(), &mut b), |blocks| { for block in blocks {
state.absorb_block(block);
}
});
buffer.digest_blocks(
left_encode((function_name.len() * 8) as u64, &mut b),
|blocks| { for block in blocks {
state.absorb_block(block);
}
},
);
buffer.digest_blocks(function_name, |blocks| { for block in blocks {
state.absorb_block(block);
}
});
buffer.digest_blocks(
left_encode((customization.len() * 8) as u64, &mut b),
|blocks| { for block in blocks {
state.absorb_block(block);
}
},
);
buffer.digest_blocks(customization, |blocks| { for block in blocks {
state.absorb_block(block);
}
});
state.absorb_block(buffer.pad_with_zeros());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.