diff options
author | tb <> | 2025-01-01 10:01:31 +0000 |
---|---|---|
committer | tb <> | 2025-01-01 10:01:31 +0000 |
commit | e66ace5866e5cf640f90e9158ea3245cf5c846e4 (patch) | |
tree | 40ae061a84810df2ca827fadecab17289a513582 | |
parent | 183ebcd147bfd493e4856f28b1ff4c9c6dbd0730 (diff) | |
download | openbsd-e66ace5866e5cf640f90e9158ea3245cf5c846e4.tar.gz openbsd-e66ace5866e5cf640f90e9158ea3245cf5c846e4.tar.bz2 openbsd-e66ace5866e5cf640f90e9158ea3245cf5c846e4.zip |
Garbage collect .group_finish()
There is only one caller, EC_GROUP_free(), so inline the relevant free
calls there and dispose of a few layers of indirection.
ok jsing
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_local.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_methods.c | 19 |
3 files changed, 9 insertions, 23 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index aeb627dfba..89d26e1177 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.92 2025/01/01 09:57:02 tb Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.93 2025/01/01 10:01:31 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 | */ |
@@ -109,8 +109,12 @@ EC_GROUP_free(EC_GROUP *group) | |||
109 | if (group == NULL) | 109 | if (group == NULL) |
110 | return; | 110 | return; |
111 | 111 | ||
112 | if (group->meth->group_finish != NULL) | 112 | BN_free(&group->p); |
113 | group->meth->group_finish(group); | 113 | BN_free(&group->a); |
114 | BN_free(&group->b); | ||
115 | |||
116 | BN_MONT_CTX_free(group->mont_ctx); | ||
117 | BN_free(group->mont_one); | ||
114 | 118 | ||
115 | EC_POINT_free(group->generator); | 119 | EC_POINT_free(group->generator); |
116 | BN_free(&group->order); | 120 | BN_free(&group->order); |
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index bce3f31d4d..cc918b38fd 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.44 2025/01/01 09:57:02 tb Exp $ */ | 1 | /* $OpenBSD: ec_local.h,v 1.45 2025/01/01 10:01:31 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 | |||
88 | struct ec_method_st { | 88 | struct ec_method_st { |
89 | int field_type; | 89 | int field_type; |
90 | 90 | ||
91 | void (*group_finish)(EC_GROUP *); | ||
92 | int (*group_copy)(EC_GROUP *, const EC_GROUP *); | 91 | int (*group_copy)(EC_GROUP *, const EC_GROUP *); |
93 | 92 | ||
94 | int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, | 93 | int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, |
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index 333922d351..af19addab4 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.16 2025/01/01 09:57:02 tb Exp $ */ | 1 | /* $OpenBSD: ecp_methods.c,v 1.17 2025/01/01 10:01:31 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,14 +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 | ||
87 | static void | ||
88 | ec_group_finish(EC_GROUP *group) | ||
89 | { | ||
90 | BN_free(&group->p); | ||
91 | BN_free(&group->a); | ||
92 | BN_free(&group->b); | ||
93 | } | ||
94 | |||
95 | static int | 87 | static int |
96 | ec_group_copy(EC_GROUP *dest, const EC_GROUP *src) | 88 | ec_group_copy(EC_GROUP *dest, const EC_GROUP *src) |
97 | { | 89 | { |
@@ -1526,13 +1518,6 @@ ec_mont_group_clear(EC_GROUP *group) | |||
1526 | group->mont_one = NULL; | 1518 | group->mont_one = NULL; |
1527 | } | 1519 | } |
1528 | 1520 | ||
1529 | static void | ||
1530 | ec_mont_group_finish(EC_GROUP *group) | ||
1531 | { | ||
1532 | ec_mont_group_clear(group); | ||
1533 | ec_group_finish(group); | ||
1534 | } | ||
1535 | |||
1536 | static int | 1521 | static int |
1537 | ec_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src) | 1522 | ec_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src) |
1538 | { | 1523 | { |
@@ -1661,7 +1646,6 @@ ec_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) | |||
1661 | 1646 | ||
1662 | static const EC_METHOD ec_GFp_simple_method = { | 1647 | static const EC_METHOD ec_GFp_simple_method = { |
1663 | .field_type = NID_X9_62_prime_field, | 1648 | .field_type = NID_X9_62_prime_field, |
1664 | .group_finish = ec_group_finish, | ||
1665 | .group_copy = ec_group_copy, | 1649 | .group_copy = ec_group_copy, |
1666 | .group_set_curve = ec_group_set_curve, | 1650 | .group_set_curve = ec_group_set_curve, |
1667 | .group_get_curve = ec_group_get_curve, | 1651 | .group_get_curve = ec_group_get_curve, |
@@ -1697,7 +1681,6 @@ LCRYPTO_ALIAS(EC_GFp_simple_method); | |||
1697 | 1681 | ||
1698 | static const EC_METHOD ec_GFp_mont_method = { | 1682 | static const EC_METHOD ec_GFp_mont_method = { |
1699 | .field_type = NID_X9_62_prime_field, | 1683 | .field_type = NID_X9_62_prime_field, |
1700 | .group_finish = ec_mont_group_finish, | ||
1701 | .group_copy = ec_mont_group_copy, | 1684 | .group_copy = ec_mont_group_copy, |
1702 | .group_set_curve = ec_mont_group_set_curve, | 1685 | .group_set_curve = ec_mont_group_set_curve, |
1703 | .group_get_curve = ec_group_get_curve, | 1686 | .group_get_curve = ec_group_get_curve, |