summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_lib.c
diff options
context:
space:
mode:
authortb <>2021-04-20 17:04:13 +0000
committertb <>2021-04-20 17:04:13 +0000
commit05c3c8fff8c081d09d5d0feb2306a16cd2b9f6f7 (patch)
tree173c34f3f2e636d34625fd1b38effccf5db6b71f /src/lib/libcrypto/ec/ec_lib.c
parentc1737c38418f1a215997d19f2ff6dd2977f52430 (diff)
downloadopenbsd-05c3c8fff8c081d09d5d0feb2306a16cd2b9f6f7.tar.gz
openbsd-05c3c8fff8c081d09d5d0feb2306a16cd2b9f6f7.tar.bz2
openbsd-05c3c8fff8c081d09d5d0feb2306a16cd2b9f6f7.zip
Prepare to provide EC_GROUP_{get,set}_curve(3)
There are numerous functions in ec/ that exist with _GF2m and _GFp variants for no good reason. The code of both variants is the same. The EC_METHODs contain a pointer to the appropriate version. This commit hides the _GF2m and _GFp variants from internal use and provides versions that work for both curve types. These will be made public in an upcoming library bump. Similar to part of OpenSSL commit 8e3cced75fb5fee5da59ebef9605d403a999391b ok jsing
Diffstat (limited to 'src/lib/libcrypto/ec/ec_lib.c')
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index 3442c7a324..67db821ec4 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.33 2020/12/04 08:55:30 tb Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.34 2021/04/20 17:04:13 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 */
@@ -488,10 +488,9 @@ EC_GROUP_get_seed_len(const EC_GROUP * group)
488 return group->seed_len; 488 return group->seed_len;
489} 489}
490 490
491 491int
492int 492EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
493EC_GROUP_set_curve_GFp(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a, 493 const BIGNUM *b, BN_CTX *ctx)
494 const BIGNUM * b, BN_CTX * ctx)
495{ 494{
496 if (group->meth->group_set_curve == 0) { 495 if (group->meth->group_set_curve == 0) {
497 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 496 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -500,10 +499,9 @@ EC_GROUP_set_curve_GFp(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a,
500 return group->meth->group_set_curve(group, p, a, b, ctx); 499 return group->meth->group_set_curve(group, p, a, b, ctx);
501} 500}
502 501
503 502int
504int 503EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
505EC_GROUP_get_curve_GFp(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, 504 BN_CTX *ctx)
506 BIGNUM * b, BN_CTX * ctx)
507{ 505{
508 if (group->meth->group_get_curve == 0) { 506 if (group->meth->group_get_curve == 0) {
509 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 507 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -512,28 +510,33 @@ EC_GROUP_get_curve_GFp(const EC_GROUP * group, BIGNUM * p, BIGNUM * a,
512 return group->meth->group_get_curve(group, p, a, b, ctx); 510 return group->meth->group_get_curve(group, p, a, b, ctx);
513} 511}
514 512
515#ifndef OPENSSL_NO_EC2M 513int
516int 514EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
517EC_GROUP_set_curve_GF2m(EC_GROUP * group, const BIGNUM * p, const BIGNUM * a, 515 const BIGNUM *b, BN_CTX *ctx)
518 const BIGNUM * b, BN_CTX * ctx)
519{ 516{
520 if (group->meth->group_set_curve == 0) { 517 return EC_GROUP_set_curve(group, p, a, b, ctx);
521 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
522 return 0;
523 }
524 return group->meth->group_set_curve(group, p, a, b, ctx);
525} 518}
526 519
520int
521EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
522 BN_CTX *ctx)
523{
524 return EC_GROUP_get_curve(group, p, a, b, ctx);
525}
527 526
528int 527#ifndef OPENSSL_NO_EC2M
529EC_GROUP_get_curve_GF2m(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, 528int
530 BIGNUM * b, BN_CTX * ctx) 529EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
530 const BIGNUM *b, BN_CTX *ctx)
531{ 531{
532 if (group->meth->group_get_curve == 0) { 532 return EC_GROUP_set_curve(group, p, a, b, ctx);
533 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 533}
534 return 0; 534
535 } 535int
536 return group->meth->group_get_curve(group, p, a, b, ctx); 536EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
537 BIGNUM *b, BN_CTX *ctx)
538{
539 return EC_GROUP_get_curve(group, p, a, b, ctx);
537} 540}
538#endif 541#endif
539 542