diff options
author | tb <> | 2023-07-26 12:16:13 +0000 |
---|---|---|
committer | tb <> | 2023-07-26 12:16:13 +0000 |
commit | 358c3ca483c0d97eb85d267582df13747b40d549 (patch) | |
tree | 3c6ad80171432322bae86b59d6a725d016c62710 | |
parent | e1df32281280bf2a9fc7e0f31572601bd086f7d4 (diff) | |
download | openbsd-358c3ca483c0d97eb85d267582df13747b40d549.tar.gz openbsd-358c3ca483c0d97eb85d267582df13747b40d549.tar.bz2 openbsd-358c3ca483c0d97eb85d267582df13747b40d549.zip |
Streamline check_discriminant()
Instead of inlining EC_GROUP_get_curve(), we can simply call it...
ok jsing
-rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index 21d0d32ef9..1a467d4f8f 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_smpl.c,v 1.50 2023/07/26 12:12:13 tb Exp $ */ | 1 | /* $OpenBSD: ecp_smpl.c,v 1.51 2023/07/26 12:16:13 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. |
@@ -203,12 +203,13 @@ ec_GFp_simple_group_get_degree(const EC_GROUP *group) | |||
203 | int | 203 | int |
204 | ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) | 204 | ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) |
205 | { | 205 | { |
206 | BIGNUM *a, *b, *order, *tmp_1, *tmp_2; | 206 | BIGNUM *p, *a, *b, *order, *tmp_1, *tmp_2; |
207 | const BIGNUM *p = &group->field; | ||
208 | int ret = 0; | 207 | int ret = 0; |
209 | 208 | ||
210 | BN_CTX_start(ctx); | 209 | BN_CTX_start(ctx); |
211 | 210 | ||
211 | if ((p = BN_CTX_get(ctx)) == NULL) | ||
212 | goto err; | ||
212 | if ((a = BN_CTX_get(ctx)) == NULL) | 213 | if ((a = BN_CTX_get(ctx)) == NULL) |
213 | goto err; | 214 | goto err; |
214 | if ((b = BN_CTX_get(ctx)) == NULL) | 215 | if ((b = BN_CTX_get(ctx)) == NULL) |
@@ -220,17 +221,8 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) | |||
220 | if ((order = BN_CTX_get(ctx)) == NULL) | 221 | if ((order = BN_CTX_get(ctx)) == NULL) |
221 | goto err; | 222 | goto err; |
222 | 223 | ||
223 | if (group->meth->field_decode) { | 224 | if (!EC_GROUP_get_curve(group, p, a, b, ctx)) |
224 | if (!group->meth->field_decode(group, a, &group->a, ctx)) | 225 | goto err; |
225 | goto err; | ||
226 | if (!group->meth->field_decode(group, b, &group->b, ctx)) | ||
227 | goto err; | ||
228 | } else { | ||
229 | if (!bn_copy(a, &group->a)) | ||
230 | goto err; | ||
231 | if (!bn_copy(b, &group->b)) | ||
232 | goto err; | ||
233 | } | ||
234 | 226 | ||
235 | /* | 227 | /* |
236 | * check the discriminant: y^2 = x^3 + a*x + b is an elliptic curve | 228 | * check the discriminant: y^2 = x^3 + a*x + b is an elliptic curve |