keyforkd: hide field seed in std::fmt::Debug implementation

This commit is contained in:
Ryan Heywood 2024-01-17 20:45:04 -05:00
parent f7c00d11f1
commit d2965745e8
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 13 additions and 2 deletions

View File

@ -16,14 +16,25 @@ use tracing::info;
// NOTE: All values implemented in Keyforkd must implement Clone with low overhead, either by // NOTE: All values implemented in Keyforkd must implement Clone with low overhead, either by
// using an Arc or by having a small signature. This is because Service<T> takes &mut self. // using an Arc or by having a small signature. This is because Service<T> takes &mut self.
//
// TODO: Make `seed` a `secrecy::SecretVec<u8>` so we can readd derive(Debug)
/// The Keyfork Service. /// The Keyfork Service.
#[derive(Clone, Debug)] #[derive(Clone)]
pub struct Keyforkd { pub struct Keyforkd {
seed: Arc<Vec<u8>>, seed: Arc<Vec<u8>>,
} }
impl std::fmt::Debug for Keyforkd {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// Bind data from self, to ensure we capture all values if we add more later.
let Keyforkd { seed: _ } = self;
f.debug_struct("Keyforkd")
.field("seed", &"<hidden>")
.finish()
}
}
impl Keyforkd { impl Keyforkd {
/// Create a new instance of Keyfork from a given seed. /// Create a new instance of Keyfork from a given seed.
pub fn new(seed: Vec<u8>) -> Self { pub fn new(seed: Vec<u8>) -> Self {