diff options
| author | tb <> | 2025-02-13 11:19:49 +0000 |
|---|---|---|
| committer | tb <> | 2025-02-13 11:19:49 +0000 |
| commit | aee4d44b17e8fc57dfaadf57efabb128712c9f72 (patch) | |
| tree | b4719b45a328028e919d8d242d7046508e2bae1b /src | |
| parent | 4d14a0160a4c9b56bb435f52958b6af4d767c02d (diff) | |
| download | openbsd-aee4d44b17e8fc57dfaadf57efabb128712c9f72.tar.gz openbsd-aee4d44b17e8fc57dfaadf57efabb128712c9f72.tar.bz2 openbsd-aee4d44b17e8fc57dfaadf57efabb128712c9f72.zip | |
ec_mont_group_set_curve: convert to BN_MONT_CTX_create() and simplify
This removes the penultimate internal call of BN_MONT_CTX_new(). The last
one could be removed at the cost of introducing a BN_MONT_CTX_dup(), which
probably isn't worth it.
ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_methods.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/lib/libcrypto/ec/ecp_methods.c b/src/lib/libcrypto/ec/ecp_methods.c index ad975cb646..d1d0add538 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.42 2025/01/25 13:15:21 tb Exp $ */ | 1 | /* $OpenBSD: ecp_methods.c,v 1.43 2025/02/13 11:19:49 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. |
| @@ -1217,33 +1217,20 @@ static int | |||
| 1217 | ec_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, | 1217 | ec_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, |
| 1218 | const BIGNUM *b, BN_CTX *ctx) | 1218 | const BIGNUM *b, BN_CTX *ctx) |
| 1219 | { | 1219 | { |
| 1220 | BN_MONT_CTX *mont = NULL; | ||
| 1221 | int ret = 0; | ||
| 1222 | |||
| 1223 | BN_MONT_CTX_free(group->mont_ctx); | 1220 | BN_MONT_CTX_free(group->mont_ctx); |
| 1224 | group->mont_ctx = NULL; | 1221 | if ((group->mont_ctx = BN_MONT_CTX_create(p, ctx)) == NULL) |
| 1225 | |||
| 1226 | if ((mont = BN_MONT_CTX_new()) == NULL) | ||
| 1227 | goto err; | 1222 | goto err; |
| 1228 | if (!BN_MONT_CTX_set(mont, p, ctx)) { | ||
| 1229 | ECerror(ERR_R_BN_LIB); | ||
| 1230 | goto err; | ||
| 1231 | } | ||
| 1232 | group->mont_ctx = mont; | ||
| 1233 | mont = NULL; | ||
| 1234 | 1223 | ||
| 1235 | if (!ec_group_set_curve(group, p, a, b, ctx)) { | 1224 | if (!ec_group_set_curve(group, p, a, b, ctx)) |
| 1236 | BN_MONT_CTX_free(group->mont_ctx); | ||
| 1237 | group->mont_ctx = NULL; | ||
| 1238 | goto err; | 1225 | goto err; |
| 1239 | } | ||
| 1240 | 1226 | ||
| 1241 | ret = 1; | 1227 | return 1; |
| 1242 | 1228 | ||
| 1243 | err: | 1229 | err: |
| 1244 | BN_MONT_CTX_free(mont); | 1230 | BN_MONT_CTX_free(group->mont_ctx); |
| 1231 | group->mont_ctx = NULL; | ||
| 1245 | 1232 | ||
| 1246 | return ret; | 1233 | return 0; |
| 1247 | } | 1234 | } |
| 1248 | 1235 | ||
| 1249 | static int | 1236 | static int |
