summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-11-19 07:29:29 +0000
committertb <>2022-11-19 07:29:29 +0000
commit97ff0b8011f923270c9adb50e24c2b4c4a533238 (patch)
tree744c8fadca050ecfeaa626562148788777b42d2f /src
parentb197546e7fd8128aedea248a6196a0d25734b937 (diff)
downloadopenbsd-97ff0b8011f923270c9adb50e24c2b4c4a533238.tar.gz
openbsd-97ff0b8011f923270c9adb50e24c2b4c4a533238.tar.bz2
openbsd-97ff0b8011f923270c9adb50e24c2b4c4a533238.zip
Fix an annoying quirk in the EC code
Dealing with elliptic curves makes some people think that it would be kind of neat to multiply types with variable names. Sometimes. Only in function definitions.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ec/ec2_mult.c6
-rw-r--r--src/lib/libcrypto/ec/ec2_oct.c4
-rw-r--r--src/lib/libcrypto/ec/ec2_smpl.c34
-rw-r--r--src/lib/libcrypto/ec/ec_ameth.c50
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c28
-rw-r--r--src/lib/libcrypto/ec/ec_check.c4
-rw-r--r--src/lib/libcrypto/ec/ec_curve.c4
-rw-r--r--src/lib/libcrypto/ec/ec_key.c46
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c60
-rw-r--r--src/lib/libcrypto/ec/ec_mult.c14
-rw-r--r--src/lib/libcrypto/ec/ec_pmeth.c22
-rw-r--r--src/lib/libcrypto/ec/ec_print.c18
-rw-r--r--src/lib/libcrypto/ec/eck_prn.c18
-rw-r--r--src/lib/libcrypto/ec/ecp_mont.c10
-rw-r--r--src/lib/libcrypto/ec/ecp_nist.c8
-rw-r--r--src/lib/libcrypto/ec/ecp_nistp224.c28
-rw-r--r--src/lib/libcrypto/ec/ecp_nistp256.c32
-rw-r--r--src/lib/libcrypto/ec/ecp_nistp521.c30
-rw-r--r--src/lib/libcrypto/ec/ecp_oct.c14
-rw-r--r--src/lib/libcrypto/ec/ecp_smpl.c56
20 files changed, 243 insertions, 243 deletions
diff --git a/src/lib/libcrypto/ec/ec2_mult.c b/src/lib/libcrypto/ec/ec2_mult.c
index 3e5d1dca85..c44ac5c3db 100644
--- a/src/lib/libcrypto/ec/ec2_mult.c
+++ b/src/lib/libcrypto/ec/ec2_mult.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec2_mult.c,v 1.13 2018/07/23 18:24:22 tb Exp $ */ 1/* $OpenBSD: ec2_mult.c,v 1.14 2022/11/19 07:29:29 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -441,13 +441,13 @@ ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
441 * because ec_GF2m_simple_mul() uses ec_wNAF_mul() if appropriate */ 441 * because ec_GF2m_simple_mul() uses ec_wNAF_mul() if appropriate */
442 442
443int 443int
444ec_GF2m_precompute_mult(EC_GROUP * group, BN_CTX * ctx) 444ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
445{ 445{
446 return ec_wNAF_precompute_mult(group, ctx); 446 return ec_wNAF_precompute_mult(group, ctx);
447} 447}
448 448
449int 449int
450ec_GF2m_have_precompute_mult(const EC_GROUP * group) 450ec_GF2m_have_precompute_mult(const EC_GROUP *group)
451{ 451{
452 return ec_wNAF_have_precompute_mult(group); 452 return ec_wNAF_have_precompute_mult(group);
453} 453}
diff --git a/src/lib/libcrypto/ec/ec2_oct.c b/src/lib/libcrypto/ec/ec2_oct.c
index b25084ef58..be29203292 100644
--- a/src/lib/libcrypto/ec/ec2_oct.c
+++ b/src/lib/libcrypto/ec/ec2_oct.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec2_oct.c,v 1.17 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec2_oct.c,v 1.18 2022/11/19 07:29:29 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -175,7 +175,7 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point
175size_t 175size_t
176ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, 176ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
177 point_conversion_form_t form, 177 point_conversion_form_t form,
178 unsigned char *buf, size_t len, BN_CTX * ctx) 178 unsigned char *buf, size_t len, BN_CTX *ctx)
179{ 179{
180 size_t ret; 180 size_t ret;
181 BN_CTX *new_ctx = NULL; 181 BN_CTX *new_ctx = NULL;
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c
index 17664d0426..b3030edeee 100644
--- a/src/lib/libcrypto/ec/ec2_smpl.c
+++ b/src/lib/libcrypto/ec/ec2_smpl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec2_smpl.c,v 1.24 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec2_smpl.c,v 1.25 2022/11/19 07:29:29 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -127,7 +127,7 @@ EC_GF2m_simple_method(void)
127 * Note that all other members are handled by EC_GROUP_new. 127 * Note that all other members are handled by EC_GROUP_new.
128 */ 128 */
129int 129int
130ec_GF2m_simple_group_init(EC_GROUP * group) 130ec_GF2m_simple_group_init(EC_GROUP *group)
131{ 131{
132 BN_init(&group->field); 132 BN_init(&group->field);
133 BN_init(&group->a); 133 BN_init(&group->a);
@@ -140,7 +140,7 @@ ec_GF2m_simple_group_init(EC_GROUP * group)
140 * Note that all other members are handled by EC_GROUP_free. 140 * Note that all other members are handled by EC_GROUP_free.
141 */ 141 */
142void 142void
143ec_GF2m_simple_group_finish(EC_GROUP * group) 143ec_GF2m_simple_group_finish(EC_GROUP *group)
144{ 144{
145 BN_free(&group->field); 145 BN_free(&group->field);
146 BN_free(&group->a); 146 BN_free(&group->a);
@@ -152,7 +152,7 @@ ec_GF2m_simple_group_finish(EC_GROUP * group)
152 * Note that all other members are handled by EC_GROUP_clear_free. 152 * Note that all other members are handled by EC_GROUP_clear_free.
153 */ 153 */
154void 154void
155ec_GF2m_simple_group_clear_finish(EC_GROUP * group) 155ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
156{ 156{
157 BN_clear_free(&group->field); 157 BN_clear_free(&group->field);
158 BN_clear_free(&group->a); 158 BN_clear_free(&group->a);
@@ -170,7 +170,7 @@ ec_GF2m_simple_group_clear_finish(EC_GROUP * group)
170 * Note that all other members are handled by EC_GROUP_copy. 170 * Note that all other members are handled by EC_GROUP_copy.
171 */ 171 */
172int 172int
173ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) 173ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
174{ 174{
175 int i; 175 int i;
176 176
@@ -200,8 +200,8 @@ ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src)
200 200
201/* Set the curve parameters of an EC_GROUP structure. */ 201/* Set the curve parameters of an EC_GROUP structure. */
202int 202int
203ec_GF2m_simple_group_set_curve(EC_GROUP * group, 203ec_GF2m_simple_group_set_curve(EC_GROUP *group,
204 const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 204 const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
205{ 205{
206 int ret = 0, i; 206 int ret = 0, i;
207 207
@@ -265,7 +265,7 @@ ec_GF2m_simple_group_get_curve(const EC_GROUP *group,
265 265
266/* Gets the degree of the field. For a curve over GF(2^m) this is the value m. */ 266/* Gets the degree of the field. For a curve over GF(2^m) this is the value m. */
267int 267int
268ec_GF2m_simple_group_get_degree(const EC_GROUP * group) 268ec_GF2m_simple_group_get_degree(const EC_GROUP *group)
269{ 269{
270 return BN_num_bits(&group->field) - 1; 270 return BN_num_bits(&group->field) - 1;
271} 271}
@@ -275,7 +275,7 @@ ec_GF2m_simple_group_get_degree(const EC_GROUP * group)
275 * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) 275 * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p)
276 */ 276 */
277int 277int
278ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) 278ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
279{ 279{
280 int ret = 0; 280 int ret = 0;
281 BIGNUM *b; 281 BIGNUM *b;
@@ -314,7 +314,7 @@ ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)
314 314
315/* Initializes an EC_POINT. */ 315/* Initializes an EC_POINT. */
316int 316int
317ec_GF2m_simple_point_init(EC_POINT * point) 317ec_GF2m_simple_point_init(EC_POINT *point)
318{ 318{
319 BN_init(&point->X); 319 BN_init(&point->X);
320 BN_init(&point->Y); 320 BN_init(&point->Y);
@@ -325,7 +325,7 @@ ec_GF2m_simple_point_init(EC_POINT * point)
325 325
326/* Frees an EC_POINT. */ 326/* Frees an EC_POINT. */
327void 327void
328ec_GF2m_simple_point_finish(EC_POINT * point) 328ec_GF2m_simple_point_finish(EC_POINT *point)
329{ 329{
330 BN_free(&point->X); 330 BN_free(&point->X);
331 BN_free(&point->Y); 331 BN_free(&point->Y);
@@ -335,7 +335,7 @@ ec_GF2m_simple_point_finish(EC_POINT * point)
335 335
336/* Clears and frees an EC_POINT. */ 336/* Clears and frees an EC_POINT. */
337void 337void
338ec_GF2m_simple_point_clear_finish(EC_POINT * point) 338ec_GF2m_simple_point_clear_finish(EC_POINT *point)
339{ 339{
340 BN_clear_free(&point->X); 340 BN_clear_free(&point->X);
341 BN_clear_free(&point->Y); 341 BN_clear_free(&point->Y);
@@ -346,7 +346,7 @@ ec_GF2m_simple_point_clear_finish(EC_POINT * point)
346 346
347/* Copy the contents of one EC_POINT into another. Assumes dest is initialized. */ 347/* Copy the contents of one EC_POINT into another. Assumes dest is initialized. */
348int 348int
349ec_GF2m_simple_point_copy(EC_POINT * dest, const EC_POINT * src) 349ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
350{ 350{
351 if (!BN_copy(&dest->X, &src->X)) 351 if (!BN_copy(&dest->X, &src->X))
352 return 0; 352 return 0;
@@ -364,7 +364,7 @@ ec_GF2m_simple_point_copy(EC_POINT * dest, const EC_POINT * src)
364 * A point at infinity is represented by having Z=0. 364 * A point at infinity is represented by having Z=0.
365 */ 365 */
366int 366int
367ec_GF2m_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) 367ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
368{ 368{
369 point->Z_is_one = 0; 369 point->Z_is_one = 0;
370 BN_zero(&point->Z); 370 BN_zero(&point->Z);
@@ -376,8 +376,8 @@ ec_GF2m_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point)
376 * Note that the simple implementation only uses affine coordinates. 376 * Note that the simple implementation only uses affine coordinates.
377 */ 377 */
378int 378int
379ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, 379ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
380 const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) 380 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
381{ 381{
382 int ret = 0; 382 int ret = 0;
383 if (x == NULL || y == NULL) { 383 if (x == NULL || y == NULL) {
@@ -701,7 +701,7 @@ ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a,
701 701
702/* Forces the given EC_POINT to internally use affine coordinates. */ 702/* Forces the given EC_POINT to internally use affine coordinates. */
703int 703int
704ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) 704ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
705{ 705{
706 BN_CTX *new_ctx = NULL; 706 BN_CTX *new_ctx = NULL;
707 BIGNUM *x, *y; 707 BIGNUM *x, *y;
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c
index ee931a93c6..b6f21ade63 100644
--- a/src/lib/libcrypto/ec/ec_ameth.c
+++ b/src/lib/libcrypto/ec/ec_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_ameth.c,v 1.34 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_ameth.c,v 1.35 2022/11/19 07:29:29 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -76,7 +76,7 @@ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri);
76#endif 76#endif
77 77
78static int 78static int
79eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key) 79eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key)
80{ 80{
81 const EC_GROUP *group; 81 const EC_GROUP *group;
82 int nid; 82 int nid;
@@ -108,7 +108,7 @@ eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key)
108} 108}
109 109
110static int 110static int
111eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey) 111eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
112{ 112{
113 EC_KEY *ec_key = pkey->pkey.ec; 113 EC_KEY *ec_key = pkey->pkey.ec;
114 void *pval = NULL; 114 void *pval = NULL;
@@ -191,7 +191,7 @@ eckey_type2param(int ptype, const void *pval)
191} 191}
192 192
193static int 193static int
194eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) 194eckey_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
195{ 195{
196 const unsigned char *p = NULL; 196 const unsigned char *p = NULL;
197 const void *pval; 197 const void *pval;
@@ -224,7 +224,7 @@ eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey)
224} 224}
225 225
226static int 226static int
227eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) 227eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
228{ 228{
229 int r; 229 int r;
230 const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec); 230 const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec);
@@ -239,7 +239,7 @@ eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b)
239} 239}
240 240
241static int 241static int
242eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8) 242eckey_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
243{ 243{
244 const unsigned char *p = NULL; 244 const unsigned char *p = NULL;
245 const void *pval; 245 const void *pval;
@@ -306,7 +306,7 @@ eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8)
306} 306}
307 307
308static int 308static int
309eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey) 309eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
310{ 310{
311 EC_KEY *ec_key; 311 EC_KEY *ec_key;
312 unsigned char *ep, *p; 312 unsigned char *ep, *p;
@@ -359,13 +359,13 @@ eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey)
359} 359}
360 360
361static int 361static int
362int_ec_size(const EVP_PKEY * pkey) 362int_ec_size(const EVP_PKEY *pkey)
363{ 363{
364 return ECDSA_size(pkey->pkey.ec); 364 return ECDSA_size(pkey->pkey.ec);
365} 365}
366 366
367static int 367static int
368ec_bits(const EVP_PKEY * pkey) 368ec_bits(const EVP_PKEY *pkey)
369{ 369{
370 BIGNUM *order = BN_new(); 370 BIGNUM *order = BN_new();
371 const EC_GROUP *group; 371 const EC_GROUP *group;
@@ -406,7 +406,7 @@ ec_security_bits(const EVP_PKEY *pkey)
406} 406}
407 407
408static int 408static int
409ec_missing_parameters(const EVP_PKEY * pkey) 409ec_missing_parameters(const EVP_PKEY *pkey)
410{ 410{
411 if (EC_KEY_get0_group(pkey->pkey.ec) == NULL) 411 if (EC_KEY_get0_group(pkey->pkey.ec) == NULL)
412 return 1; 412 return 1;
@@ -414,13 +414,13 @@ ec_missing_parameters(const EVP_PKEY * pkey)
414} 414}
415 415
416static int 416static int
417ec_copy_parameters(EVP_PKEY * to, const EVP_PKEY * from) 417ec_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
418{ 418{
419 return EC_KEY_set_group(to->pkey.ec, EC_KEY_get0_group(from->pkey.ec)); 419 return EC_KEY_set_group(to->pkey.ec, EC_KEY_get0_group(from->pkey.ec));
420} 420}
421 421
422static int 422static int
423ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b) 423ec_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
424{ 424{
425 const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), *group_b = EC_KEY_get0_group(b->pkey.ec); 425 const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), *group_b = EC_KEY_get0_group(b->pkey.ec);
426 if (EC_GROUP_cmp(group_a, group_b, NULL)) 426 if (EC_GROUP_cmp(group_a, group_b, NULL))
@@ -430,13 +430,13 @@ ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b)
430} 430}
431 431
432static void 432static void
433int_ec_free(EVP_PKEY * pkey) 433int_ec_free(EVP_PKEY *pkey)
434{ 434{
435 EC_KEY_free(pkey->pkey.ec); 435 EC_KEY_free(pkey->pkey.ec);
436} 436}
437 437
438static int 438static int
439do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) 439do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
440{ 440{
441 unsigned char *buffer = NULL; 441 unsigned char *buffer = NULL;
442 const char *ecstr; 442 const char *ecstr;
@@ -520,7 +520,7 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype)
520} 520}
521 521
522static int 522static int
523eckey_param_decode(EVP_PKEY * pkey, 523eckey_param_decode(EVP_PKEY *pkey,
524 const unsigned char **pder, int derlen) 524 const unsigned char **pder, int derlen)
525{ 525{
526 EC_KEY *eckey; 526 EC_KEY *eckey;
@@ -533,35 +533,35 @@ eckey_param_decode(EVP_PKEY * pkey,
533} 533}
534 534
535static int 535static int
536eckey_param_encode(const EVP_PKEY * pkey, unsigned char **pder) 536eckey_param_encode(const EVP_PKEY *pkey, unsigned char **pder)
537{ 537{
538 return i2d_ECParameters(pkey->pkey.ec, pder); 538 return i2d_ECParameters(pkey->pkey.ec, pder);
539} 539}
540 540
541static int 541static int
542eckey_param_print(BIO * bp, const EVP_PKEY * pkey, int indent, 542eckey_param_print(BIO *bp, const EVP_PKEY *pkey, int indent,
543 ASN1_PCTX * ctx) 543 ASN1_PCTX *ctx)
544{ 544{
545 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0); 545 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0);
546} 546}
547 547
548static int 548static int
549eckey_pub_print(BIO * bp, const EVP_PKEY * pkey, int indent, 549eckey_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent,
550 ASN1_PCTX * ctx) 550 ASN1_PCTX *ctx)
551{ 551{
552 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1); 552 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1);
553} 553}
554 554
555 555
556static int 556static int
557eckey_priv_print(BIO * bp, const EVP_PKEY * pkey, int indent, 557eckey_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent,
558 ASN1_PCTX * ctx) 558 ASN1_PCTX *ctx)
559{ 559{
560 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2); 560 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2);
561} 561}
562 562
563static int 563static int
564old_ec_priv_decode(EVP_PKEY * pkey, 564old_ec_priv_decode(EVP_PKEY *pkey,
565 const unsigned char **pder, int derlen) 565 const unsigned char **pder, int derlen)
566{ 566{
567 EC_KEY *ec; 567 EC_KEY *ec;
@@ -574,13 +574,13 @@ old_ec_priv_decode(EVP_PKEY * pkey,
574} 574}
575 575
576static int 576static int
577old_ec_priv_encode(const EVP_PKEY * pkey, unsigned char **pder) 577old_ec_priv_encode(const EVP_PKEY *pkey, unsigned char **pder)
578{ 578{
579 return i2d_ECPrivateKey(pkey->pkey.ec, pder); 579 return i2d_ECPrivateKey(pkey->pkey.ec, pder);
580} 580}
581 581
582static int 582static int
583ec_pkey_ctrl(EVP_PKEY * pkey, int op, long arg1, void *arg2) 583ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
584{ 584{
585 switch (op) { 585 switch (op) {
586 case ASN1_PKEY_CTRL_PKCS7_SIGN: 586 case ASN1_PKEY_CTRL_PKCS7_SIGN:
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c
index baa58b5183..974afffe78 100644
--- a/src/lib/libcrypto/ec/ec_asn1.c
+++ b/src/lib/libcrypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_asn1.c,v 1.38 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_asn1.c,v 1.39 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -68,7 +68,7 @@
68#include "ec_lcl.h" 68#include "ec_lcl.h"
69 69
70int 70int
71EC_GROUP_get_basis_type(const EC_GROUP * group) 71EC_GROUP_get_basis_type(const EC_GROUP *group)
72{ 72{
73 int i = 0; 73 int i = 0;
74 74
@@ -91,7 +91,7 @@ EC_GROUP_get_basis_type(const EC_GROUP * group)
91 91
92#ifndef OPENSSL_NO_EC2M 92#ifndef OPENSSL_NO_EC2M
93int 93int
94EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) 94EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k)
95{ 95{
96 if (group == NULL) 96 if (group == NULL)
97 return 0; 97 return 0;
@@ -109,7 +109,7 @@ EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k)
109} 109}
110 110
111int 111int
112EC_GROUP_get_pentanomial_basis(const EC_GROUP * group, unsigned int *k1, 112EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1,
113 unsigned int *k2, unsigned int *k3) 113 unsigned int *k2, unsigned int *k3)
114{ 114{
115 if (group == NULL) 115 if (group == NULL)
@@ -683,7 +683,7 @@ static ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *,
683/* the function definitions */ 683/* the function definitions */
684 684
685static int 685static int
686ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) 686ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
687{ 687{
688 int ok = 0, nid; 688 int ok = 0, nid;
689 BIGNUM *tmp = NULL; 689 BIGNUM *tmp = NULL;
@@ -799,7 +799,7 @@ ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field)
799} 799}
800 800
801static int 801static int
802ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) 802ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
803{ 803{
804 BIGNUM *tmp_1 = NULL, *tmp_2 = NULL; 804 BIGNUM *tmp_1 = NULL, *tmp_2 = NULL;
805 unsigned char *buffer_1 = NULL, *buffer_2 = NULL, *a_buf = NULL, 805 unsigned char *buffer_1 = NULL, *buffer_2 = NULL, *a_buf = NULL,
@@ -894,7 +894,7 @@ ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve)
894} 894}
895 895
896static ECPARAMETERS * 896static ECPARAMETERS *
897ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param) 897ec_asn1_group2parameters(const EC_GROUP *group, ECPARAMETERS *param)
898{ 898{
899 int ok = 0; 899 int ok = 0;
900 size_t len = 0; 900 size_t len = 0;
@@ -989,7 +989,7 @@ ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param)
989} 989}
990 990
991ECPKPARAMETERS * 991ECPKPARAMETERS *
992ec_asn1_group2pkparameters(const EC_GROUP * group, ECPKPARAMETERS * params) 992ec_asn1_group2pkparameters(const EC_GROUP *group, ECPKPARAMETERS *params)
993{ 993{
994 int ok = 1, tmp; 994 int ok = 1, tmp;
995 ECPKPARAMETERS *ret = params; 995 ECPKPARAMETERS *ret = params;
@@ -1035,7 +1035,7 @@ ec_asn1_group2pkparameters(const EC_GROUP * group, ECPKPARAMETERS * params)
1035} 1035}
1036 1036
1037static EC_GROUP * 1037static EC_GROUP *
1038ec_asn1_parameters2group(const ECPARAMETERS * params) 1038ec_asn1_parameters2group(const ECPARAMETERS *params)
1039{ 1039{
1040 int ok = 0, tmp; 1040 int ok = 0, tmp;
1041 EC_GROUP *ret = NULL; 1041 EC_GROUP *ret = NULL;
@@ -1247,7 +1247,7 @@ ec_asn1_parameters2group(const ECPARAMETERS * params)
1247} 1247}
1248 1248
1249EC_GROUP * 1249EC_GROUP *
1250ec_asn1_pkparameters2group(const ECPKPARAMETERS * params) 1250ec_asn1_pkparameters2group(const ECPKPARAMETERS *params)
1251{ 1251{
1252 EC_GROUP *ret = NULL; 1252 EC_GROUP *ret = NULL;
1253 int tmp = 0; 1253 int tmp = 0;
@@ -1309,7 +1309,7 @@ d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len)
1309} 1309}
1310 1310
1311int 1311int
1312i2d_ECPKParameters(const EC_GROUP * a, unsigned char **out) 1312i2d_ECPKParameters(const EC_GROUP *a, unsigned char **out)
1313{ 1313{
1314 int ret = 0; 1314 int ret = 0;
1315 ECPKPARAMETERS *tmp = ec_asn1_group2pkparameters(a, NULL); 1315 ECPKPARAMETERS *tmp = ec_asn1_group2pkparameters(a, NULL);
@@ -1421,7 +1421,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len)
1421} 1421}
1422 1422
1423int 1423int
1424i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) 1424i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
1425{ 1425{
1426 int ret = 0, ok = 0; 1426 int ret = 0, ok = 0;
1427 unsigned char *buffer = NULL; 1427 unsigned char *buffer = NULL;
@@ -1505,7 +1505,7 @@ i2d_ECPrivateKey(EC_KEY * a, unsigned char **out)
1505} 1505}
1506 1506
1507int 1507int
1508i2d_ECParameters(EC_KEY * a, unsigned char **out) 1508i2d_ECParameters(EC_KEY *a, unsigned char **out)
1509{ 1509{
1510 if (a == NULL) { 1510 if (a == NULL) {
1511 ECerror(ERR_R_PASSED_NULL_PARAMETER); 1511 ECerror(ERR_R_PASSED_NULL_PARAMETER);
@@ -1570,7 +1570,7 @@ o2i_ECPublicKey(EC_KEY ** a, const unsigned char **in, long len)
1570} 1570}
1571 1571
1572int 1572int
1573i2o_ECPublicKey(const EC_KEY * a, unsigned char **out) 1573i2o_ECPublicKey(const EC_KEY *a, unsigned char **out)
1574{ 1574{
1575 size_t buf_len = 0; 1575 size_t buf_len = 0;
1576 int new_buffer = 0; 1576 int new_buffer = 0;
diff --git a/src/lib/libcrypto/ec/ec_check.c b/src/lib/libcrypto/ec/ec_check.c
index 3f6a802374..cc54ded3e7 100644
--- a/src/lib/libcrypto/ec/ec_check.c
+++ b/src/lib/libcrypto/ec/ec_check.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_check.c,v 1.10 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_check.c,v 1.11 2022/11/19 07:29:29 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -57,7 +57,7 @@
57#include <openssl/err.h> 57#include <openssl/err.h>
58 58
59int 59int
60EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) 60EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx)
61{ 61{
62 int ret = 0; 62 int ret = 0;
63 BIGNUM *order; 63 BIGNUM *order;
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c
index 1f69d4f1dc..592a367a82 100644
--- a/src/lib/libcrypto/ec/ec_curve.c
+++ b/src/lib/libcrypto/ec/ec_curve.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_curve.c,v 1.23 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_curve.c,v 1.24 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -3434,7 +3434,7 @@ EC_GROUP_new_by_curve_name(int nid)
3434} 3434}
3435 3435
3436size_t 3436size_t
3437EC_get_builtin_curves(EC_builtin_curve * r, size_t nitems) 3437EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems)
3438{ 3438{
3439 size_t i, min; 3439 size_t i, min;
3440 3440
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c
index 3aa6a96eb8..fa8d463220 100644
--- a/src/lib/libcrypto/ec/ec_key.c
+++ b/src/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_key.c,v 1.27 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_key.c,v 1.28 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -99,7 +99,7 @@ EC_KEY_new_by_curve_name(int nid)
99} 99}
100 100
101void 101void
102EC_KEY_free(EC_KEY * r) 102EC_KEY_free(EC_KEY *r)
103{ 103{
104 int i; 104 int i;
105 105
@@ -128,7 +128,7 @@ EC_KEY_free(EC_KEY * r)
128} 128}
129 129
130EC_KEY * 130EC_KEY *
131EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) 131EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
132{ 132{
133 EC_EXTRA_DATA *d; 133 EC_EXTRA_DATA *d;
134 134
@@ -215,7 +215,7 @@ EC_KEY_copy(EC_KEY * dest, const EC_KEY * src)
215} 215}
216 216
217EC_KEY * 217EC_KEY *
218EC_KEY_dup(const EC_KEY * ec_key) 218EC_KEY_dup(const EC_KEY *ec_key)
219{ 219{
220 EC_KEY *ret; 220 EC_KEY *ret;
221 221
@@ -229,7 +229,7 @@ EC_KEY_dup(const EC_KEY * ec_key)
229} 229}
230 230
231int 231int
232EC_KEY_up_ref(EC_KEY * r) 232EC_KEY_up_ref(EC_KEY *r)
233{ 233{
234 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC); 234 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC);
235 return ((i > 1) ? 1 : 0); 235 return ((i > 1) ? 1 : 0);
@@ -309,7 +309,7 @@ ossl_ec_key_gen(EC_KEY *eckey)
309} 309}
310 310
311int 311int
312EC_KEY_check_key(const EC_KEY * eckey) 312EC_KEY_check_key(const EC_KEY *eckey)
313{ 313{
314 int ok = 0; 314 int ok = 0;
315 BN_CTX *ctx = NULL; 315 BN_CTX *ctx = NULL;
@@ -376,7 +376,7 @@ EC_KEY_check_key(const EC_KEY * eckey)
376} 376}
377 377
378int 378int
379EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) 379EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y)
380{ 380{
381 BN_CTX *ctx = NULL; 381 BN_CTX *ctx = NULL;
382 BIGNUM *tx, *ty; 382 BIGNUM *tx, *ty;
@@ -429,13 +429,13 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y)
429} 429}
430 430
431const EC_GROUP * 431const EC_GROUP *
432EC_KEY_get0_group(const EC_KEY * key) 432EC_KEY_get0_group(const EC_KEY *key)
433{ 433{
434 return key->group; 434 return key->group;
435} 435}
436 436
437int 437int
438EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group) 438EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)
439{ 439{
440 if (key->meth->set_group != NULL && 440 if (key->meth->set_group != NULL &&
441 key->meth->set_group(key, group) == 0) 441 key->meth->set_group(key, group) == 0)
@@ -446,13 +446,13 @@ EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group)
446} 446}
447 447
448const BIGNUM * 448const BIGNUM *
449EC_KEY_get0_private_key(const EC_KEY * key) 449EC_KEY_get0_private_key(const EC_KEY *key)
450{ 450{
451 return key->priv_key; 451 return key->priv_key;
452} 452}
453 453
454int 454int
455EC_KEY_set_private_key(EC_KEY * key, const BIGNUM * priv_key) 455EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key)
456{ 456{
457 if (key->meth->set_private != NULL && 457 if (key->meth->set_private != NULL &&
458 key->meth->set_private(key, priv_key) == 0) 458 key->meth->set_private(key, priv_key) == 0)
@@ -463,13 +463,13 @@ EC_KEY_set_private_key(EC_KEY * key, const BIGNUM * priv_key)
463} 463}
464 464
465const EC_POINT * 465const EC_POINT *
466EC_KEY_get0_public_key(const EC_KEY * key) 466EC_KEY_get0_public_key(const EC_KEY *key)
467{ 467{
468 return key->pub_key; 468 return key->pub_key;
469} 469}
470 470
471int 471int
472EC_KEY_set_public_key(EC_KEY * key, const EC_POINT * pub_key) 472EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key)
473{ 473{
474 if (key->meth->set_public != NULL && 474 if (key->meth->set_public != NULL &&
475 key->meth->set_public(key, pub_key) == 0) 475 key->meth->set_public(key, pub_key) == 0)
@@ -480,25 +480,25 @@ EC_KEY_set_public_key(EC_KEY * key, const EC_POINT * pub_key)
480} 480}
481 481
482unsigned int 482unsigned int
483EC_KEY_get_enc_flags(const EC_KEY * key) 483EC_KEY_get_enc_flags(const EC_KEY *key)
484{ 484{
485 return key->enc_flag; 485 return key->enc_flag;
486} 486}
487 487
488void 488void
489EC_KEY_set_enc_flags(EC_KEY * key, unsigned int flags) 489EC_KEY_set_enc_flags(EC_KEY *key, unsigned int flags)
490{ 490{
491 key->enc_flag = flags; 491 key->enc_flag = flags;
492} 492}
493 493
494point_conversion_form_t 494point_conversion_form_t
495EC_KEY_get_conv_form(const EC_KEY * key) 495EC_KEY_get_conv_form(const EC_KEY *key)
496{ 496{
497 return key->conv_form; 497 return key->conv_form;
498} 498}
499 499
500void 500void
501EC_KEY_set_conv_form(EC_KEY * key, point_conversion_form_t cform) 501EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform)
502{ 502{
503 key->conv_form = cform; 503 key->conv_form = cform;
504 if (key->group != NULL) 504 if (key->group != NULL)
@@ -521,7 +521,7 @@ EC_KEY_get_key_method_data(EC_KEY *key,
521} 521}
522 522
523void * 523void *
524EC_KEY_insert_key_method_data(EC_KEY * key, void *data, 524EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
525 void *(*dup_func) (void *), 525 void *(*dup_func) (void *),
526 void (*free_func) (void *), 526 void (*free_func) (void *),
527 void (*clear_free_func) (void *)) 527 void (*clear_free_func) (void *))
@@ -538,14 +538,14 @@ EC_KEY_insert_key_method_data(EC_KEY * key, void *data,
538} 538}
539 539
540void 540void
541EC_KEY_set_asn1_flag(EC_KEY * key, int flag) 541EC_KEY_set_asn1_flag(EC_KEY *key, int flag)
542{ 542{
543 if (key->group != NULL) 543 if (key->group != NULL)
544 EC_GROUP_set_asn1_flag(key->group, flag); 544 EC_GROUP_set_asn1_flag(key->group, flag);
545} 545}
546 546
547int 547int
548EC_KEY_precompute_mult(EC_KEY * key, BN_CTX * ctx) 548EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx)
549{ 549{
550 if (key->group == NULL) 550 if (key->group == NULL)
551 return 0; 551 return 0;
@@ -553,19 +553,19 @@ EC_KEY_precompute_mult(EC_KEY * key, BN_CTX * ctx)
553} 553}
554 554
555int 555int
556EC_KEY_get_flags(const EC_KEY * key) 556EC_KEY_get_flags(const EC_KEY *key)
557{ 557{
558 return key->flags; 558 return key->flags;
559} 559}
560 560
561void 561void
562EC_KEY_set_flags(EC_KEY * key, int flags) 562EC_KEY_set_flags(EC_KEY *key, int flags)
563{ 563{
564 key->flags |= flags; 564 key->flags |= flags;
565} 565}
566 566
567void 567void
568EC_KEY_clear_flags(EC_KEY * key, int flags) 568EC_KEY_clear_flags(EC_KEY *key, int flags)
569{ 569{
570 key->flags &= ~flags; 570 key->flags &= ~flags;
571} 571}
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index 4ec17d5d5d..151e91b36c 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.45 2022/04/07 17:37:25 tb Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.46 2022/11/19 07:29:29 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 */
@@ -74,7 +74,7 @@
74/* functions for EC_GROUP objects */ 74/* functions for EC_GROUP objects */
75 75
76EC_GROUP * 76EC_GROUP *
77EC_GROUP_new(const EC_METHOD * meth) 77EC_GROUP_new(const EC_METHOD *meth)
78{ 78{
79 EC_GROUP *ret; 79 EC_GROUP *ret;
80 80
@@ -115,7 +115,7 @@ EC_GROUP_new(const EC_METHOD * meth)
115 115
116 116
117void 117void
118EC_GROUP_free(EC_GROUP * group) 118EC_GROUP_free(EC_GROUP *group)
119{ 119{
120 if (!group) 120 if (!group)
121 return; 121 return;
@@ -136,7 +136,7 @@ EC_GROUP_free(EC_GROUP * group)
136 136
137 137
138void 138void
139EC_GROUP_clear_free(EC_GROUP * group) 139EC_GROUP_clear_free(EC_GROUP *group)
140{ 140{
141 if (!group) 141 if (!group)
142 return; 142 return;
@@ -158,7 +158,7 @@ EC_GROUP_clear_free(EC_GROUP * group)
158 158
159 159
160int 160int
161EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) 161EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
162{ 162{
163 EC_EXTRA_DATA *d; 163 EC_EXTRA_DATA *d;
164 164
@@ -227,7 +227,7 @@ EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src)
227 227
228 228
229EC_GROUP * 229EC_GROUP *
230EC_GROUP_dup(const EC_GROUP * a) 230EC_GROUP_dup(const EC_GROUP *a)
231{ 231{
232 EC_GROUP *t = NULL; 232 EC_GROUP *t = NULL;
233 233
@@ -428,35 +428,35 @@ EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
428 428
429 429
430void 430void
431EC_GROUP_set_curve_name(EC_GROUP * group, int nid) 431EC_GROUP_set_curve_name(EC_GROUP *group, int nid)
432{ 432{
433 group->curve_name = nid; 433 group->curve_name = nid;
434} 434}
435 435
436 436
437int 437int
438EC_GROUP_get_curve_name(const EC_GROUP * group) 438EC_GROUP_get_curve_name(const EC_GROUP *group)
439{ 439{
440 return group->curve_name; 440 return group->curve_name;
441} 441}
442 442
443 443
444void 444void
445EC_GROUP_set_asn1_flag(EC_GROUP * group, int flag) 445EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag)
446{ 446{
447 group->asn1_flag = flag; 447 group->asn1_flag = flag;
448} 448}
449 449
450 450
451int 451int
452EC_GROUP_get_asn1_flag(const EC_GROUP * group) 452EC_GROUP_get_asn1_flag(const EC_GROUP *group)
453{ 453{
454 return group->asn1_flag; 454 return group->asn1_flag;
455} 455}
456 456
457 457
458void 458void
459EC_GROUP_set_point_conversion_form(EC_GROUP * group, 459EC_GROUP_set_point_conversion_form(EC_GROUP *group,
460 point_conversion_form_t form) 460 point_conversion_form_t form)
461{ 461{
462 group->asn1_form = form; 462 group->asn1_form = form;
@@ -464,14 +464,14 @@ EC_GROUP_set_point_conversion_form(EC_GROUP * group,
464 464
465 465
466point_conversion_form_t 466point_conversion_form_t
467EC_GROUP_get_point_conversion_form(const EC_GROUP * group) 467EC_GROUP_get_point_conversion_form(const EC_GROUP *group)
468{ 468{
469 return group->asn1_form; 469 return group->asn1_form;
470} 470}
471 471
472 472
473size_t 473size_t
474EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len) 474EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len)
475{ 475{
476 if (group->seed) { 476 if (group->seed) {
477 free(group->seed); 477 free(group->seed);
@@ -491,14 +491,14 @@ EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len)
491 491
492 492
493unsigned char * 493unsigned char *
494EC_GROUP_get0_seed(const EC_GROUP * group) 494EC_GROUP_get0_seed(const EC_GROUP *group)
495{ 495{
496 return group->seed; 496 return group->seed;
497} 497}
498 498
499 499
500size_t 500size_t
501EC_GROUP_get_seed_len(const EC_GROUP * group) 501EC_GROUP_get_seed_len(const EC_GROUP *group)
502{ 502{
503 return group->seed_len; 503 return group->seed_len;
504} 504}
@@ -556,7 +556,7 @@ EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
556#endif 556#endif
557 557
558int 558int
559EC_GROUP_get_degree(const EC_GROUP * group) 559EC_GROUP_get_degree(const EC_GROUP *group)
560{ 560{
561 if (group->meth->group_get_degree == 0) { 561 if (group->meth->group_get_degree == 0) {
562 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 562 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -567,7 +567,7 @@ EC_GROUP_get_degree(const EC_GROUP * group)
567 567
568 568
569int 569int
570EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) 570EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
571{ 571{
572 if (group->meth->group_check_discriminant == 0) { 572 if (group->meth->group_check_discriminant == 0) {
573 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 573 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -578,7 +578,7 @@ EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)
578 578
579 579
580int 580int
581EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) 581EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
582{ 582{
583 int r = 0; 583 int r = 0;
584 BIGNUM *a1, *a2, *a3, *b1, *b2, *b3; 584 BIGNUM *a1, *a2, *a3, *b1, *b2, *b3;
@@ -710,7 +710,7 @@ EC_EX_DATA_set_data(EC_EXTRA_DATA ** ex_data, void *data,
710 710
711/* this has 'package' visibility */ 711/* this has 'package' visibility */
712void * 712void *
713EC_EX_DATA_get_data(const EC_EXTRA_DATA * ex_data, 713EC_EX_DATA_get_data(const EC_EXTRA_DATA *ex_data,
714 void *(*dup_func) (void *), 714 void *(*dup_func) (void *),
715 void (*free_func) (void *), 715 void (*free_func) (void *),
716 void (*clear_free_func) (void *)) 716 void (*clear_free_func) (void *))
@@ -825,7 +825,7 @@ EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA ** ex_data)
825/* functions for EC_POINT objects */ 825/* functions for EC_POINT objects */
826 826
827EC_POINT * 827EC_POINT *
828EC_POINT_new(const EC_GROUP * group) 828EC_POINT_new(const EC_GROUP *group)
829{ 829{
830 EC_POINT *ret; 830 EC_POINT *ret;
831 831
@@ -853,7 +853,7 @@ EC_POINT_new(const EC_GROUP * group)
853 853
854 854
855void 855void
856EC_POINT_free(EC_POINT * point) 856EC_POINT_free(EC_POINT *point)
857{ 857{
858 if (!point) 858 if (!point)
859 return; 859 return;
@@ -865,7 +865,7 @@ EC_POINT_free(EC_POINT * point)
865 865
866 866
867void 867void
868EC_POINT_clear_free(EC_POINT * point) 868EC_POINT_clear_free(EC_POINT *point)
869{ 869{
870 if (!point) 870 if (!point)
871 return; 871 return;
@@ -879,7 +879,7 @@ EC_POINT_clear_free(EC_POINT * point)
879 879
880 880
881int 881int
882EC_POINT_copy(EC_POINT * dest, const EC_POINT * src) 882EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)
883{ 883{
884 if (dest->meth->point_copy == 0) { 884 if (dest->meth->point_copy == 0) {
885 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 885 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -896,7 +896,7 @@ EC_POINT_copy(EC_POINT * dest, const EC_POINT * src)
896 896
897 897
898EC_POINT * 898EC_POINT *
899EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group) 899EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group)
900{ 900{
901 EC_POINT *t; 901 EC_POINT *t;
902 int r; 902 int r;
@@ -917,14 +917,14 @@ EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group)
917 917
918 918
919const EC_METHOD * 919const EC_METHOD *
920EC_POINT_method_of(const EC_POINT * point) 920EC_POINT_method_of(const EC_POINT *point)
921{ 921{
922 return point->meth; 922 return point->meth;
923} 923}
924 924
925 925
926int 926int
927EC_POINT_set_to_infinity(const EC_GROUP * group, EC_POINT * point) 927EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
928{ 928{
929 if (group->meth->point_set_to_infinity == 0) { 929 if (group->meth->point_set_to_infinity == 0) {
930 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 930 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -1113,7 +1113,7 @@ EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
1113 1113
1114 1114
1115int 1115int
1116EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) 1116EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
1117{ 1117{
1118 if (group->meth->is_on_curve == 0) { 1118 if (group->meth->is_on_curve == 0) {
1119 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 1119 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -1129,7 +1129,7 @@ EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ct
1129 1129
1130int 1130int
1131EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, 1131EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
1132 BN_CTX * ctx) 1132 BN_CTX *ctx)
1133{ 1133{
1134 if (group->meth->point_cmp == 0) { 1134 if (group->meth->point_cmp == 0) {
1135 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 1135 ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
@@ -1258,7 +1258,7 @@ EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
1258} 1258}
1259 1259
1260int 1260int
1261EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) 1261EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
1262{ 1262{
1263 if (group->meth->precompute_mult != 0) 1263 if (group->meth->precompute_mult != 0)
1264 return group->meth->precompute_mult(group, ctx); 1264 return group->meth->precompute_mult(group, ctx);
@@ -1267,7 +1267,7 @@ EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx)
1267} 1267}
1268 1268
1269int 1269int
1270EC_GROUP_have_precompute_mult(const EC_GROUP * group) 1270EC_GROUP_have_precompute_mult(const EC_GROUP *group)
1271{ 1271{
1272 if (group->meth->have_precompute_mult != 0) 1272 if (group->meth->have_precompute_mult != 0)
1273 return group->meth->have_precompute_mult(group); 1273 return group->meth->have_precompute_mult(group);
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c
index 1198a6f6b1..a3da62323a 100644
--- a/src/lib/libcrypto/ec/ec_mult.c
+++ b/src/lib/libcrypto/ec/ec_mult.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_mult.c,v 1.25 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_mult.c,v 1.26 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. 3 * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -98,7 +98,7 @@ static void ec_pre_comp_free(void *);
98static void ec_pre_comp_clear_free(void *); 98static void ec_pre_comp_clear_free(void *);
99 99
100static EC_PRE_COMP * 100static EC_PRE_COMP *
101ec_pre_comp_new(const EC_GROUP * group) 101ec_pre_comp_new(const EC_GROUP *group)
102{ 102{
103 EC_PRE_COMP *ret = NULL; 103 EC_PRE_COMP *ret = NULL;
104 104
@@ -192,7 +192,7 @@ ec_pre_comp_clear_free(void *pre_)
192 * w-1 zeros away from that next non-zero digit. 192 * w-1 zeros away from that next non-zero digit.
193 */ 193 */
194static signed char * 194static signed char *
195compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len) 195compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
196{ 196{
197 int window_val; 197 int window_val;
198 int ok = 0; 198 int ok = 0;
@@ -332,8 +332,8 @@ compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len)
332 * in the addition if scalar != NULL 332 * in the addition if scalar != NULL
333 */ 333 */
334int 334int
335ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, 335ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
336 size_t num, const EC_POINT * points[], const BIGNUM * scalars[], BN_CTX * ctx) 336 size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx)
337{ 337{
338 BN_CTX *new_ctx = NULL; 338 BN_CTX *new_ctx = NULL;
339 const EC_POINT *generator = NULL; 339 const EC_POINT *generator = NULL;
@@ -722,7 +722,7 @@ ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar,
722 * points[2^(w-1)*numblocks] = NULL 722 * points[2^(w-1)*numblocks] = NULL
723 */ 723 */
724int 724int
725ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) 725ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
726{ 726{
727 const EC_POINT *generator; 727 const EC_POINT *generator;
728 EC_POINT *tmp_point = NULL, *base = NULL, **var; 728 EC_POINT *tmp_point = NULL, *base = NULL, **var;
@@ -876,7 +876,7 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx)
876 876
877 877
878int 878int
879ec_wNAF_have_precompute_mult(const EC_GROUP * group) 879ec_wNAF_have_precompute_mult(const EC_GROUP *group)
880{ 880{
881 if (EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free) != NULL) 881 if (EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free) != NULL)
882 return 1; 882 return 1;
diff --git a/src/lib/libcrypto/ec/ec_pmeth.c b/src/lib/libcrypto/ec/ec_pmeth.c
index 3637d6bba6..80c09b1e21 100644
--- a/src/lib/libcrypto/ec/ec_pmeth.c
+++ b/src/lib/libcrypto/ec/ec_pmeth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_pmeth.c,v 1.14 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_pmeth.c,v 1.15 2022/11/19 07:29:29 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -94,7 +94,7 @@ typedef struct {
94} EC_PKEY_CTX; 94} EC_PKEY_CTX;
95 95
96static int 96static int
97pkey_ec_init(EVP_PKEY_CTX * ctx) 97pkey_ec_init(EVP_PKEY_CTX *ctx)
98{ 98{
99 EC_PKEY_CTX *dctx; 99 EC_PKEY_CTX *dctx;
100 100
@@ -112,7 +112,7 @@ pkey_ec_init(EVP_PKEY_CTX * ctx)
112} 112}
113 113
114static int 114static int
115pkey_ec_copy(EVP_PKEY_CTX * dst, EVP_PKEY_CTX * src) 115pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
116{ 116{
117 EC_PKEY_CTX *dctx, *sctx; 117 EC_PKEY_CTX *dctx, *sctx;
118 if (!pkey_ec_init(dst)) 118 if (!pkey_ec_init(dst))
@@ -147,7 +147,7 @@ pkey_ec_copy(EVP_PKEY_CTX * dst, EVP_PKEY_CTX * src)
147} 147}
148 148
149static void 149static void
150pkey_ec_cleanup(EVP_PKEY_CTX * ctx) 150pkey_ec_cleanup(EVP_PKEY_CTX *ctx)
151{ 151{
152 EC_PKEY_CTX *dctx = ctx->data; 152 EC_PKEY_CTX *dctx = ctx->data;
153 153
@@ -161,7 +161,7 @@ pkey_ec_cleanup(EVP_PKEY_CTX * ctx)
161} 161}
162 162
163static int 163static int
164pkey_ec_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, size_t * siglen, 164pkey_ec_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
165 const unsigned char *tbs, size_t tbslen) 165 const unsigned char *tbs, size_t tbslen)
166{ 166{
167 int ret, type; 167 int ret, type;
@@ -189,7 +189,7 @@ pkey_ec_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, size_t * siglen,
189} 189}
190 190
191static int 191static int
192pkey_ec_verify(EVP_PKEY_CTX * ctx, 192pkey_ec_verify(EVP_PKEY_CTX *ctx,
193 const unsigned char *sig, size_t siglen, 193 const unsigned char *sig, size_t siglen,
194 const unsigned char *tbs, size_t tbslen) 194 const unsigned char *tbs, size_t tbslen)
195{ 195{
@@ -208,7 +208,7 @@ pkey_ec_verify(EVP_PKEY_CTX * ctx,
208} 208}
209 209
210static int 210static int
211pkey_ec_derive(EVP_PKEY_CTX * ctx, unsigned char *key, size_t * keylen) 211pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
212{ 212{
213 int ret; 213 int ret;
214 size_t outlen; 214 size_t outlen;
@@ -284,7 +284,7 @@ pkey_ec_kdf_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
284} 284}
285 285
286static int 286static int
287pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2) 287pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
288{ 288{
289 EC_PKEY_CTX *dctx = ctx->data; 289 EC_PKEY_CTX *dctx = ctx->data;
290 EC_GROUP *group; 290 EC_GROUP *group;
@@ -411,7 +411,7 @@ pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2)
411} 411}
412 412
413static int 413static int
414pkey_ec_ctrl_str(EVP_PKEY_CTX * ctx, const char *type, const char *value) 414pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value)
415{ 415{
416 if (!strcmp(type, "ec_paramgen_curve")) { 416 if (!strcmp(type, "ec_paramgen_curve")) {
417 int nid; 417 int nid;
@@ -450,7 +450,7 @@ pkey_ec_ctrl_str(EVP_PKEY_CTX * ctx, const char *type, const char *value)
450} 450}
451 451
452static int 452static int
453pkey_ec_paramgen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) 453pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
454{ 454{
455 EC_KEY *ec = NULL; 455 EC_KEY *ec = NULL;
456 EC_PKEY_CTX *dctx = ctx->data; 456 EC_PKEY_CTX *dctx = ctx->data;
@@ -471,7 +471,7 @@ pkey_ec_paramgen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey)
471} 471}
472 472
473static int 473static int
474pkey_ec_keygen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) 474pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
475{ 475{
476 EC_KEY *ec = NULL; 476 EC_KEY *ec = NULL;
477 EC_PKEY_CTX *dctx = ctx->data; 477 EC_PKEY_CTX *dctx = ctx->data;
diff --git a/src/lib/libcrypto/ec/ec_print.c b/src/lib/libcrypto/ec/ec_print.c
index af4d1996c0..18d7a7a01f 100644
--- a/src/lib/libcrypto/ec/ec_print.c
+++ b/src/lib/libcrypto/ec/ec_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_print.c,v 1.7 2014/12/03 19:53:20 deraadt Exp $ */ 1/* $OpenBSD: ec_print.c,v 1.8 2022/11/19 07:29:29 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -57,8 +57,8 @@
57#include "ec_lcl.h" 57#include "ec_lcl.h"
58 58
59BIGNUM * 59BIGNUM *
60EC_POINT_point2bn(const EC_GROUP * group, const EC_POINT * point, 60EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point,
61 point_conversion_form_t form, BIGNUM * ret, BN_CTX * ctx) 61 point_conversion_form_t form, BIGNUM *ret, BN_CTX *ctx)
62{ 62{
63 size_t buf_len = 0; 63 size_t buf_len = 0;
64 unsigned char *buf; 64 unsigned char *buf;
@@ -83,8 +83,8 @@ EC_POINT_point2bn(const EC_GROUP * group, const EC_POINT * point,
83} 83}
84 84
85EC_POINT * 85EC_POINT *
86EC_POINT_bn2point(const EC_GROUP * group, 86EC_POINT_bn2point(const EC_GROUP *group,
87 const BIGNUM * bn, EC_POINT * point, BN_CTX * ctx) 87 const BIGNUM *bn, EC_POINT *point, BN_CTX *ctx)
88{ 88{
89 size_t buf_len = 0; 89 size_t buf_len = 0;
90 unsigned char *buf; 90 unsigned char *buf;
@@ -122,8 +122,8 @@ static const char *HEX_DIGITS = "0123456789ABCDEF";
122 122
123/* the return value must be freed (using free()) */ 123/* the return value must be freed (using free()) */
124char * 124char *
125EC_POINT_point2hex(const EC_GROUP * group, const EC_POINT * point, 125EC_POINT_point2hex(const EC_GROUP *group, const EC_POINT *point,
126 point_conversion_form_t form, BN_CTX * ctx) 126 point_conversion_form_t form, BN_CTX *ctx)
127{ 127{
128 char *ret, *p; 128 char *ret, *p;
129 size_t buf_len = 0, i; 129 size_t buf_len = 0, i;
@@ -161,8 +161,8 @@ EC_POINT_point2hex(const EC_GROUP * group, const EC_POINT * point,
161} 161}
162 162
163EC_POINT * 163EC_POINT *
164EC_POINT_hex2point(const EC_GROUP * group, const char *buf, 164EC_POINT_hex2point(const EC_GROUP *group, const char *buf,
165 EC_POINT * point, BN_CTX * ctx) 165 EC_POINT *point, BN_CTX *ctx)
166{ 166{
167 EC_POINT *ret = NULL; 167 EC_POINT *ret = NULL;
168 BIGNUM *tmp_bn = NULL; 168 BIGNUM *tmp_bn = NULL;
diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c
index 14185c7605..f7ce8debb0 100644
--- a/src/lib/libcrypto/ec/eck_prn.c
+++ b/src/lib/libcrypto/ec/eck_prn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: eck_prn.c,v 1.19 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: eck_prn.c,v 1.20 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -70,7 +70,7 @@
70#include <openssl/evp.h> 70#include <openssl/evp.h>
71 71
72int 72int
73ECPKParameters_print_fp(FILE * fp, const EC_GROUP * x, int off) 73ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off)
74{ 74{
75 BIO *b; 75 BIO *b;
76 int ret; 76 int ret;
@@ -86,7 +86,7 @@ ECPKParameters_print_fp(FILE * fp, const EC_GROUP * x, int off)
86} 86}
87 87
88int 88int
89EC_KEY_print_fp(FILE * fp, const EC_KEY * x, int off) 89EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off)
90{ 90{
91 BIO *b; 91 BIO *b;
92 int ret; 92 int ret;
@@ -102,7 +102,7 @@ EC_KEY_print_fp(FILE * fp, const EC_KEY * x, int off)
102} 102}
103 103
104int 104int
105ECParameters_print_fp(FILE * fp, const EC_KEY * x) 105ECParameters_print_fp(FILE *fp, const EC_KEY *x)
106{ 106{
107 BIO *b; 107 BIO *b;
108 int ret; 108 int ret;
@@ -118,7 +118,7 @@ ECParameters_print_fp(FILE * fp, const EC_KEY * x)
118} 118}
119 119
120int 120int
121EC_KEY_print(BIO * bp, const EC_KEY * x, int off) 121EC_KEY_print(BIO *bp, const EC_KEY *x, int off)
122{ 122{
123 EVP_PKEY *pk; 123 EVP_PKEY *pk;
124 int ret = 0; 124 int ret = 0;
@@ -136,7 +136,7 @@ EC_KEY_print(BIO * bp, const EC_KEY * x, int off)
136} 136}
137 137
138int 138int
139ECParameters_print(BIO * bp, const EC_KEY * x) 139ECParameters_print(BIO *bp, const EC_KEY *x)
140{ 140{
141 EVP_PKEY *pk; 141 EVP_PKEY *pk;
142 int ret = 0; 142 int ret = 0;
@@ -154,11 +154,11 @@ ECParameters_print(BIO * bp, const EC_KEY * x)
154} 154}
155 155
156static int 156static int
157print_bin(BIO * fp, const char *str, const unsigned char *num, 157print_bin(BIO *fp, const char *str, const unsigned char *num,
158 size_t len, int off); 158 size_t len, int off);
159 159
160int 160int
161ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) 161ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off)
162{ 162{
163 unsigned char *buffer = NULL; 163 unsigned char *buffer = NULL;
164 size_t buf_len = 0, i; 164 size_t buf_len = 0, i;
@@ -334,7 +334,7 @@ ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off)
334} 334}
335 335
336static int 336static int
337print_bin(BIO * fp, const char *name, const unsigned char *buf, 337print_bin(BIO *fp, const char *name, const unsigned char *buf,
338 size_t len, int off) 338 size_t len, int off)
339{ 339{
340 size_t i; 340 size_t i;
diff --git a/src/lib/libcrypto/ec/ecp_mont.c b/src/lib/libcrypto/ec/ecp_mont.c
index 0da3083d8e..da6d2f1cf0 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.20 2021/09/08 17:29:21 tb Exp $ */ 1/* $OpenBSD: ecp_mont.c,v 1.21 2022/11/19 07:29:29 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 */
@@ -119,7 +119,7 @@ EC_GFp_mont_method(void)
119 119
120 120
121int 121int
122ec_GFp_mont_group_init(EC_GROUP * group) 122ec_GFp_mont_group_init(EC_GROUP *group)
123{ 123{
124 int ok; 124 int ok;
125 125
@@ -131,7 +131,7 @@ ec_GFp_mont_group_init(EC_GROUP * group)
131 131
132 132
133void 133void
134ec_GFp_mont_group_finish(EC_GROUP * group) 134ec_GFp_mont_group_finish(EC_GROUP *group)
135{ 135{
136 BN_MONT_CTX_free(group->field_data1); 136 BN_MONT_CTX_free(group->field_data1);
137 group->field_data1 = NULL; 137 group->field_data1 = NULL;
@@ -142,7 +142,7 @@ ec_GFp_mont_group_finish(EC_GROUP * group)
142 142
143 143
144void 144void
145ec_GFp_mont_group_clear_finish(EC_GROUP * group) 145ec_GFp_mont_group_clear_finish(EC_GROUP *group)
146{ 146{
147 BN_MONT_CTX_free(group->field_data1); 147 BN_MONT_CTX_free(group->field_data1);
148 group->field_data1 = NULL; 148 group->field_data1 = NULL;
@@ -153,7 +153,7 @@ ec_GFp_mont_group_clear_finish(EC_GROUP * group)
153 153
154 154
155int 155int
156ec_GFp_mont_group_copy(EC_GROUP * dest, const EC_GROUP * src) 156ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src)
157{ 157{
158 BN_MONT_CTX_free(dest->field_data1); 158 BN_MONT_CTX_free(dest->field_data1);
159 dest->field_data1 = NULL; 159 dest->field_data1 = NULL;
diff --git a/src/lib/libcrypto/ec/ecp_nist.c b/src/lib/libcrypto/ec/ecp_nist.c
index b3cea0c4c0..d3cb4f37b7 100644
--- a/src/lib/libcrypto/ec/ecp_nist.c
+++ b/src/lib/libcrypto/ec/ecp_nist.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_nist.c,v 1.19 2022/06/30 11:14:47 tb Exp $ */ 1/* $OpenBSD: ecp_nist.c,v 1.20 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -117,7 +117,7 @@ EC_GFp_nist_method(void)
117} 117}
118 118
119int 119int
120ec_GFp_nist_group_copy(EC_GROUP * dest, const EC_GROUP * src) 120ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
121{ 121{
122 dest->field_mod_func = src->field_mod_func; 122 dest->field_mod_func = src->field_mod_func;
123 123
@@ -192,8 +192,8 @@ ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
192 192
193 193
194int 194int
195ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, 195ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
196 BN_CTX * ctx) 196 BN_CTX *ctx)
197{ 197{
198 int ret = 0; 198 int ret = 0;
199 BN_CTX *ctx_new = NULL; 199 BN_CTX *ctx_new = NULL;
diff --git a/src/lib/libcrypto/ec/ecp_nistp224.c b/src/lib/libcrypto/ec/ecp_nistp224.c
index 9ef9dc3585..70944c463d 100644
--- a/src/lib/libcrypto/ec/ecp_nistp224.c
+++ b/src/lib/libcrypto/ec/ecp_nistp224.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_nistp224.c,v 1.27 2021/09/08 17:29:21 tb Exp $ */ 1/* $OpenBSD: ecp_nistp224.c,v 1.28 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Emilia Kasper (Google) for the OpenSSL project. 3 * Written by Emilia Kasper (Google) for the OpenSSL project.
4 */ 4 */
@@ -302,7 +302,7 @@ felem_to_bin28(u8 out[28], const felem in)
302 302
303/* To preserve endianness when using BN_bn2bin and BN_bin2bn */ 303/* To preserve endianness when using BN_bn2bin and BN_bin2bn */
304static void 304static void
305flip_endian(u8 * out, const u8 * in, unsigned len) 305flip_endian(u8 *out, const u8 *in, unsigned len)
306{ 306{
307 unsigned i; 307 unsigned i;
308 for (i = 0; i < len; ++i) 308 for (i = 0; i < len; ++i)
@@ -311,7 +311,7 @@ flip_endian(u8 * out, const u8 * in, unsigned len)
311 311
312/* From OpenSSL BIGNUM to internal representation */ 312/* From OpenSSL BIGNUM to internal representation */
313static int 313static int
314BN_to_felem(felem out, const BIGNUM * bn) 314BN_to_felem(felem out, const BIGNUM *bn)
315{ 315{
316 felem_bytearray b_in; 316 felem_bytearray b_in;
317 felem_bytearray b_out; 317 felem_bytearray b_out;
@@ -336,7 +336,7 @@ BN_to_felem(felem out, const BIGNUM * bn)
336 336
337/* From internal representation to OpenSSL BIGNUM */ 337/* From internal representation to OpenSSL BIGNUM */
338static BIGNUM * 338static BIGNUM *
339felem_to_BN(BIGNUM * out, const felem in) 339felem_to_BN(BIGNUM *out, const felem in)
340{ 340{
341 felem_bytearray b_in, b_out; 341 felem_bytearray b_in, b_out;
342 felem_to_bin28(b_in, in); 342 felem_to_bin28(b_in, in);
@@ -1249,7 +1249,7 @@ nistp224_pre_comp_clear_free(void *pre_)
1249 */ 1249 */
1250 1250
1251int 1251int
1252ec_GFp_nistp224_group_init(EC_GROUP * group) 1252ec_GFp_nistp224_group_init(EC_GROUP *group)
1253{ 1253{
1254 int ret; 1254 int ret;
1255 ret = ec_GFp_simple_group_init(group); 1255 ret = ec_GFp_simple_group_init(group);
@@ -1258,8 +1258,8 @@ ec_GFp_nistp224_group_init(EC_GROUP * group)
1258} 1258}
1259 1259
1260int 1260int
1261ec_GFp_nistp224_group_set_curve(EC_GROUP * group, const BIGNUM * p, 1261ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p,
1262 const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 1262 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1263{ 1263{
1264 int ret = 0; 1264 int ret = 0;
1265 BN_CTX *new_ctx = NULL; 1265 BN_CTX *new_ctx = NULL;
@@ -1292,8 +1292,8 @@ ec_GFp_nistp224_group_set_curve(EC_GROUP * group, const BIGNUM * p,
1292/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns 1292/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns
1293 * (X', Y') = (X/Z^2, Y/Z^3) */ 1293 * (X', Y') = (X/Z^2, Y/Z^3) */
1294int 1294int
1295ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP * group, 1295ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group,
1296 const EC_POINT * point, BIGNUM * x, BIGNUM * y, BN_CTX * ctx) 1296 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
1297{ 1297{
1298 felem z1, z2, x_in, y_in, x_out, y_out; 1298 felem z1, z2, x_in, y_in, x_out, y_out;
1299 widefelem tmp; 1299 widefelem tmp;
@@ -1355,9 +1355,9 @@ make_points_affine(size_t num, felem points[ /* num */ ][3], felem tmp_felems[ /
1355/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values 1355/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values
1356 * Result is stored in r (r can equal one of the inputs). */ 1356 * Result is stored in r (r can equal one of the inputs). */
1357int 1357int
1358ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, 1358ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,
1359 const BIGNUM * scalar, size_t num, const EC_POINT * points[], 1359 const BIGNUM *scalar, size_t num, const EC_POINT *points[],
1360 const BIGNUM * scalars[], BN_CTX * ctx) 1360 const BIGNUM *scalars[], BN_CTX *ctx)
1361{ 1361{
1362 int ret = 0; 1362 int ret = 0;
1363 int j; 1363 int j;
@@ -1550,7 +1550,7 @@ ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r,
1550} 1550}
1551 1551
1552int 1552int
1553ec_GFp_nistp224_precompute_mult(EC_GROUP * group, BN_CTX * ctx) 1553ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
1554{ 1554{
1555 int ret = 0; 1555 int ret = 0;
1556 NISTP224_PRE_COMP *pre = NULL; 1556 NISTP224_PRE_COMP *pre = NULL;
@@ -1677,7 +1677,7 @@ ec_GFp_nistp224_precompute_mult(EC_GROUP * group, BN_CTX * ctx)
1677} 1677}
1678 1678
1679int 1679int
1680ec_GFp_nistp224_have_precompute_mult(const EC_GROUP * group) 1680ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group)
1681{ 1681{
1682 if (EC_EX_DATA_get_data(group->extra_data, nistp224_pre_comp_dup, 1682 if (EC_EX_DATA_get_data(group->extra_data, nistp224_pre_comp_dup,
1683 nistp224_pre_comp_free, nistp224_pre_comp_clear_free) 1683 nistp224_pre_comp_free, nistp224_pre_comp_clear_free)
diff --git a/src/lib/libcrypto/ec/ecp_nistp256.c b/src/lib/libcrypto/ec/ecp_nistp256.c
index e13621c7b6..8371ee4827 100644
--- a/src/lib/libcrypto/ec/ecp_nistp256.c
+++ b/src/lib/libcrypto/ec/ecp_nistp256.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_nistp256.c,v 1.26 2021/09/08 17:29:21 tb Exp $ */ 1/* $OpenBSD: ecp_nistp256.c,v 1.27 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Adam Langley (Google) for the OpenSSL project 3 * Written by Adam Langley (Google) for the OpenSSL project
4 */ 4 */
@@ -137,7 +137,7 @@ smallfelem_to_bin32(u8 out[32], const smallfelem in)
137 137
138/* To preserve endianness when using BN_bn2bin and BN_bin2bn */ 138/* To preserve endianness when using BN_bn2bin and BN_bin2bn */
139static void 139static void
140flip_endian(u8 * out, const u8 * in, unsigned len) 140flip_endian(u8 *out, const u8 *in, unsigned len)
141{ 141{
142 unsigned i; 142 unsigned i;
143 for (i = 0; i < len; ++i) 143 for (i = 0; i < len; ++i)
@@ -146,7 +146,7 @@ flip_endian(u8 * out, const u8 * in, unsigned len)
146 146
147/* BN_to_felem converts an OpenSSL BIGNUM into an felem */ 147/* BN_to_felem converts an OpenSSL BIGNUM into an felem */
148static int 148static int
149BN_to_felem(felem out, const BIGNUM * bn) 149BN_to_felem(felem out, const BIGNUM *bn)
150{ 150{
151 felem_bytearray b_in; 151 felem_bytearray b_in;
152 felem_bytearray b_out; 152 felem_bytearray b_out;
@@ -171,7 +171,7 @@ BN_to_felem(felem out, const BIGNUM * bn)
171 171
172/* felem_to_BN converts an felem into an OpenSSL BIGNUM */ 172/* felem_to_BN converts an felem into an OpenSSL BIGNUM */
173static BIGNUM * 173static BIGNUM *
174smallfelem_to_BN(BIGNUM * out, const smallfelem in) 174smallfelem_to_BN(BIGNUM *out, const smallfelem in)
175{ 175{
176 felem_bytearray b_in, b_out; 176 felem_bytearray b_in, b_out;
177 smallfelem_to_bin32(b_in, in); 177 smallfelem_to_bin32(b_in, in);
@@ -833,7 +833,7 @@ felem_reduce_zero105(felem out, const longfelem in)
833/* subtract_u64 sets *result = *result - v and *carry to one if the subtraction 833/* subtract_u64 sets *result = *result - v and *carry to one if the subtraction
834 * underflowed. */ 834 * underflowed. */
835static void 835static void
836subtract_u64(u64 * result, u64 * carry, u64 v) 836subtract_u64(u64 *result, u64 *carry, u64 v)
837{ 837{
838 uint128_t r = *result; 838 uint128_t r = *result;
839 r -= v; 839 r -= v;
@@ -1581,7 +1581,7 @@ get_bit(const felem_bytearray in, int i)
1581 * Output point (X, Y, Z) is stored in x_out, y_out, z_out */ 1581 * Output point (X, Y, Z) is stored in x_out, y_out, z_out */
1582static void 1582static void
1583batch_mul(felem x_out, felem y_out, felem z_out, 1583batch_mul(felem x_out, felem y_out, felem z_out,
1584 const felem_bytearray scalars[], const unsigned num_points, const u8 * g_scalar, 1584 const felem_bytearray scalars[], const unsigned num_points, const u8 *g_scalar,
1585 const int mixed, const smallfelem pre_comp[][17][3], const smallfelem g_pre_comp[2][16][3]) 1585 const int mixed, const smallfelem pre_comp[][17][3], const smallfelem g_pre_comp[2][16][3])
1586{ 1586{
1587 int i, skip; 1587 int i, skip;
@@ -1798,7 +1798,7 @@ nistp256_pre_comp_clear_free(void *pre_)
1798 */ 1798 */
1799 1799
1800int 1800int
1801ec_GFp_nistp256_group_init(EC_GROUP * group) 1801ec_GFp_nistp256_group_init(EC_GROUP *group)
1802{ 1802{
1803 int ret; 1803 int ret;
1804 ret = ec_GFp_simple_group_init(group); 1804 ret = ec_GFp_simple_group_init(group);
@@ -1807,8 +1807,8 @@ ec_GFp_nistp256_group_init(EC_GROUP * group)
1807} 1807}
1808 1808
1809int 1809int
1810ec_GFp_nistp256_group_set_curve(EC_GROUP * group, const BIGNUM * p, 1810ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p,
1811 const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 1811 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1812{ 1812{
1813 int ret = 0; 1813 int ret = 0;
1814 BN_CTX *new_ctx = NULL; 1814 BN_CTX *new_ctx = NULL;
@@ -1841,8 +1841,8 @@ ec_GFp_nistp256_group_set_curve(EC_GROUP * group, const BIGNUM * p,
1841/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns 1841/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns
1842 * (X', Y') = (X/Z^2, Y/Z^3) */ 1842 * (X', Y') = (X/Z^2, Y/Z^3) */
1843int 1843int
1844ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP * group, 1844ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group,
1845 const EC_POINT * point, BIGNUM * x, BIGNUM * y, BN_CTX * ctx) 1845 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
1846{ 1846{
1847 felem z1, z2, x_in, y_in; 1847 felem z1, z2, x_in, y_in;
1848 smallfelem x_out, y_out; 1848 smallfelem x_out, y_out;
@@ -1905,9 +1905,9 @@ make_points_affine(size_t num, smallfelem points[ /* num */ ][3], smallfelem tmp
1905/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values 1905/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values
1906 * Result is stored in r (r can equal one of the inputs). */ 1906 * Result is stored in r (r can equal one of the inputs). */
1907int 1907int
1908ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, 1908ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,
1909 const BIGNUM * scalar, size_t num, const EC_POINT * points[], 1909 const BIGNUM *scalar, size_t num, const EC_POINT *points[],
1910 const BIGNUM * scalars[], BN_CTX * ctx) 1910 const BIGNUM *scalars[], BN_CTX *ctx)
1911{ 1911{
1912 int ret = 0; 1912 int ret = 0;
1913 int j; 1913 int j;
@@ -2103,7 +2103,7 @@ ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r,
2103} 2103}
2104 2104
2105int 2105int
2106ec_GFp_nistp256_precompute_mult(EC_GROUP * group, BN_CTX * ctx) 2106ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
2107{ 2107{
2108 int ret = 0; 2108 int ret = 0;
2109 NISTP256_PRE_COMP *pre = NULL; 2109 NISTP256_PRE_COMP *pre = NULL;
@@ -2224,7 +2224,7 @@ ec_GFp_nistp256_precompute_mult(EC_GROUP * group, BN_CTX * ctx)
2224} 2224}
2225 2225
2226int 2226int
2227ec_GFp_nistp256_have_precompute_mult(const EC_GROUP * group) 2227ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group)
2228{ 2228{
2229 if (EC_EX_DATA_get_data(group->extra_data, nistp256_pre_comp_dup, 2229 if (EC_EX_DATA_get_data(group->extra_data, nistp256_pre_comp_dup,
2230 nistp256_pre_comp_free, nistp256_pre_comp_clear_free) 2230 nistp256_pre_comp_free, nistp256_pre_comp_clear_free)
diff --git a/src/lib/libcrypto/ec/ecp_nistp521.c b/src/lib/libcrypto/ec/ecp_nistp521.c
index 994c1039d6..064bf85534 100644
--- a/src/lib/libcrypto/ec/ecp_nistp521.c
+++ b/src/lib/libcrypto/ec/ecp_nistp521.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_nistp521.c,v 1.27 2021/09/08 17:29:21 tb Exp $ */ 1/* $OpenBSD: ecp_nistp521.c,v 1.28 2022/11/19 07:29:29 tb Exp $ */
2/* 2/*
3 * Written by Adam Langley (Google) for the OpenSSL project 3 * Written by Adam Langley (Google) for the OpenSSL project
4 */ 4 */
@@ -163,7 +163,7 @@ felem_to_bin66(u8 out[66], const felem in)
163 163
164/* To preserve endianness when using BN_bn2bin and BN_bin2bn */ 164/* To preserve endianness when using BN_bn2bin and BN_bin2bn */
165static void 165static void
166flip_endian(u8 * out, const u8 * in, unsigned len) 166flip_endian(u8 *out, const u8 *in, unsigned len)
167{ 167{
168 unsigned i; 168 unsigned i;
169 for (i = 0; i < len; ++i) 169 for (i = 0; i < len; ++i)
@@ -172,7 +172,7 @@ flip_endian(u8 * out, const u8 * in, unsigned len)
172 172
173/* BN_to_felem converts an OpenSSL BIGNUM into an felem */ 173/* BN_to_felem converts an OpenSSL BIGNUM into an felem */
174static int 174static int
175BN_to_felem(felem out, const BIGNUM * bn) 175BN_to_felem(felem out, const BIGNUM *bn)
176{ 176{
177 felem_bytearray b_in; 177 felem_bytearray b_in;
178 felem_bytearray b_out; 178 felem_bytearray b_out;
@@ -197,7 +197,7 @@ BN_to_felem(felem out, const BIGNUM * bn)
197 197
198/* felem_to_BN converts an felem into an OpenSSL BIGNUM */ 198/* felem_to_BN converts an felem into an OpenSSL BIGNUM */
199static BIGNUM * 199static BIGNUM *
200felem_to_BN(BIGNUM * out, const felem in) 200felem_to_BN(BIGNUM *out, const felem in)
201{ 201{
202 felem_bytearray b_in, b_out; 202 felem_bytearray b_in, b_out;
203 felem_to_bin66(b_in, in); 203 felem_to_bin66(b_in, in);
@@ -1487,7 +1487,7 @@ get_bit(const felem_bytearray in, int i)
1487 * Output point (X, Y, Z) is stored in x_out, y_out, z_out */ 1487 * Output point (X, Y, Z) is stored in x_out, y_out, z_out */
1488static void 1488static void
1489batch_mul(felem x_out, felem y_out, felem z_out, 1489batch_mul(felem x_out, felem y_out, felem z_out,
1490 const felem_bytearray scalars[], const unsigned num_points, const u8 * g_scalar, 1490 const felem_bytearray scalars[], const unsigned num_points, const u8 *g_scalar,
1491 const int mixed, const felem pre_comp[][17][3], const felem g_pre_comp[16][3]) 1491 const int mixed, const felem pre_comp[][17][3], const felem g_pre_comp[16][3])
1492{ 1492{
1493 int i, skip; 1493 int i, skip;
@@ -1689,7 +1689,7 @@ nistp521_pre_comp_clear_free(void *pre_)
1689 */ 1689 */
1690 1690
1691int 1691int
1692ec_GFp_nistp521_group_init(EC_GROUP * group) 1692ec_GFp_nistp521_group_init(EC_GROUP *group)
1693{ 1693{
1694 int ret; 1694 int ret;
1695 ret = ec_GFp_simple_group_init(group); 1695 ret = ec_GFp_simple_group_init(group);
@@ -1698,8 +1698,8 @@ ec_GFp_nistp521_group_init(EC_GROUP * group)
1698} 1698}
1699 1699
1700int 1700int
1701ec_GFp_nistp521_group_set_curve(EC_GROUP * group, const BIGNUM * p, 1701ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,
1702 const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 1702 const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1703{ 1703{
1704 int ret = 0; 1704 int ret = 0;
1705 BN_CTX *new_ctx = NULL; 1705 BN_CTX *new_ctx = NULL;
@@ -1732,8 +1732,8 @@ ec_GFp_nistp521_group_set_curve(EC_GROUP * group, const BIGNUM * p,
1732/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns 1732/* Takes the Jacobian coordinates (X, Y, Z) of a point and returns
1733 * (X', Y') = (X/Z^2, Y/Z^3) */ 1733 * (X', Y') = (X/Z^2, Y/Z^3) */
1734int 1734int
1735ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP * group, 1735ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group,
1736 const EC_POINT * point, BIGNUM * x, BIGNUM * y, BN_CTX * ctx) 1736 const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
1737{ 1737{
1738 felem z1, z2, x_in, y_in, x_out, y_out; 1738 felem z1, z2, x_in, y_in, x_out, y_out;
1739 largefelem tmp; 1739 largefelem tmp;
@@ -1795,9 +1795,9 @@ make_points_affine(size_t num, felem points[ /* num */ ][3], felem tmp_felems[ /
1795/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values 1795/* Computes scalar*generator + \sum scalars[i]*points[i], ignoring NULL values
1796 * Result is stored in r (r can equal one of the inputs). */ 1796 * Result is stored in r (r can equal one of the inputs). */
1797int 1797int
1798ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, 1798ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,
1799 const BIGNUM * scalar, size_t num, const EC_POINT * points[], 1799 const BIGNUM *scalar, size_t num, const EC_POINT *points[],
1800 const BIGNUM * scalars[], BN_CTX * ctx) 1800 const BIGNUM *scalars[], BN_CTX *ctx)
1801{ 1801{
1802 int ret = 0; 1802 int ret = 0;
1803 int j; 1803 int j;
@@ -1992,7 +1992,7 @@ ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r,
1992} 1992}
1993 1993
1994int 1994int
1995ec_GFp_nistp521_precompute_mult(EC_GROUP * group, BN_CTX * ctx) 1995ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
1996{ 1996{
1997 int ret = 0; 1997 int ret = 0;
1998 NISTP521_PRE_COMP *pre = NULL; 1998 NISTP521_PRE_COMP *pre = NULL;
@@ -2099,7 +2099,7 @@ ec_GFp_nistp521_precompute_mult(EC_GROUP * group, BN_CTX * ctx)
2099} 2099}
2100 2100
2101int 2101int
2102ec_GFp_nistp521_have_precompute_mult(const EC_GROUP * group) 2102ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group)
2103{ 2103{
2104 if (EC_EX_DATA_get_data(group->extra_data, nistp521_pre_comp_dup, 2104 if (EC_EX_DATA_get_data(group->extra_data, nistp521_pre_comp_dup,
2105 nistp521_pre_comp_free, nistp521_pre_comp_clear_free) 2105 nistp521_pre_comp_free, nistp521_pre_comp_clear_free)
diff --git a/src/lib/libcrypto/ec/ecp_oct.c b/src/lib/libcrypto/ec/ecp_oct.c
index 1536b3ee90..7c29e7e612 100644
--- a/src/lib/libcrypto/ec/ecp_oct.c
+++ b/src/lib/libcrypto/ec/ecp_oct.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_oct.c,v 1.15 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ecp_oct.c,v 1.16 2022/11/19 07:29:29 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.
@@ -67,8 +67,8 @@
67#include "ec_lcl.h" 67#include "ec_lcl.h"
68 68
69int 69int
70ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, 70ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
71 EC_POINT * point, const BIGNUM * x_, int y_bit, BN_CTX * ctx) 71 EC_POINT *point, const BIGNUM *x_, int y_bit, BN_CTX *ctx)
72{ 72{
73 BN_CTX *new_ctx = NULL; 73 BN_CTX *new_ctx = NULL;
74 BIGNUM *tmp1, *tmp2, *x, *y; 74 BIGNUM *tmp1, *tmp2, *x, *y;
@@ -198,8 +198,8 @@ ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group,
198 198
199 199
200size_t 200size_t
201ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_conversion_form_t form, 201ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
202 unsigned char *buf, size_t len, BN_CTX * ctx) 202 unsigned char *buf, size_t len, BN_CTX *ctx)
203{ 203{
204 size_t ret; 204 size_t ret;
205 BN_CTX *new_ctx = NULL; 205 BN_CTX *new_ctx = NULL;
@@ -303,8 +303,8 @@ ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_co
303 303
304 304
305int 305int
306ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, 306ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
307 const unsigned char *buf, size_t len, BN_CTX * ctx) 307 const unsigned char *buf, size_t len, BN_CTX *ctx)
308{ 308{
309 point_conversion_form_t form; 309 point_conversion_form_t form;
310 int y_bit; 310 int y_bit;
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c
index c9d73bd629..55fb46869d 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.35 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ecp_smpl.c,v 1.36 2022/11/19 07:29:29 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.
@@ -131,7 +131,7 @@ EC_GFp_simple_method(void)
131 131
132 132
133int 133int
134ec_GFp_simple_group_init(EC_GROUP * group) 134ec_GFp_simple_group_init(EC_GROUP *group)
135{ 135{
136 BN_init(&group->field); 136 BN_init(&group->field);
137 BN_init(&group->a); 137 BN_init(&group->a);
@@ -142,7 +142,7 @@ ec_GFp_simple_group_init(EC_GROUP * group)
142 142
143 143
144void 144void
145ec_GFp_simple_group_finish(EC_GROUP * group) 145ec_GFp_simple_group_finish(EC_GROUP *group)
146{ 146{
147 BN_free(&group->field); 147 BN_free(&group->field);
148 BN_free(&group->a); 148 BN_free(&group->a);
@@ -151,7 +151,7 @@ ec_GFp_simple_group_finish(EC_GROUP * group)
151 151
152 152
153void 153void
154ec_GFp_simple_group_clear_finish(EC_GROUP * group) 154ec_GFp_simple_group_clear_finish(EC_GROUP *group)
155{ 155{
156 BN_clear_free(&group->field); 156 BN_clear_free(&group->field);
157 BN_clear_free(&group->a); 157 BN_clear_free(&group->a);
@@ -160,7 +160,7 @@ ec_GFp_simple_group_clear_finish(EC_GROUP * group)
160 160
161 161
162int 162int
163ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) 163ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
164{ 164{
165 if (!BN_copy(&dest->field, &src->field)) 165 if (!BN_copy(&dest->field, &src->field))
166 return 0; 166 return 0;
@@ -176,8 +176,8 @@ ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src)
176 176
177 177
178int 178int
179ec_GFp_simple_group_set_curve(EC_GROUP * group, 179ec_GFp_simple_group_set_curve(EC_GROUP *group,
180 const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 180 const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
181{ 181{
182 int ret = 0; 182 int ret = 0;
183 BN_CTX *new_ctx = NULL; 183 BN_CTX *new_ctx = NULL;
@@ -233,7 +233,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group,
233 233
234 234
235int 235int
236ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) 236ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
237{ 237{
238 int ret = 0; 238 int ret = 0;
239 BN_CTX *new_ctx = NULL; 239 BN_CTX *new_ctx = NULL;
@@ -277,14 +277,14 @@ ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BI
277 277
278 278
279int 279int
280ec_GFp_simple_group_get_degree(const EC_GROUP * group) 280ec_GFp_simple_group_get_degree(const EC_GROUP *group)
281{ 281{
282 return BN_num_bits(&group->field); 282 return BN_num_bits(&group->field);
283} 283}
284 284
285 285
286int 286int
287ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) 287ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
288{ 288{
289 int ret = 0; 289 int ret = 0;
290 BIGNUM *a, *b, *order, *tmp_1, *tmp_2; 290 BIGNUM *a, *b, *order, *tmp_1, *tmp_2;
@@ -372,7 +372,7 @@ ec_GFp_simple_point_init(EC_POINT * point)
372 372
373 373
374void 374void
375ec_GFp_simple_point_finish(EC_POINT * point) 375ec_GFp_simple_point_finish(EC_POINT *point)
376{ 376{
377 BN_free(&point->X); 377 BN_free(&point->X);
378 BN_free(&point->Y); 378 BN_free(&point->Y);
@@ -381,7 +381,7 @@ ec_GFp_simple_point_finish(EC_POINT * point)
381 381
382 382
383void 383void
384ec_GFp_simple_point_clear_finish(EC_POINT * point) 384ec_GFp_simple_point_clear_finish(EC_POINT *point)
385{ 385{
386 BN_clear_free(&point->X); 386 BN_clear_free(&point->X);
387 BN_clear_free(&point->Y); 387 BN_clear_free(&point->Y);
@@ -391,7 +391,7 @@ ec_GFp_simple_point_clear_finish(EC_POINT * point)
391 391
392 392
393int 393int
394ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src) 394ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
395{ 395{
396 if (!BN_copy(&dest->X, &src->X)) 396 if (!BN_copy(&dest->X, &src->X))
397 return 0; 397 return 0;
@@ -406,7 +406,7 @@ ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src)
406 406
407 407
408int 408int
409ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) 409ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
410{ 410{
411 point->Z_is_one = 0; 411 point->Z_is_one = 0;
412 BN_zero(&point->Z); 412 BN_zero(&point->Z);
@@ -515,8 +515,8 @@ ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *group,
515} 515}
516 516
517int 517int
518ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, 518ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
519 const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) 519 const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
520{ 520{
521 if (x == NULL || y == NULL) { 521 if (x == NULL || y == NULL) {
522 /* unlike for projective coordinates, we do not tolerate this */ 522 /* unlike for projective coordinates, we do not tolerate this */
@@ -528,8 +528,8 @@ ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * po
528} 528}
529 529
530int 530int
531ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POINT * point, 531ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
532 BIGNUM * x, BIGNUM * y, BN_CTX * ctx) 532 BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
533{ 533{
534 BN_CTX *new_ctx = NULL; 534 BN_CTX *new_ctx = NULL;
535 BIGNUM *Z, *Z_1, *Z_2, *Z_3; 535 BIGNUM *Z, *Z_1, *Z_2, *Z_3;
@@ -635,7 +635,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN
635} 635}
636 636
637int 637int
638ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) 638ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
639{ 639{
640 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 640 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
641 int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); 641 int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -824,7 +824,7 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons
824 824
825 825
826int 826int
827ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_CTX * ctx) 827ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
828{ 828{
829 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 829 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
830 int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); 830 int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -966,7 +966,7 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C
966 966
967 967
968int 968int
969ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) 969ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
970{ 970{
971 if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y)) 971 if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y))
972 /* point is its own inverse */ 972 /* point is its own inverse */
@@ -977,14 +977,14 @@ ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx)
977 977
978 978
979int 979int
980ec_GFp_simple_is_at_infinity(const EC_GROUP * group, const EC_POINT * point) 980ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
981{ 981{
982 return BN_is_zero(&point->Z); 982 return BN_is_zero(&point->Z);
983} 983}
984 984
985 985
986int 986int
987ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) 987ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
988{ 988{
989 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 989 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
990 int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); 990 int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -1087,7 +1087,7 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX
1087 1087
1088 1088
1089int 1089int
1090ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) 1090ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
1091{ 1091{
1092 /* 1092 /*
1093 * return values: -1 error 0 equal (in affine coordinates) 1 1093 * return values: -1 error 0 equal (in affine coordinates) 1
@@ -1189,7 +1189,7 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b
1189 1189
1190 1190
1191int 1191int
1192ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) 1192ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1193{ 1193{
1194 BN_CTX *new_ctx = NULL; 1194 BN_CTX *new_ctx = NULL;
1195 BIGNUM *x, *y; 1195 BIGNUM *x, *y;
@@ -1227,7 +1227,7 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx
1227 1227
1228 1228
1229int 1229int
1230ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * points[], BN_CTX * ctx) 1230ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
1231{ 1231{
1232 BN_CTX *new_ctx = NULL; 1232 BN_CTX *new_ctx = NULL;
1233 BIGNUM *tmp0, *tmp1; 1233 BIGNUM *tmp0, *tmp1;
@@ -1402,13 +1402,13 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT *
1402 1402
1403 1403
1404int 1404int
1405ec_GFp_simple_field_mul(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 1405ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1406{ 1406{
1407 return BN_mod_mul(r, a, b, &group->field, ctx); 1407 return BN_mod_mul(r, a, b, &group->field, ctx);
1408} 1408}
1409 1409
1410int 1410int
1411ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx) 1411ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
1412{ 1412{
1413 return BN_mod_sqr(r, a, &group->field, ctx); 1413 return BN_mod_sqr(r, a, &group->field, ctx);
1414} 1414}