diff options
author | tb <> | 2022-11-19 07:29:29 +0000 |
---|---|---|
committer | tb <> | 2022-11-19 07:29:29 +0000 |
commit | 97ff0b8011f923270c9adb50e24c2b4c4a533238 (patch) | |
tree | 744c8fadca050ecfeaa626562148788777b42d2f /src | |
parent | b197546e7fd8128aedea248a6196a0d25734b937 (diff) | |
download | openbsd-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.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec2_oct.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec2_smpl.c | 34 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_ameth.c | 50 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 28 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_check.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_curve.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 46 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 60 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_mult.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_pmeth.c | 22 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_print.c | 18 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/eck_prn.c | 18 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_mont.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_nist.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_nistp224.c | 28 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_nistp256.c | 32 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_nistp521.c | 30 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_oct.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 56 |
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 | ||
443 | int | 443 | int |
444 | ec_GF2m_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | 444 | ec_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 | ||
449 | int | 449 | int |
450 | ec_GF2m_have_precompute_mult(const EC_GROUP * group) | 450 | ec_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 | |||
175 | size_t | 175 | size_t |
176 | ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, | 176 | ec_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 | */ |
129 | int | 129 | int |
130 | ec_GF2m_simple_group_init(EC_GROUP * group) | 130 | ec_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 | */ |
142 | void | 142 | void |
143 | ec_GF2m_simple_group_finish(EC_GROUP * group) | 143 | ec_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 | */ |
154 | void | 154 | void |
155 | ec_GF2m_simple_group_clear_finish(EC_GROUP * group) | 155 | ec_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 | */ |
172 | int | 172 | int |
173 | ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) | 173 | ec_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. */ |
202 | int | 202 | int |
203 | ec_GF2m_simple_group_set_curve(EC_GROUP * group, | 203 | ec_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. */ |
267 | int | 267 | int |
268 | ec_GF2m_simple_group_get_degree(const EC_GROUP * group) | 268 | ec_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 | */ |
277 | int | 277 | int |
278 | ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) | 278 | ec_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. */ |
316 | int | 316 | int |
317 | ec_GF2m_simple_point_init(EC_POINT * point) | 317 | ec_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. */ |
327 | void | 327 | void |
328 | ec_GF2m_simple_point_finish(EC_POINT * point) | 328 | ec_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. */ |
337 | void | 337 | void |
338 | ec_GF2m_simple_point_clear_finish(EC_POINT * point) | 338 | ec_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. */ |
348 | int | 348 | int |
349 | ec_GF2m_simple_point_copy(EC_POINT * dest, const EC_POINT * src) | 349 | ec_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 | */ |
366 | int | 366 | int |
367 | ec_GF2m_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) | 367 | ec_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 | */ |
378 | int | 378 | int |
379 | ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, | 379 | ec_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. */ |
703 | int | 703 | int |
704 | ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) | 704 | ec_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 | ||
78 | static int | 78 | static int |
79 | eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key) | 79 | eckey_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 | ||
110 | static int | 110 | static int |
111 | eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey) | 111 | eckey_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 | ||
193 | static int | 193 | static int |
194 | eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) | 194 | eckey_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 | ||
226 | static int | 226 | static int |
227 | eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) | 227 | eckey_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 | ||
241 | static int | 241 | static int |
242 | eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8) | 242 | eckey_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 | ||
308 | static int | 308 | static int |
309 | eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey) | 309 | eckey_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 | ||
361 | static int | 361 | static int |
362 | int_ec_size(const EVP_PKEY * pkey) | 362 | int_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 | ||
367 | static int | 367 | static int |
368 | ec_bits(const EVP_PKEY * pkey) | 368 | ec_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 | ||
408 | static int | 408 | static int |
409 | ec_missing_parameters(const EVP_PKEY * pkey) | 409 | ec_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 | ||
416 | static int | 416 | static int |
417 | ec_copy_parameters(EVP_PKEY * to, const EVP_PKEY * from) | 417 | ec_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 | ||
422 | static int | 422 | static int |
423 | ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b) | 423 | ec_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 | ||
432 | static void | 432 | static void |
433 | int_ec_free(EVP_PKEY * pkey) | 433 | int_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 | ||
438 | static int | 438 | static int |
439 | do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) | 439 | do_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 | ||
522 | static int | 522 | static int |
523 | eckey_param_decode(EVP_PKEY * pkey, | 523 | eckey_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 | ||
535 | static int | 535 | static int |
536 | eckey_param_encode(const EVP_PKEY * pkey, unsigned char **pder) | 536 | eckey_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 | ||
541 | static int | 541 | static int |
542 | eckey_param_print(BIO * bp, const EVP_PKEY * pkey, int indent, | 542 | eckey_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 | ||
548 | static int | 548 | static int |
549 | eckey_pub_print(BIO * bp, const EVP_PKEY * pkey, int indent, | 549 | eckey_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 | ||
556 | static int | 556 | static int |
557 | eckey_priv_print(BIO * bp, const EVP_PKEY * pkey, int indent, | 557 | eckey_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 | ||
563 | static int | 563 | static int |
564 | old_ec_priv_decode(EVP_PKEY * pkey, | 564 | old_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 | ||
576 | static int | 576 | static int |
577 | old_ec_priv_encode(const EVP_PKEY * pkey, unsigned char **pder) | 577 | old_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 | ||
582 | static int | 582 | static int |
583 | ec_pkey_ctrl(EVP_PKEY * pkey, int op, long arg1, void *arg2) | 583 | ec_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 | ||
70 | int | 70 | int |
71 | EC_GROUP_get_basis_type(const EC_GROUP * group) | 71 | EC_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 |
93 | int | 93 | int |
94 | EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) | 94 | EC_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 | ||
111 | int | 111 | int |
112 | EC_GROUP_get_pentanomial_basis(const EC_GROUP * group, unsigned int *k1, | 112 | EC_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 | ||
685 | static int | 685 | static int |
686 | ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) | 686 | ec_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 | ||
801 | static int | 801 | static int |
802 | ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) | 802 | ec_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 | ||
896 | static ECPARAMETERS * | 896 | static ECPARAMETERS * |
897 | ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param) | 897 | ec_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 | ||
991 | ECPKPARAMETERS * | 991 | ECPKPARAMETERS * |
992 | ec_asn1_group2pkparameters(const EC_GROUP * group, ECPKPARAMETERS * params) | 992 | ec_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 | ||
1037 | static EC_GROUP * | 1037 | static EC_GROUP * |
1038 | ec_asn1_parameters2group(const ECPARAMETERS * params) | 1038 | ec_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 | ||
1249 | EC_GROUP * | 1249 | EC_GROUP * |
1250 | ec_asn1_pkparameters2group(const ECPKPARAMETERS * params) | 1250 | ec_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 | ||
1311 | int | 1311 | int |
1312 | i2d_ECPKParameters(const EC_GROUP * a, unsigned char **out) | 1312 | i2d_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 | ||
1423 | int | 1423 | int |
1424 | i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) | 1424 | i2d_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 | ||
1507 | int | 1507 | int |
1508 | i2d_ECParameters(EC_KEY * a, unsigned char **out) | 1508 | i2d_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 | ||
1572 | int | 1572 | int |
1573 | i2o_ECPublicKey(const EC_KEY * a, unsigned char **out) | 1573 | i2o_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 | ||
59 | int | 59 | int |
60 | EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) | 60 | EC_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 | ||
3436 | size_t | 3436 | size_t |
3437 | EC_get_builtin_curves(EC_builtin_curve * r, size_t nitems) | 3437 | EC_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 | ||
101 | void | 101 | void |
102 | EC_KEY_free(EC_KEY * r) | 102 | EC_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 | ||
130 | EC_KEY * | 130 | EC_KEY * |
131 | EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) | 131 | EC_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 | ||
217 | EC_KEY * | 217 | EC_KEY * |
218 | EC_KEY_dup(const EC_KEY * ec_key) | 218 | EC_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 | ||
231 | int | 231 | int |
232 | EC_KEY_up_ref(EC_KEY * r) | 232 | EC_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 | ||
311 | int | 311 | int |
312 | EC_KEY_check_key(const EC_KEY * eckey) | 312 | EC_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 | ||
378 | int | 378 | int |
379 | EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) | 379 | EC_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 | ||
431 | const EC_GROUP * | 431 | const EC_GROUP * |
432 | EC_KEY_get0_group(const EC_KEY * key) | 432 | EC_KEY_get0_group(const EC_KEY *key) |
433 | { | 433 | { |
434 | return key->group; | 434 | return key->group; |
435 | } | 435 | } |
436 | 436 | ||
437 | int | 437 | int |
438 | EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group) | 438 | EC_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 | ||
448 | const BIGNUM * | 448 | const BIGNUM * |
449 | EC_KEY_get0_private_key(const EC_KEY * key) | 449 | EC_KEY_get0_private_key(const EC_KEY *key) |
450 | { | 450 | { |
451 | return key->priv_key; | 451 | return key->priv_key; |
452 | } | 452 | } |
453 | 453 | ||
454 | int | 454 | int |
455 | EC_KEY_set_private_key(EC_KEY * key, const BIGNUM * priv_key) | 455 | EC_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 | ||
465 | const EC_POINT * | 465 | const EC_POINT * |
466 | EC_KEY_get0_public_key(const EC_KEY * key) | 466 | EC_KEY_get0_public_key(const EC_KEY *key) |
467 | { | 467 | { |
468 | return key->pub_key; | 468 | return key->pub_key; |
469 | } | 469 | } |
470 | 470 | ||
471 | int | 471 | int |
472 | EC_KEY_set_public_key(EC_KEY * key, const EC_POINT * pub_key) | 472 | EC_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 | ||
482 | unsigned int | 482 | unsigned int |
483 | EC_KEY_get_enc_flags(const EC_KEY * key) | 483 | EC_KEY_get_enc_flags(const EC_KEY *key) |
484 | { | 484 | { |
485 | return key->enc_flag; | 485 | return key->enc_flag; |
486 | } | 486 | } |
487 | 487 | ||
488 | void | 488 | void |
489 | EC_KEY_set_enc_flags(EC_KEY * key, unsigned int flags) | 489 | EC_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 | ||
494 | point_conversion_form_t | 494 | point_conversion_form_t |
495 | EC_KEY_get_conv_form(const EC_KEY * key) | 495 | EC_KEY_get_conv_form(const EC_KEY *key) |
496 | { | 496 | { |
497 | return key->conv_form; | 497 | return key->conv_form; |
498 | } | 498 | } |
499 | 499 | ||
500 | void | 500 | void |
501 | EC_KEY_set_conv_form(EC_KEY * key, point_conversion_form_t cform) | 501 | EC_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 | ||
523 | void * | 523 | void * |
524 | EC_KEY_insert_key_method_data(EC_KEY * key, void *data, | 524 | EC_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 | ||
540 | void | 540 | void |
541 | EC_KEY_set_asn1_flag(EC_KEY * key, int flag) | 541 | EC_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 | ||
547 | int | 547 | int |
548 | EC_KEY_precompute_mult(EC_KEY * key, BN_CTX * ctx) | 548 | EC_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 | ||
555 | int | 555 | int |
556 | EC_KEY_get_flags(const EC_KEY * key) | 556 | EC_KEY_get_flags(const EC_KEY *key) |
557 | { | 557 | { |
558 | return key->flags; | 558 | return key->flags; |
559 | } | 559 | } |
560 | 560 | ||
561 | void | 561 | void |
562 | EC_KEY_set_flags(EC_KEY * key, int flags) | 562 | EC_KEY_set_flags(EC_KEY *key, int flags) |
563 | { | 563 | { |
564 | key->flags |= flags; | 564 | key->flags |= flags; |
565 | } | 565 | } |
566 | 566 | ||
567 | void | 567 | void |
568 | EC_KEY_clear_flags(EC_KEY * key, int flags) | 568 | EC_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 | ||
76 | EC_GROUP * | 76 | EC_GROUP * |
77 | EC_GROUP_new(const EC_METHOD * meth) | 77 | EC_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 | ||
117 | void | 117 | void |
118 | EC_GROUP_free(EC_GROUP * group) | 118 | EC_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 | ||
138 | void | 138 | void |
139 | EC_GROUP_clear_free(EC_GROUP * group) | 139 | EC_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 | ||
160 | int | 160 | int |
161 | EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) | 161 | EC_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 | ||
229 | EC_GROUP * | 229 | EC_GROUP * |
230 | EC_GROUP_dup(const EC_GROUP * a) | 230 | EC_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 | ||
430 | void | 430 | void |
431 | EC_GROUP_set_curve_name(EC_GROUP * group, int nid) | 431 | EC_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 | ||
437 | int | 437 | int |
438 | EC_GROUP_get_curve_name(const EC_GROUP * group) | 438 | EC_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 | ||
444 | void | 444 | void |
445 | EC_GROUP_set_asn1_flag(EC_GROUP * group, int flag) | 445 | EC_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 | ||
451 | int | 451 | int |
452 | EC_GROUP_get_asn1_flag(const EC_GROUP * group) | 452 | EC_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 | ||
458 | void | 458 | void |
459 | EC_GROUP_set_point_conversion_form(EC_GROUP * group, | 459 | EC_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 | ||
466 | point_conversion_form_t | 466 | point_conversion_form_t |
467 | EC_GROUP_get_point_conversion_form(const EC_GROUP * group) | 467 | EC_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 | ||
473 | size_t | 473 | size_t |
474 | EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len) | 474 | EC_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 | ||
493 | unsigned char * | 493 | unsigned char * |
494 | EC_GROUP_get0_seed(const EC_GROUP * group) | 494 | EC_GROUP_get0_seed(const EC_GROUP *group) |
495 | { | 495 | { |
496 | return group->seed; | 496 | return group->seed; |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | size_t | 500 | size_t |
501 | EC_GROUP_get_seed_len(const EC_GROUP * group) | 501 | EC_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 | ||
558 | int | 558 | int |
559 | EC_GROUP_get_degree(const EC_GROUP * group) | 559 | EC_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 | ||
569 | int | 569 | int |
570 | EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) | 570 | EC_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 | ||
580 | int | 580 | int |
581 | EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) | 581 | EC_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 */ |
712 | void * | 712 | void * |
713 | EC_EX_DATA_get_data(const EC_EXTRA_DATA * ex_data, | 713 | EC_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 | ||
827 | EC_POINT * | 827 | EC_POINT * |
828 | EC_POINT_new(const EC_GROUP * group) | 828 | EC_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 | ||
855 | void | 855 | void |
856 | EC_POINT_free(EC_POINT * point) | 856 | EC_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 | ||
867 | void | 867 | void |
868 | EC_POINT_clear_free(EC_POINT * point) | 868 | EC_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 | ||
881 | int | 881 | int |
882 | EC_POINT_copy(EC_POINT * dest, const EC_POINT * src) | 882 | EC_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 | ||
898 | EC_POINT * | 898 | EC_POINT * |
899 | EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group) | 899 | EC_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 | ||
919 | const EC_METHOD * | 919 | const EC_METHOD * |
920 | EC_POINT_method_of(const EC_POINT * point) | 920 | EC_POINT_method_of(const EC_POINT *point) |
921 | { | 921 | { |
922 | return point->meth; | 922 | return point->meth; |
923 | } | 923 | } |
924 | 924 | ||
925 | 925 | ||
926 | int | 926 | int |
927 | EC_POINT_set_to_infinity(const EC_GROUP * group, EC_POINT * point) | 927 | EC_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 | ||
1115 | int | 1115 | int |
1116 | EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) | 1116 | EC_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 | ||
1130 | int | 1130 | int |
1131 | EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, | 1131 | EC_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 | ||
1260 | int | 1260 | int |
1261 | EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | 1261 | EC_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 | ||
1269 | int | 1269 | int |
1270 | EC_GROUP_have_precompute_mult(const EC_GROUP * group) | 1270 | EC_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 *); | |||
98 | static void ec_pre_comp_clear_free(void *); | 98 | static void ec_pre_comp_clear_free(void *); |
99 | 99 | ||
100 | static EC_PRE_COMP * | 100 | static EC_PRE_COMP * |
101 | ec_pre_comp_new(const EC_GROUP * group) | 101 | ec_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 | */ |
194 | static signed char * | 194 | static signed char * |
195 | compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len) | 195 | compute_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 | */ |
334 | int | 334 | int |
335 | ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, | 335 | ec_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 | */ |
724 | int | 724 | int |
725 | ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | 725 | ec_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 | ||
878 | int | 878 | int |
879 | ec_wNAF_have_precompute_mult(const EC_GROUP * group) | 879 | ec_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 | ||
96 | static int | 96 | static int |
97 | pkey_ec_init(EVP_PKEY_CTX * ctx) | 97 | pkey_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 | ||
114 | static int | 114 | static int |
115 | pkey_ec_copy(EVP_PKEY_CTX * dst, EVP_PKEY_CTX * src) | 115 | pkey_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 | ||
149 | static void | 149 | static void |
150 | pkey_ec_cleanup(EVP_PKEY_CTX * ctx) | 150 | pkey_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 | ||
163 | static int | 163 | static int |
164 | pkey_ec_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, size_t * siglen, | 164 | pkey_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 | ||
191 | static int | 191 | static int |
192 | pkey_ec_verify(EVP_PKEY_CTX * ctx, | 192 | pkey_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 | ||
210 | static int | 210 | static int |
211 | pkey_ec_derive(EVP_PKEY_CTX * ctx, unsigned char *key, size_t * keylen) | 211 | pkey_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 | ||
286 | static int | 286 | static int |
287 | pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2) | 287 | pkey_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 | ||
413 | static int | 413 | static int |
414 | pkey_ec_ctrl_str(EVP_PKEY_CTX * ctx, const char *type, const char *value) | 414 | pkey_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 | ||
452 | static int | 452 | static int |
453 | pkey_ec_paramgen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) | 453 | pkey_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 | ||
473 | static int | 473 | static int |
474 | pkey_ec_keygen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) | 474 | pkey_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 | ||
59 | BIGNUM * | 59 | BIGNUM * |
60 | EC_POINT_point2bn(const EC_GROUP * group, const EC_POINT * point, | 60 | EC_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 | ||
85 | EC_POINT * | 85 | EC_POINT * |
86 | EC_POINT_bn2point(const EC_GROUP * group, | 86 | EC_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()) */ |
124 | char * | 124 | char * |
125 | EC_POINT_point2hex(const EC_GROUP * group, const EC_POINT * point, | 125 | EC_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 | ||
163 | EC_POINT * | 163 | EC_POINT * |
164 | EC_POINT_hex2point(const EC_GROUP * group, const char *buf, | 164 | EC_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 | ||
72 | int | 72 | int |
73 | ECPKParameters_print_fp(FILE * fp, const EC_GROUP * x, int off) | 73 | ECPKParameters_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 | ||
88 | int | 88 | int |
89 | EC_KEY_print_fp(FILE * fp, const EC_KEY * x, int off) | 89 | EC_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 | ||
104 | int | 104 | int |
105 | ECParameters_print_fp(FILE * fp, const EC_KEY * x) | 105 | ECParameters_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 | ||
120 | int | 120 | int |
121 | EC_KEY_print(BIO * bp, const EC_KEY * x, int off) | 121 | EC_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 | ||
138 | int | 138 | int |
139 | ECParameters_print(BIO * bp, const EC_KEY * x) | 139 | ECParameters_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 | ||
156 | static int | 156 | static int |
157 | print_bin(BIO * fp, const char *str, const unsigned char *num, | 157 | print_bin(BIO *fp, const char *str, const unsigned char *num, |
158 | size_t len, int off); | 158 | size_t len, int off); |
159 | 159 | ||
160 | int | 160 | int |
161 | ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) | 161 | ECPKParameters_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 | ||
336 | static int | 336 | static int |
337 | print_bin(BIO * fp, const char *name, const unsigned char *buf, | 337 | print_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 | ||
121 | int | 121 | int |
122 | ec_GFp_mont_group_init(EC_GROUP * group) | 122 | ec_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 | ||
133 | void | 133 | void |
134 | ec_GFp_mont_group_finish(EC_GROUP * group) | 134 | ec_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 | ||
144 | void | 144 | void |
145 | ec_GFp_mont_group_clear_finish(EC_GROUP * group) | 145 | ec_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 | ||
155 | int | 155 | int |
156 | ec_GFp_mont_group_copy(EC_GROUP * dest, const EC_GROUP * src) | 156 | ec_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 | ||
119 | int | 119 | int |
120 | ec_GFp_nist_group_copy(EC_GROUP * dest, const EC_GROUP * src) | 120 | ec_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 | ||
194 | int | 194 | int |
195 | ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, | 195 | ec_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 */ |
304 | static void | 304 | static void |
305 | flip_endian(u8 * out, const u8 * in, unsigned len) | 305 | flip_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 */ |
313 | static int | 313 | static int |
314 | BN_to_felem(felem out, const BIGNUM * bn) | 314 | BN_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 */ |
338 | static BIGNUM * | 338 | static BIGNUM * |
339 | felem_to_BN(BIGNUM * out, const felem in) | 339 | felem_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 | ||
1251 | int | 1251 | int |
1252 | ec_GFp_nistp224_group_init(EC_GROUP * group) | 1252 | ec_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 | ||
1260 | int | 1260 | int |
1261 | ec_GFp_nistp224_group_set_curve(EC_GROUP * group, const BIGNUM * p, | 1261 | ec_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) */ |
1294 | int | 1294 | int |
1295 | ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP * group, | 1295 | ec_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). */ |
1357 | int | 1357 | int |
1358 | ec_GFp_nistp224_points_mul(const EC_GROUP * group, EC_POINT * r, | 1358 | ec_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 | ||
1552 | int | 1552 | int |
1553 | ec_GFp_nistp224_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | 1553 | ec_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 | ||
1679 | int | 1679 | int |
1680 | ec_GFp_nistp224_have_precompute_mult(const EC_GROUP * group) | 1680 | ec_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 */ |
139 | static void | 139 | static void |
140 | flip_endian(u8 * out, const u8 * in, unsigned len) | 140 | flip_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 */ |
148 | static int | 148 | static int |
149 | BN_to_felem(felem out, const BIGNUM * bn) | 149 | BN_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 */ |
173 | static BIGNUM * | 173 | static BIGNUM * |
174 | smallfelem_to_BN(BIGNUM * out, const smallfelem in) | 174 | smallfelem_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. */ |
835 | static void | 835 | static void |
836 | subtract_u64(u64 * result, u64 * carry, u64 v) | 836 | subtract_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 */ |
1582 | static void | 1582 | static void |
1583 | batch_mul(felem x_out, felem y_out, felem z_out, | 1583 | batch_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 | ||
1800 | int | 1800 | int |
1801 | ec_GFp_nistp256_group_init(EC_GROUP * group) | 1801 | ec_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 | ||
1809 | int | 1809 | int |
1810 | ec_GFp_nistp256_group_set_curve(EC_GROUP * group, const BIGNUM * p, | 1810 | ec_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) */ |
1843 | int | 1843 | int |
1844 | ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP * group, | 1844 | ec_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). */ |
1907 | int | 1907 | int |
1908 | ec_GFp_nistp256_points_mul(const EC_GROUP * group, EC_POINT * r, | 1908 | ec_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 | ||
2105 | int | 2105 | int |
2106 | ec_GFp_nistp256_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | 2106 | ec_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 | ||
2226 | int | 2226 | int |
2227 | ec_GFp_nistp256_have_precompute_mult(const EC_GROUP * group) | 2227 | ec_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 */ |
165 | static void | 165 | static void |
166 | flip_endian(u8 * out, const u8 * in, unsigned len) | 166 | flip_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 */ |
174 | static int | 174 | static int |
175 | BN_to_felem(felem out, const BIGNUM * bn) | 175 | BN_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 */ |
199 | static BIGNUM * | 199 | static BIGNUM * |
200 | felem_to_BN(BIGNUM * out, const felem in) | 200 | felem_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 */ |
1488 | static void | 1488 | static void |
1489 | batch_mul(felem x_out, felem y_out, felem z_out, | 1489 | batch_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 | ||
1691 | int | 1691 | int |
1692 | ec_GFp_nistp521_group_init(EC_GROUP * group) | 1692 | ec_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 | ||
1700 | int | 1700 | int |
1701 | ec_GFp_nistp521_group_set_curve(EC_GROUP * group, const BIGNUM * p, | 1701 | ec_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) */ |
1734 | int | 1734 | int |
1735 | ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP * group, | 1735 | ec_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). */ |
1797 | int | 1797 | int |
1798 | ec_GFp_nistp521_points_mul(const EC_GROUP * group, EC_POINT * r, | 1798 | ec_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 | ||
1994 | int | 1994 | int |
1995 | ec_GFp_nistp521_precompute_mult(EC_GROUP * group, BN_CTX * ctx) | 1995 | ec_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 | ||
2101 | int | 2101 | int |
2102 | ec_GFp_nistp521_have_precompute_mult(const EC_GROUP * group) | 2102 | ec_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 | ||
69 | int | 69 | int |
70 | ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, | 70 | ec_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 | ||
200 | size_t | 200 | size_t |
201 | ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_conversion_form_t form, | 201 | ec_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 | ||
305 | int | 305 | int |
306 | ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, | 306 | ec_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 | ||
133 | int | 133 | int |
134 | ec_GFp_simple_group_init(EC_GROUP * group) | 134 | ec_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 | ||
144 | void | 144 | void |
145 | ec_GFp_simple_group_finish(EC_GROUP * group) | 145 | ec_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 | ||
153 | void | 153 | void |
154 | ec_GFp_simple_group_clear_finish(EC_GROUP * group) | 154 | ec_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 | ||
162 | int | 162 | int |
163 | ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) | 163 | ec_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 | ||
178 | int | 178 | int |
179 | ec_GFp_simple_group_set_curve(EC_GROUP * group, | 179 | ec_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 | ||
235 | int | 235 | int |
236 | ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) | 236 | ec_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 | ||
279 | int | 279 | int |
280 | ec_GFp_simple_group_get_degree(const EC_GROUP * group) | 280 | ec_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 | ||
286 | int | 286 | int |
287 | ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) | 287 | ec_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 | ||
374 | void | 374 | void |
375 | ec_GFp_simple_point_finish(EC_POINT * point) | 375 | ec_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 | ||
383 | void | 383 | void |
384 | ec_GFp_simple_point_clear_finish(EC_POINT * point) | 384 | ec_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 | ||
393 | int | 393 | int |
394 | ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src) | 394 | ec_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 | ||
408 | int | 408 | int |
409 | ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) | 409 | ec_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 | ||
517 | int | 517 | int |
518 | ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, | 518 | ec_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 | ||
530 | int | 530 | int |
531 | ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POINT * point, | 531 | ec_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 | ||
637 | int | 637 | int |
638 | ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) | 638 | ec_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 | ||
826 | int | 826 | int |
827 | ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_CTX * ctx) | 827 | ec_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 | ||
968 | int | 968 | int |
969 | ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) | 969 | ec_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 | ||
979 | int | 979 | int |
980 | ec_GFp_simple_is_at_infinity(const EC_GROUP * group, const EC_POINT * point) | 980 | ec_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 | ||
986 | int | 986 | int |
987 | ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) | 987 | ec_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 | ||
1089 | int | 1089 | int |
1090 | ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) | 1090 | ec_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 | ||
1191 | int | 1191 | int |
1192 | ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) | 1192 | ec_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 | ||
1229 | int | 1229 | int |
1230 | ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * points[], BN_CTX * ctx) | 1230 | ec_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 | ||
1404 | int | 1404 | int |
1405 | ec_GFp_simple_field_mul(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) | 1405 | ec_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 | ||
1410 | int | 1410 | int |
1411 | ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx) | 1411 | ec_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 | } |