From b21a95dbbd29a90a13e966fb19c8965d10d57072 Mon Sep 17 00:00:00 2001 From: David Niehues <7667041+DavidNiehues@users.noreply.github.com> Date: Thu, 20 Mar 2025 17:46:41 +0100 Subject: [PATCH] doc(rp+rosenpass+ciphers+cipher-traits): Apply cargo fmt formatting --- cipher-traits/src/primitives/keyed_hash.rs | 2 ++ ciphers/src/lib.rs | 1 - rosenpass/src/protocol/protocol.rs | 8 +++----- rosenpass/tests/gen-ipc-msg-types.rs | 2 +- rp/src/exchange.rs | 6 +++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cipher-traits/src/primitives/keyed_hash.rs b/cipher-traits/src/primitives/keyed_hash.rs index d616cb2..da10880 100644 --- a/cipher-traits/src/primitives/keyed_hash.rs +++ b/cipher-traits/src/primitives/keyed_hash.rs @@ -66,10 +66,12 @@ where Static::keyed_hash(key, data, out) } + /// Returns the key length of the keyed hash function. pub const fn key_len(self) -> usize { Self::KEY_LEN } + /// Returns the hash length of the keyed hash function. pub const fn hash_len(self) -> usize { Self::HASH_LEN } diff --git a/ciphers/src/lib.rs b/ciphers/src/lib.rs index 6a584e3..aca6dbf 100644 --- a/ciphers/src/lib.rs +++ b/ciphers/src/lib.rs @@ -1,4 +1,3 @@ -use rosenpass_cipher_traits::primitives::Aead as _; use static_assertions::const_assert; pub mod subtle; diff --git a/rosenpass/src/protocol/protocol.rs b/rosenpass/src/protocol/protocol.rs index 9aeec85..8a5edd3 100644 --- a/rosenpass/src/protocol/protocol.rs +++ b/rosenpass/src/protocol/protocol.rs @@ -718,13 +718,11 @@ impl KnownResponseHasher { /// Panics in case of a problem with this underlying hash function pub fn hash(&self, msg: &Envelope) -> KnownResponseHash { let data = &msg.as_bytes()[span_of!(Envelope, msg_type..cookie)]; - // TODO: the hash choice hasn't been propagated here so far - // TODO: FIX DOCU AND OUT-COMMENTED_CODE_BELOW - let hash_choice = - rosenpass_ciphers::subtle::keyed_hash::KeyedHash::incorrect_hmac_blake2b(); + // This function is only used internally and results are not propagated + // to outside the peer. Thus, it uses SHAKE256 exclusively. let mut hash = [0; 32]; - hash_choice + KeyedHash::keyed_shake256() .keyed_hash(self.key.secret(), data, &mut hash) .unwrap(); Public::from_slice(&hash[0..16]) // truncate to 16 bytes diff --git a/rosenpass/tests/gen-ipc-msg-types.rs b/rosenpass/tests/gen-ipc-msg-types.rs index 1b46144..6b117df 100644 --- a/rosenpass/tests/gen-ipc-msg-types.rs +++ b/rosenpass/tests/gen-ipc-msg-types.rs @@ -1,4 +1,4 @@ -use std::{process::Command}; +use std::process::Command; #[test] fn test_gen_ipc_msg_types() -> anyhow::Result<()> { diff --git a/rp/src/exchange.rs b/rp/src/exchange.rs index 838824b..32b09ac 100644 --- a/rp/src/exchange.rs +++ b/rp/src/exchange.rs @@ -6,10 +6,10 @@ use std::pin::Pin; use std::sync::Arc; use std::{net::SocketAddr, path::PathBuf, process::Command}; -use anyhow::Result; -use rosenpass::config::ProtocolVersion; #[cfg(any(target_os = "linux", target_os = "freebsd"))] use crate::key::WG_B64_LEN; +use anyhow::Result; +use rosenpass::config::ProtocolVersion; /// Used to define a peer for the rosenpass connection that consists of /// a directory for storing public keys and optionally an IP address and port of the endpoint, @@ -25,7 +25,7 @@ pub struct ExchangePeer { /// The IPs that are allowed for this peer. pub allowed_ips: Option, /// The protocol version used by the peer. - pub protocol_version: ProtocolVersion + pub protocol_version: ProtocolVersion, } /// Options for the exchange operation of the `rp` binary.