Skip to content

Commit

Permalink
Remove no longer used method KeyMaterial::equals().
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Jan 6, 2025
1 parent 5ef6691 commit 0e255c4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 107 deletions.
97 changes: 0 additions & 97 deletions src/lib/key_material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<const RSAKeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return (key->key_.n == key_.n) && (key->key_.e == key_.e);
}

void
RSAKeyMaterial::clear_secret() noexcept
{
Expand Down Expand Up @@ -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<const DSAKeyMaterial *>(&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
{
Expand Down Expand Up @@ -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<const EGKeyMaterial *>(&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
{
Expand Down Expand Up @@ -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<const ECKeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return (key->key_.curve == key_.curve) && (key->key_.p == key_.p);
}

void
ECKeyMaterial::clear_secret() noexcept
{
Expand Down Expand Up @@ -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<const Ed25519KeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return key->key_.pub == key_.pub;
}

void
Ed25519KeyMaterial::clear_secret() noexcept
{
Expand Down Expand Up @@ -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<const X25519KeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return key->key_.pub == key_.pub;
}

void
X25519KeyMaterial::clear_secret() noexcept
{
Expand Down Expand Up @@ -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<const MlkemEcdhKeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return key->key_.pub == key_.pub;
}

void
MlkemEcdhKeyMaterial::clear_secret() noexcept
{
Expand Down Expand Up @@ -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<const DilithiumEccKeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return key->key_.pub == key_.pub;
}

void
DilithiumEccKeyMaterial::clear_secret() noexcept
{
Expand Down Expand Up @@ -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<const SlhdsaKeyMaterial *>(&value);
if (!key || !KeyMaterial::equals(value)) {
return false;
}
return key->key_.pub == key_.pub;
}

void
SlhdsaKeyMaterial::clear_secret() noexcept
{
Expand Down
10 changes: 0 additions & 10 deletions src/lib/key_material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -247,7 +246,6 @@ class RSAKeyMaterial : public KeyMaterial {
: KeyMaterial(kalg, secret), key_(key){};
std::unique_ptr<KeyMaterial> 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;
Expand Down Expand Up @@ -291,7 +289,6 @@ class DSAKeyMaterial : public KeyMaterial {
: KeyMaterial(PGP_PKA_DSA, secret), key_(key){};
std::unique_ptr<KeyMaterial> 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;
Expand Down Expand Up @@ -329,7 +326,6 @@ class EGKeyMaterial : public KeyMaterial {
: KeyMaterial(kalg, secret), key_(key){};
std::unique_ptr<KeyMaterial> 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -483,7 +478,6 @@ class Ed25519KeyMaterial : public KeyMaterial {
Ed25519KeyMaterial() : KeyMaterial(PGP_PKA_ED25519), key_{} {};
std::unique_ptr<KeyMaterial> 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;
Expand Down Expand Up @@ -514,7 +508,6 @@ class X25519KeyMaterial : public KeyMaterial {
X25519KeyMaterial() : KeyMaterial(PGP_PKA_X25519), key_{} {};
std::unique_ptr<KeyMaterial> 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;
Expand Down Expand Up @@ -547,7 +540,6 @@ class MlkemEcdhKeyMaterial : public KeyMaterial {
MlkemEcdhKeyMaterial(pgp_pubkey_alg_t kalg) : KeyMaterial(kalg), key_{} {};
std::unique_ptr<KeyMaterial> 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -610,7 +601,6 @@ class SlhdsaKeyMaterial : public KeyMaterial {
SlhdsaKeyMaterial(pgp_pubkey_alg_t kalg) : KeyMaterial(kalg), key_{} {};
std::unique_ptr<KeyMaterial> 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;
Expand Down

0 comments on commit 0e255c4

Please sign in to comment.