From 0e255c4671e24e094704c1881510c959b397f964 Mon Sep 17 00:00:00 2001 From: Nickolay Olshevsky Date: Mon, 6 Jan 2025 14:08:33 +0200 Subject: [PATCH] Remove no longer used method KeyMaterial::equals(). --- src/lib/key_material.cpp | 97 ---------------------------------------- src/lib/key_material.hpp | 10 ----- 2 files changed, 107 deletions(-) diff --git a/src/lib/key_material.cpp b/src/lib/key_material.cpp index 97dd5ec9a..a7a51870e 100644 --- a/src/lib/key_material.cpp +++ b/src/lib/key_material.cpp @@ -260,12 +260,6 @@ KeyMaterial::valid() const return validity_.validated && validity_.valid; } -bool -KeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - return alg_ == value.alg_; -} - void KeyMaterial::validate(rnp::SecurityContext &ctx, bool reset) { @@ -495,16 +489,6 @@ RSAKeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return !key_.validate(ctx.rng, secret_); } -bool -RSAKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return (key->key_.n == key_.n) && (key->key_.e == key_.e); -} - void RSAKeyMaterial::clear_secret() noexcept { @@ -686,17 +670,6 @@ DSAKeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return !key_.validate(ctx.rng, secret_); } -bool -DSAKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return (key->key_.p == key_.p) && (key->key_.q == key_.q) && (key->key_.g == key_.g) && - (key->key_.y == key_.y); -} - void DSAKeyMaterial::clear_secret() noexcept { @@ -851,16 +824,6 @@ EGKeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return key_.validate(secret_); } -bool -EGKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return (key->key_.p == key_.p) && (key->key_.g == key_.g) && (key->key_.y == key_.y); -} - void EGKeyMaterial::clear_secret() noexcept { @@ -991,16 +954,6 @@ ECKeyMaterial::grip_update(rnp::Hash &hash) const grip_hash_ec(hash, key_); } -bool -ECKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return (key->key_.curve == key_.curve) && (key->key_.p == key_.p); -} - void ECKeyMaterial::clear_secret() noexcept { @@ -1469,16 +1422,6 @@ Ed25519KeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return !ed25519_validate_key_native(&ctx.rng, &key_, secret_); } -bool -Ed25519KeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return key->key_.pub == key_.pub; -} - void Ed25519KeyMaterial::clear_secret() noexcept { @@ -1604,16 +1547,6 @@ X25519KeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return !x25519_validate_key_native(&ctx.rng, &key_, secret_); } -bool -X25519KeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return key->key_.pub == key_.pub; -} - void X25519KeyMaterial::clear_secret() noexcept { @@ -1745,16 +1678,6 @@ MlkemEcdhKeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return !kyber_ecdh_validate_key(&ctx.rng, &key_, secret_); } -bool -MlkemEcdhKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return key->key_.pub == key_.pub; -} - void MlkemEcdhKeyMaterial::clear_secret() noexcept { @@ -1876,16 +1799,6 @@ DilithiumEccKeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset return !dilithium_exdsa_validate_key(&ctx.rng, &key_, secret_); } -bool -DilithiumEccKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return key->key_.pub == key_.pub; -} - void DilithiumEccKeyMaterial::clear_secret() noexcept { @@ -2008,16 +1921,6 @@ SlhdsaKeyMaterial::validate_material(rnp::SecurityContext &ctx, bool reset) return !sphincsplus_validate_key(&ctx.rng, &key_, secret_); } -bool -SlhdsaKeyMaterial::equals(const KeyMaterial &value) const noexcept -{ - auto key = dynamic_cast(&value); - if (!key || !KeyMaterial::equals(value)) { - return false; - } - return key->key_.pub == key_.pub; -} - void SlhdsaKeyMaterial::clear_secret() noexcept { diff --git a/src/lib/key_material.hpp b/src/lib/key_material.hpp index 6338c6231..a9357808c 100644 --- a/src/lib/key_material.hpp +++ b/src/lib/key_material.hpp @@ -200,7 +200,6 @@ class KeyMaterial { void set_validity(const pgp_validity_t &val); void reset_validity(); bool valid() const; - virtual bool equals(const KeyMaterial &value) const noexcept; virtual void clear_secret() noexcept; virtual bool parse(pgp_packet_body_t &pkt) noexcept = 0; virtual bool parse_secret(pgp_packet_body_t &pkt) noexcept = 0; @@ -247,7 +246,6 @@ class RSAKeyMaterial : public KeyMaterial { : KeyMaterial(kalg, secret), key_(key){}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -291,7 +289,6 @@ class DSAKeyMaterial : public KeyMaterial { : KeyMaterial(PGP_PKA_DSA, secret), key_(key){}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -329,7 +326,6 @@ class EGKeyMaterial : public KeyMaterial { : KeyMaterial(kalg, secret), key_(key){}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -367,7 +363,6 @@ class ECKeyMaterial : public KeyMaterial { ECKeyMaterial(pgp_pubkey_alg_t kalg, const ec::Key &key, bool secret = false) : KeyMaterial(kalg, secret), key_(key){}; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -483,7 +478,6 @@ class Ed25519KeyMaterial : public KeyMaterial { Ed25519KeyMaterial() : KeyMaterial(PGP_PKA_ED25519), key_{} {}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -514,7 +508,6 @@ class X25519KeyMaterial : public KeyMaterial { X25519KeyMaterial() : KeyMaterial(PGP_PKA_X25519), key_{} {}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -547,7 +540,6 @@ class MlkemEcdhKeyMaterial : public KeyMaterial { MlkemEcdhKeyMaterial(pgp_pubkey_alg_t kalg) : KeyMaterial(kalg), key_{} {}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -579,7 +571,6 @@ class DilithiumEccKeyMaterial : public KeyMaterial { /** @brief Check two key material for equality. Only public part is checked, so this may be * called on public/secret key material */ - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override; @@ -610,7 +601,6 @@ class SlhdsaKeyMaterial : public KeyMaterial { SlhdsaKeyMaterial(pgp_pubkey_alg_t kalg) : KeyMaterial(kalg), key_{} {}; std::unique_ptr clone() override; - bool equals(const KeyMaterial &value) const noexcept override; void clear_secret() noexcept override; bool parse(pgp_packet_body_t &pkt) noexcept override; bool parse_secret(pgp_packet_body_t &pkt) noexcept override;