mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-05 20:40:02 -08:00
test(rosenpass): Complete support for SHAKE256 in gen-ipc-msg-types.rs
This commit is contained in:
committed by
Jan Winkelmann (keks)
parent
3205f8c572
commit
5e6c85d73d
@@ -15,11 +15,11 @@ fn calculate_hash_value(hd: HashDomain, values: &[&str]) -> Result<[u8; KEY_LEN]
|
||||
|
||||
/// Print a hash literal for pasting into the Rosenpass source code
|
||||
fn print_literal(path: &[&str], shake_or_blake: KeyedHash) -> Result<()> {
|
||||
let val = calculate_hash_value(HashDomain::zero(shake_or_blake), path)?;
|
||||
let val = calculate_hash_value(HashDomain::zero(shake_or_blake.clone()), path)?;
|
||||
let (last, prefix) = path.split_last().context("developer error!")?;
|
||||
let var_name = last.to_shouty_snake_case();
|
||||
|
||||
print!("// hash domain hash of: ");
|
||||
print!("// hash domain hash with hash {} of: ", shake_or_blake);
|
||||
for n in prefix.iter() {
|
||||
print!("{n} -> ");
|
||||
}
|
||||
@@ -95,6 +95,7 @@ fn main() -> Result<()> {
|
||||
|
||||
println!("type RawMsgType = u128;");
|
||||
println!();
|
||||
tree.gen_code(EitherShakeOrBlake::Left(SHAKE256Core))?;
|
||||
tree.gen_code(EitherShakeOrBlake::Right(Blake2bCore))
|
||||
tree.gen_code(KeyedHash::keyed_shake256())?;
|
||||
println!();
|
||||
tree.gen_code(KeyedHash::incorrect_hmac_blake2b())
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ fn test_gen_ipc_msg_types() -> anyhow::Result<()> {
|
||||
|
||||
// Smoke tests only
|
||||
assert!(stdout.contains("type RawMsgType = u128;"));
|
||||
// For Blake2b:
|
||||
assert!(stdout.contains("const SUPPLY_KEYPAIR_RESPONSE : RawMsgType = RawMsgType::from_le_bytes(hex!(\"f2dc 49bd e261 5f10 40b7 3c16 ec61 edb9\"));"));
|
||||
// For SHAKE256:
|
||||
assert!(stdout.contains("const SUPPLY_KEYPAIR_RESPONSE : RawMsgType = RawMsgType::from_le_bytes(hex!(\"ff80 3886 68a4 47ce 2ae6 0915 0972 682f\"))"));
|
||||
|
||||
// TODO: Also test SHAKE256 here
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user