summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/crypto/mod.rs')
-rw-r--r--openpgp/src/crypto/mod.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index 9da5a8d9..d3deb2e1 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -22,9 +22,15 @@ pub(crate) mod symmetric;
/// Holds a session key.
///
/// The session key is cleared when dropped.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, Eq)]
pub struct SessionKey(Box<[u8]>);
+impl PartialEq for SessionKey {
+ fn eq(&self, other: &Self) -> bool {
+ secure_cmp(&self.0, &other.0) == Ordering::Equal
+ }
+}
+
impl SessionKey {
/// Creates a new session key.
pub fn new(rng: &mut Yarrow, size: usize) -> Self {
@@ -75,9 +81,15 @@ impl fmt::Debug for SessionKey {
/// Holds a password.
///
/// The password is cleared when dropped.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, Eq)]
pub struct Password(Box<[u8]>);
+impl PartialEq for Password {
+ fn eq(&self, other: &Self) -> bool {
+ secure_cmp(&self.0, &other.0) == Ordering::Equal
+ }
+}
+
impl Deref for Password {
type Target = [u8];