Skip to content

Commit

Permalink
Implement Debug for Key
Browse files Browse the repository at this point in the history
  • Loading branch information
frenetisch-applaudierend authored and SergioBenitez committed Sep 22, 2023
1 parent 89edddf commit 8a1ec74
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/secure/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ impl PartialEq for Key {
}
}

impl std::fmt::Debug for Key {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Key").finish()
}
}

impl Key {
// An empty key structure, to be filled.
const fn zero() -> Self {
Expand Down Expand Up @@ -298,4 +304,11 @@ mod test {
assert_ne!(key_a.signing(), key_b.signing());
assert_ne!(key_a.encryption(), key_b.encryption());
}

#[test]
fn debug_does_not_leak_key() {
let key = Key::generate();

assert_eq!(format!("{:?}", key), "Key");
}
}

0 comments on commit 8a1ec74

Please sign in to comment.