aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2021-03-13 08:54:07 -0500
committerJack Lloyd <[email protected]>2021-03-13 08:56:48 -0500
commitea7002880a92cc4c48375a7bb8b977e92b043fba (patch)
tree4ac91c240e1c13de0a61b0a97ee6c6b53febd43e
parent18897bf5ba701ec1bde277f4719265612da95a44 (diff)
Address some review comments
-rw-r--r--src/lib/pubkey/ec_group/ec_group.cpp18
-rw-r--r--src/tests/test_ec_group.cpp2
2 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp
index 67d63ee65..ca007b584 100644
--- a/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/lib/pubkey/ec_group/ec_group.cpp
@@ -64,7 +64,7 @@ class EC_Group_Data final
this->g_y() == g_y);
}
- bool match(EC_Group_Data& other) const
+ bool match(const EC_Group_Data& other) const
{
return match(other.p(), other.a(), other.b(),
other.g_x(), other.g_y(),
@@ -263,8 +263,20 @@ class EC_Group_Data_Map final
const OID oid_from_store = EC_Group::EC_group_identity_from_order(order);
if(oid_from_store.has_value())
{
- std::shared_ptr<EC_Group_Data> data = EC_Group::EC_group_info(oid);
- if(data == nullptr || new_group->match(*data))
+ std::shared_ptr<EC_Group_Data> data = EC_Group::EC_group_info(oid_from_store);
+
+ /*
+ If EC_group_identity_from_order returned an OID then looking up that OID
+ must always return a result.
+ */
+ BOTAN_ASSERT_NOMSG(data != nullptr);
+
+ /*
+ It is possible (if unlikely) that someone is registering another group
+ that happens to have an order equal to that of a well known group -
+ so verify all values before assigning the OID.
+ */
+ if(new_group->match(*data))
{
new_group->set_oid(oid_from_store);
}
diff --git a/src/tests/test_ec_group.cpp b/src/tests/test_ec_group.cpp
index 0757254c1..81541cfd5 100644
--- a/src/tests/test_ec_group.cpp
+++ b/src/tests/test_ec_group.cpp
@@ -762,7 +762,7 @@ Test::Result test_ec_group_duplicate_orders()
// We can now get it by OID:
Botan::EC_Group hc_group(oid);
- result.confirm("Group has correct OID", reg_group.get_curve_oid() == oid);
+ result.confirm("Group has correct OID", hc_group.get_curve_oid() == oid);
// Existing secp160r1 unmodified:
const Botan::OID secp160r1("1.3.132.0.8");