From f3f76e57091954477449989f51ca8794ef8c882c Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Mon, 7 Jun 2021 20:55:03 -0700 Subject: [PATCH] [#472] remove Debug from SessionRecord - also add a cheap Debug impl for PrivateKey which leaks no info --- rust/protocol/src/curve.rs | 8 ++++++++ rust/protocol/src/state/session.rs | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rust/protocol/src/curve.rs b/rust/protocol/src/curve.rs index 33e683742a..3840ee2977 100644 --- a/rust/protocol/src/curve.rs +++ b/rust/protocol/src/curve.rs @@ -297,6 +297,14 @@ impl TryFrom<&[u8]> for PrivateKey { } } +impl fmt::Debug for PrivateKey { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /* Calculating the equivalent public key isn't free, and we want to discourage printing out + * the actual private key data, so we just provide the key type here. */ + write!(f, "PrivateKey {{ key_type={} }}", self.key_type()) + } +} + #[derive(Copy, Clone)] pub struct KeyPair { pub public_key: PublicKey, diff --git a/rust/protocol/src/state/session.rs b/rust/protocol/src/state/session.rs index 1807108894..20bd99297f 100644 --- a/rust/protocol/src/state/session.rs +++ b/rust/protocol/src/state/session.rs @@ -466,7 +466,7 @@ impl From<&SessionState> for SessionStructure { } } -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct SessionRecord { current_session: Option, previous_sessions: Vec>,