summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-10-31 15:37:53 +0000
committertb <>2024-10-31 15:37:53 +0000
commit65fc25f0127c246c6ca0b80faa55bd49fa2ef13f (patch)
tree213f15ca307e60a6806d6afab897c0a81c295102
parent2f2f748fde73822038414204b26d3d5f3b07d5ba (diff)
downloadopenbsd-65fc25f0127c246c6ca0b80faa55bd49fa2ef13f.tar.gz
openbsd-65fc25f0127c246c6ca0b80faa55bd49fa2ef13f.tar.bz2
openbsd-65fc25f0127c246c6ca0b80faa55bd49fa2ef13f.zip
Retire the oct2point and point2oct EC_METHOD members
Both our remaining EC_METHODs use the methods that used to be called ec_GFp_simple_{oct2point,point2oct}() so there's no need for the function pointer indirection. Make the public API call them directly. ok jsing
-rw-r--r--src/lib/libcrypto/ec/ec_convert.c22
-rw-r--r--src/lib/libcrypto/ec/ec_local.h12
-rw-r--r--src/lib/libcrypto/ec/ecp_mont.c4
-rw-r--r--src/lib/libcrypto/ec/ecp_smpl.c4
4 files changed, 10 insertions, 32 deletions
diff --git a/src/lib/libcrypto/ec/ec_convert.c b/src/lib/libcrypto/ec/ec_convert.c
index a151850f46..3fdbaf3ce7 100644
--- a/src/lib/libcrypto/ec/ec_convert.c
+++ b/src/lib/libcrypto/ec/ec_convert.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_convert.c,v 1.6 2024/10/31 05:03:57 tb Exp $ */ 1/* $OpenBSD: ec_convert.c,v 1.7 2024/10/31 15:37:53 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 */
@@ -218,8 +218,8 @@ ec_oct_get_field_element_cbs(CBS *cbs, const EC_GROUP *group, BIGNUM *bn)
218 return 1; 218 return 1;
219} 219}
220 220
221size_t 221static size_t
222ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, 222ec_oct_point2oct(const EC_GROUP *group, const EC_POINT *point,
223 point_conversion_form_t conversion_form, unsigned char *buf, size_t len, 223 point_conversion_form_t conversion_form, unsigned char *buf, size_t len,
224 BN_CTX *ctx) 224 BN_CTX *ctx)
225{ 225{
@@ -308,8 +308,8 @@ ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
308 return ret; 308 return ret;
309} 309}
310 310
311int 311static int
312ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, 312ec_oct_oct2point(const EC_GROUP *group, EC_POINT *point,
313 const unsigned char *buf, size_t len, BN_CTX *ctx) 313 const unsigned char *buf, size_t len, BN_CTX *ctx)
314{ 314{
315 CBS cbs; 315 CBS cbs;
@@ -447,15 +447,11 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
447 if (ctx == NULL) 447 if (ctx == NULL)
448 goto err; 448 goto err;
449 449
450 if (group->meth->point2oct == NULL) {
451 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
452 goto err;
453 }
454 if (group->meth != point->meth) { 450 if (group->meth != point->meth) {
455 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 451 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
456 goto err; 452 goto err;
457 } 453 }
458 ret = group->meth->point2oct(group, point, form, buf, len, ctx); 454 ret = ec_oct_point2oct(group, point, form, buf, len, ctx);
459 455
460 err: 456 err:
461 if (ctx != ctx_in) 457 if (ctx != ctx_in)
@@ -477,15 +473,11 @@ EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
477 if (ctx == NULL) 473 if (ctx == NULL)
478 goto err; 474 goto err;
479 475
480 if (group->meth->oct2point == NULL) {
481 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
482 goto err;
483 }
484 if (group->meth != point->meth) { 476 if (group->meth != point->meth) {
485 ECerror(EC_R_INCOMPATIBLE_OBJECTS); 477 ECerror(EC_R_INCOMPATIBLE_OBJECTS);
486 goto err; 478 goto err;
487 } 479 }
488 ret = group->meth->oct2point(group, point, buf, len, ctx); 480 ret = ec_oct_oct2point(group, point, buf, len, ctx);
489 481
490 err: 482 err:
491 if (ctx != ctx_in) 483 if (ctx != ctx_in)
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h
index 148e94b766..547705e9a6 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.34 2024/10/30 17:52:34 tb Exp $ */ 1/* $OpenBSD: ec_local.h,v 1.35 2024/10/31 15:37:53 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 */
@@ -117,12 +117,6 @@ struct ec_method_st {
117 int (*point_set_compressed_coordinates)(const EC_GROUP *, EC_POINT *, 117 int (*point_set_compressed_coordinates)(const EC_GROUP *, EC_POINT *,
118 const BIGNUM *x, int y_bit, BN_CTX *); 118 const BIGNUM *x, int y_bit, BN_CTX *);
119 119
120 size_t (*point2oct)(const EC_GROUP *, const EC_POINT *,
121 point_conversion_form_t form, unsigned char *buf, size_t len,
122 BN_CTX *);
123 int (*oct2point)(const EC_GROUP *, EC_POINT *, const unsigned char *buf,
124 size_t len, BN_CTX *);
125
126 int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, 120 int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,
127 const EC_POINT *b, BN_CTX *); 121 const EC_POINT *b, BN_CTX *);
128 int (*dbl)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); 122 int (*dbl)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
@@ -282,10 +276,6 @@ int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT
282 BIGNUM *x, BIGNUM *y, BN_CTX *); 276 BIGNUM *x, BIGNUM *y, BN_CTX *);
283int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, 277int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,
284 const BIGNUM *x, int y_bit, BN_CTX *); 278 const BIGNUM *x, int y_bit, BN_CTX *);
285size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form,
286 unsigned char *buf, size_t len, BN_CTX *);
287int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *,
288 const unsigned char *buf, size_t len, BN_CTX *);
289int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); 279int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
290int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); 280int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
291int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); 281int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
diff --git a/src/lib/libcrypto/ec/ecp_mont.c b/src/lib/libcrypto/ec/ecp_mont.c
index 76d1f578ee..8fd7ebc7b9 100644
--- a/src/lib/libcrypto/ec/ecp_mont.c
+++ b/src/lib/libcrypto/ec/ecp_mont.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_mont.c,v 1.30 2023/07/07 13:54:45 beck Exp $ */ 1/* $OpenBSD: ecp_mont.c,v 1.31 2024/10/31 15:37:53 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 */
@@ -243,8 +243,6 @@ static const EC_METHOD ec_GFp_mont_method = {
243 ec_GFp_simple_point_get_affine_coordinates, 243 ec_GFp_simple_point_get_affine_coordinates,
244 .point_set_compressed_coordinates = 244 .point_set_compressed_coordinates =
245 ec_GFp_simple_set_compressed_coordinates, 245 ec_GFp_simple_set_compressed_coordinates,
246 .point2oct = ec_GFp_simple_point2oct,
247 .oct2point = ec_GFp_simple_oct2point,
248 .add = ec_GFp_simple_add, 246 .add = ec_GFp_simple_add,
249 .dbl = ec_GFp_simple_dbl, 247 .dbl = ec_GFp_simple_dbl,
250 .invert = ec_GFp_simple_invert, 248 .invert = ec_GFp_simple_invert,
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c
index 018aedfd4e..ab79680742 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.56 2023/08/03 18:53:56 tb Exp $ */ 1/* $OpenBSD: ecp_smpl.c,v 1.57 2024/10/31 15:37:53 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.
@@ -1534,8 +1534,6 @@ static const EC_METHOD ec_GFp_simple_method = {
1534 ec_GFp_simple_point_get_affine_coordinates, 1534 ec_GFp_simple_point_get_affine_coordinates,
1535 .point_set_compressed_coordinates = 1535 .point_set_compressed_coordinates =
1536 ec_GFp_simple_set_compressed_coordinates, 1536 ec_GFp_simple_set_compressed_coordinates,
1537 .point2oct = ec_GFp_simple_point2oct,
1538 .oct2point = ec_GFp_simple_oct2point,
1539 .add = ec_GFp_simple_add, 1537 .add = ec_GFp_simple_add,
1540 .dbl = ec_GFp_simple_dbl, 1538 .dbl = ec_GFp_simple_dbl,
1541 .invert = ec_GFp_simple_invert, 1539 .invert = ec_GFp_simple_invert,