From 7211bfabd4883f90ee15e44daae1ddcfef572de3 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 1 Dec 2023 11:27:50 +0100 Subject: [PATCH] cleanup rsapublickey --- src/key.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/key.rs b/src/key.rs index 6d4fd316..4d5161a0 100644 --- a/src/key.rs +++ b/src/key.rs @@ -23,7 +23,7 @@ use crate::traits::keys::{CrtValueNew, PrivateKeyPartsNew, PublicKeyPartsNew}; use crate::traits::{PaddingScheme, PublicKeyParts, SignatureScheme}; /// Represents the public part of an RSA key. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct RsaPublicKey { /// Modulus: product of prime numbers `p` and `q` @@ -34,16 +34,24 @@ pub struct RsaPublicKey { /// Typically 0x10001 (65537) e: BoxedUint, + #[cfg_attr(feature = "serde", serde(skip))] n_params: BoxedResidueParams, } -// TODO: derive `Hash` impl when `BoxedUint` supports it +impl Eq for RsaPublicKey {} +impl PartialEq for RsaPublicKey { + #[inline] + fn eq(&self, other: &RsaPublicKey) -> bool { + self.n == other.n && self.e == other.e + } +} + impl Hash for RsaPublicKey { fn hash(&self, state: &mut H) { // Domain separator for RSA private keys state.write(b"RsaPublicKey"); - Hash::hash(&self.n.as_words(), state); - Hash::hash(&self.e.as_words(), state); + Hash::hash(&self.n, state); + Hash::hash(&self.e, state); } }