summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2025-01-01 09:57:02 +0000
committertb <>2025-01-01 09:57:02 +0000
commit183ebcd147bfd493e4856f28b1ff4c9c6dbd0730 (patch)
tree9af62a1a58881fed0768c163faef515fca142874 /src/lib
parent4f4db522b10347e779e635569d9938a60931b0d1 (diff)
downloadopenbsd-183ebcd147bfd493e4856f28b1ff4c9c6dbd0730.tar.gz
openbsd-183ebcd147bfd493e4856f28b1ff4c9c6dbd0730.tar.bz2
openbsd-183ebcd147bfd493e4856f28b1ff4c9c6dbd0730.zip
Garbage collect .group_init()
For both in-tree methods these are just complicated ways of zeroing part of the group object. The group is allocated with calloc(), so it's all entirely pointless. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c12
-rw-r--r--src/lib/libcrypto/ec/ec_local.h3
-rw-r--r--src/lib/libcrypto/ec/ecp_methods.c25
3 files changed, 3 insertions, 37 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index 6644c4dfc7..aeb627dfba 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_lib.c,v 1.91 2024/12/12 10:02:00 tb Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.92 2025/01/01 09:57:02 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -84,10 +84,6 @@ EC_GROUP_new(const EC_METHOD *meth)
84 ECerror(EC_R_SLOT_FULL); 84 ECerror(EC_R_SLOT_FULL);
85 goto err; 85 goto err;
86 } 86 }
87 if (meth->group_init == NULL) {
88 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
89 goto err;
90 }
91 if ((group = calloc(1, sizeof(*group))) == NULL) { 87 if ((group = calloc(1, sizeof(*group))) == NULL) {
92 ECerror(ERR_R_MALLOC_FAILURE); 88 ECerror(ERR_R_MALLOC_FAILURE);
93 goto err; 89 goto err;
@@ -95,15 +91,9 @@ EC_GROUP_new(const EC_METHOD *meth)
95 91
96 group->meth = meth; 92 group->meth = meth;
97 93
98 BN_init(&group->order);
99 BN_init(&group->cofactor);
100
101 group->asn1_flag = OPENSSL_EC_NAMED_CURVE; 94 group->asn1_flag = OPENSSL_EC_NAMED_CURVE;
102 group->asn1_form = POINT_CONVERSION_UNCOMPRESSED; 95 group->asn1_form = POINT_CONVERSION_UNCOMPRESSED;
103 96
104 if (!meth->group_init(group))
105 goto err;
106
107 return group; 97 return group;
108 98
109 err: 99 err:
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h
index ea1cd7adad..bce3f31d4d 100644
--- a/src/lib/libcrypto/ec/ec_local.h
+++ b/src/lib/libcrypto/ec/ec_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_local.h,v 1.43 2024/12/12 10:00:15 tb Exp $ */ 1/* $OpenBSD: ec_local.h,v 1.44 2025/01/01 09:57:02 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -88,7 +88,6 @@ __BEGIN_HIDDEN_DECLS
88struct ec_method_st { 88struct ec_method_st {
89 int field_type; 89 int field_type;
90 90
91 int (*group_init)(EC_GROUP *);
92 void (*group_finish)(EC_GROUP *); 91 void (*group_finish)(EC_GROUP *);
93 int (*group_copy)(EC_GROUP *, const EC_GROUP *); 92 int (*group_copy)(EC_GROUP *, const EC_GROUP *);
94 93
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c
index 591d895c58..333922d351 100644
--- a/src/lib/libcrypto/ec/ecp_methods.c
+++ b/src/lib/libcrypto/ec/ecp_methods.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_methods.c,v 1.15 2025/01/01 09:31:05 tb Exp $ */ 1/* $OpenBSD: ecp_methods.c,v 1.16 2025/01/01 09:57:02 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. 3 * for the OpenSSL project.
4 * Includes code written by Bodo Moeller for the OpenSSL project. 4 * Includes code written by Bodo Moeller for the OpenSSL project.
@@ -84,16 +84,6 @@
84 * representation (i.e. 'encoding' means multiplying by some factor R). 84 * representation (i.e. 'encoding' means multiplying by some factor R).
85 */ 85 */
86 86
87static int
88ec_group_init(EC_GROUP *group)
89{
90 BN_init(&group->p);
91 BN_init(&group->a);
92 BN_init(&group->b);
93 group->a_is_minus3 = 0;
94 return 1;
95}
96
97static void 87static void
98ec_group_finish(EC_GROUP *group) 88ec_group_finish(EC_GROUP *group)
99{ 89{
@@ -1536,17 +1526,6 @@ ec_mont_group_clear(EC_GROUP *group)
1536 group->mont_one = NULL; 1526 group->mont_one = NULL;
1537} 1527}
1538 1528
1539static int
1540ec_mont_group_init(EC_GROUP *group)
1541{
1542 int ok;
1543
1544 ok = ec_group_init(group);
1545 group->mont_ctx = NULL;
1546 group->mont_one = NULL;
1547 return ok;
1548}
1549
1550static void 1529static void
1551ec_mont_group_finish(EC_GROUP *group) 1530ec_mont_group_finish(EC_GROUP *group)
1552{ 1531{
@@ -1682,7 +1661,6 @@ ec_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx)
1682 1661
1683static const EC_METHOD ec_GFp_simple_method = { 1662static const EC_METHOD ec_GFp_simple_method = {
1684 .field_type = NID_X9_62_prime_field, 1663 .field_type = NID_X9_62_prime_field,
1685 .group_init = ec_group_init,
1686 .group_finish = ec_group_finish, 1664 .group_finish = ec_group_finish,
1687 .group_copy = ec_group_copy, 1665 .group_copy = ec_group_copy,
1688 .group_set_curve = ec_group_set_curve, 1666 .group_set_curve = ec_group_set_curve,
@@ -1719,7 +1697,6 @@ LCRYPTO_ALIAS(EC_GFp_simple_method);
1719 1697
1720static const EC_METHOD ec_GFp_mont_method = { 1698static const EC_METHOD ec_GFp_mont_method = {
1721 .field_type = NID_X9_62_prime_field, 1699 .field_type = NID_X9_62_prime_field,
1722 .group_init = ec_mont_group_init,
1723 .group_finish = ec_mont_group_finish, 1700 .group_finish = ec_mont_group_finish,
1724 .group_copy = ec_mont_group_copy, 1701 .group_copy = ec_mont_group_copy,
1725 .group_set_curve = ec_mont_group_set_curve, 1702 .group_set_curve = ec_mont_group_set_curve,