From 13563237cbc90075844556bfb582e4591b8d7249 Mon Sep 17 00:00:00 2001 From: Karolin Varner Date: Wed, 8 Nov 2023 20:40:27 +0100 Subject: [PATCH] chore: rustfmt --- benches/handshake.rs | 2 +- src/labeled_prf.rs | 18 +++++++++--------- src/lprf.rs | 13 +++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/benches/handshake.rs b/benches/handshake.rs index ff78a28..1a46df5 100644 --- a/benches/handshake.rs +++ b/benches/handshake.rs @@ -2,7 +2,7 @@ use anyhow::Result; use rosenpass::pqkem::KEM; use rosenpass::{ pqkem::StaticKEM, - protocol::{SPk, SSk, CryptoServer, HandleMsgResult, MsgBuf, PeerPtr, SymKey}, + protocol::{CryptoServer, HandleMsgResult, MsgBuf, PeerPtr, SPk, SSk, SymKey}, sodium::sodium_init, }; diff --git a/src/labeled_prf.rs b/src/labeled_prf.rs index 7f3d775..bbc88bc 100644 --- a/src/labeled_prf.rs +++ b/src/labeled_prf.rs @@ -21,12 +21,12 @@ macro_rules! prflabel { } } -prflabel!(protocol, mac, "mac"); -prflabel!(protocol, cookie, "cookie"); -prflabel!(protocol, peerid, "peer id"); +prflabel!(protocol, mac, "mac"); +prflabel!(protocol, cookie, "cookie"); +prflabel!(protocol, peerid, "peer id"); prflabel!(protocol, biscuit_ad, "biscuit additional data"); -prflabel!(protocol, ckinit, "chaining key init"); -prflabel!(protocol, _ckextract, "chaining key extract"); +prflabel!(protocol, ckinit, "chaining key init"); +prflabel!(protocol, _ckextract, "chaining key extract"); macro_rules! prflabel_leaf { ($base:ident, $name:ident, $($lbl:expr),* ) => { @@ -38,10 +38,10 @@ macro_rules! prflabel_leaf { } } -prflabel_leaf!(_ckextract, mix, "mix"); -prflabel_leaf!(_ckextract, hs_enc, "handshake encryption"); -prflabel_leaf!(_ckextract, ini_enc, "initiator handshake encryption"); -prflabel_leaf!(_ckextract, res_enc, "responder handshake encryption"); +prflabel_leaf!(_ckextract, mix, "mix"); +prflabel_leaf!(_ckextract, hs_enc, "handshake encryption"); +prflabel_leaf!(_ckextract, ini_enc, "initiator handshake encryption"); +prflabel_leaf!(_ckextract, res_enc, "responder handshake encryption"); prflabel!(_ckextract, _user, "user"); prflabel!(_user, _rp, "rosenpass.eu"); diff --git a/src/lprf.rs b/src/lprf.rs index 5f14bad..6dff7a0 100644 --- a/src/lprf.rs +++ b/src/lprf.rs @@ -6,7 +6,7 @@ //! This is a generalization of a PRF operating //! on a sequence of inputs instead of a single input. //! -//! Like a Dec function the Iprf features efficient +//! Like a Dec function the Iprf features efficient //! incrementability. //! //! You can also think of an Iprf as a Dec function with @@ -27,7 +27,7 @@ pub fn prf_into(out: &mut [u8], key: &[u8], data: &[u8]) { hmac_into(out, key, data).unwrap() } -pub fn prf(key: &[u8], data: &[u8]) -> [u8; KEY_SIZE]{ +pub fn prf(key: &[u8], data: &[u8]) -> [u8; KEY_SIZE] { mutating([0u8; KEY_SIZE], |r| prf_into(r, key, data)) } @@ -40,11 +40,11 @@ impl Iprf { IprfBranch(self.0) } - // TODO: Protocol! Use domain separation to ensure that + // TODO: Protocol! Use domain separation to ensure that fn mix(self, v: &[u8]) -> Self { Self(prf(&self.0, v)) } - + fn mix_secret(self, v: Secret) -> SecretIprf { SecretIprf::prf_invoc(&self.0, v.secret()) } @@ -70,8 +70,9 @@ impl IprfBranch { impl SecretIprf { fn prf_invoc(k: &[u8], d: &[u8]) -> SecretIprf { - mutating(SecretIprf(Secret::zero()), |r| - prf_into(k, d, r.secret_mut())) + mutating(SecretIprf(Secret::zero()), |r| { + prf_into(k, d, r.secret_mut()) + }) } fn from_key(k: Secret) -> SecretIprf {