mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-12 15:49:22 -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
|
/// Print a hash literal for pasting into the Rosenpass source code
|
||||||
fn print_literal(path: &[&str], shake_or_blake: KeyedHash) -> Result<()> {
|
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 (last, prefix) = path.split_last().context("developer error!")?;
|
||||||
let var_name = last.to_shouty_snake_case();
|
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() {
|
for n in prefix.iter() {
|
||||||
print!("{n} -> ");
|
print!("{n} -> ");
|
||||||
}
|
}
|
||||||
@@ -95,6 +95,7 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
println!("type RawMsgType = u128;");
|
println!("type RawMsgType = u128;");
|
||||||
println!();
|
println!();
|
||||||
tree.gen_code(EitherShakeOrBlake::Left(SHAKE256Core))?;
|
tree.gen_code(KeyedHash::keyed_shake256())?;
|
||||||
tree.gen_code(EitherShakeOrBlake::Right(Blake2bCore))
|
println!();
|
||||||
|
tree.gen_code(KeyedHash::incorrect_hmac_blake2b())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ fn test_gen_ipc_msg_types() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
// Smoke tests only
|
// Smoke tests only
|
||||||
assert!(stdout.contains("type RawMsgType = u128;"));
|
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\"));"));
|
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
|
// TODO: Also test SHAKE256 here
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user