summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_ameth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ec/ec_ameth.c')
-rw-r--r--src/lib/libcrypto/ec/ec_ameth.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c
index ee931a93c6..b6f21ade63 100644
--- a/src/lib/libcrypto/ec/ec_ameth.c
+++ b/src/lib/libcrypto/ec/ec_ameth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_ameth.c,v 1.34 2022/11/19 07:00:57 tb Exp $ */ 1/* $OpenBSD: ec_ameth.c,v 1.35 2022/11/19 07:29:29 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -76,7 +76,7 @@ static int ecdh_cms_encrypt(CMS_RecipientInfo *ri);
76#endif 76#endif
77 77
78static int 78static int
79eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key) 79eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key)
80{ 80{
81 const EC_GROUP *group; 81 const EC_GROUP *group;
82 int nid; 82 int nid;
@@ -108,7 +108,7 @@ eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key)
108} 108}
109 109
110static int 110static int
111eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey) 111eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
112{ 112{
113 EC_KEY *ec_key = pkey->pkey.ec; 113 EC_KEY *ec_key = pkey->pkey.ec;
114 void *pval = NULL; 114 void *pval = NULL;
@@ -191,7 +191,7 @@ eckey_type2param(int ptype, const void *pval)
191} 191}
192 192
193static int 193static int
194eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) 194eckey_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
195{ 195{
196 const unsigned char *p = NULL; 196 const unsigned char *p = NULL;
197 const void *pval; 197 const void *pval;
@@ -224,7 +224,7 @@ eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey)
224} 224}
225 225
226static int 226static int
227eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) 227eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
228{ 228{
229 int r; 229 int r;
230 const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec); 230 const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec);
@@ -239,7 +239,7 @@ eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b)
239} 239}
240 240
241static int 241static int
242eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8) 242eckey_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
243{ 243{
244 const unsigned char *p = NULL; 244 const unsigned char *p = NULL;
245 const void *pval; 245 const void *pval;
@@ -306,7 +306,7 @@ eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8)
306} 306}
307 307
308static int 308static int
309eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey) 309eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
310{ 310{
311 EC_KEY *ec_key; 311 EC_KEY *ec_key;
312 unsigned char *ep, *p; 312 unsigned char *ep, *p;
@@ -359,13 +359,13 @@ eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey)
359} 359}
360 360
361static int 361static int
362int_ec_size(const EVP_PKEY * pkey) 362int_ec_size(const EVP_PKEY *pkey)
363{ 363{
364 return ECDSA_size(pkey->pkey.ec); 364 return ECDSA_size(pkey->pkey.ec);
365} 365}
366 366
367static int 367static int
368ec_bits(const EVP_PKEY * pkey) 368ec_bits(const EVP_PKEY *pkey)
369{ 369{
370 BIGNUM *order = BN_new(); 370 BIGNUM *order = BN_new();
371 const EC_GROUP *group; 371 const EC_GROUP *group;
@@ -406,7 +406,7 @@ ec_security_bits(const EVP_PKEY *pkey)
406} 406}
407 407
408static int 408static int
409ec_missing_parameters(const EVP_PKEY * pkey) 409ec_missing_parameters(const EVP_PKEY *pkey)
410{ 410{
411 if (EC_KEY_get0_group(pkey->pkey.ec) == NULL) 411 if (EC_KEY_get0_group(pkey->pkey.ec) == NULL)
412 return 1; 412 return 1;
@@ -414,13 +414,13 @@ ec_missing_parameters(const EVP_PKEY * pkey)
414} 414}
415 415
416static int 416static int
417ec_copy_parameters(EVP_PKEY * to, const EVP_PKEY * from) 417ec_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
418{ 418{
419 return EC_KEY_set_group(to->pkey.ec, EC_KEY_get0_group(from->pkey.ec)); 419 return EC_KEY_set_group(to->pkey.ec, EC_KEY_get0_group(from->pkey.ec));
420} 420}
421 421
422static int 422static int
423ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b) 423ec_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
424{ 424{
425 const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), *group_b = EC_KEY_get0_group(b->pkey.ec); 425 const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), *group_b = EC_KEY_get0_group(b->pkey.ec);
426 if (EC_GROUP_cmp(group_a, group_b, NULL)) 426 if (EC_GROUP_cmp(group_a, group_b, NULL))
@@ -430,13 +430,13 @@ ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b)
430} 430}
431 431
432static void 432static void
433int_ec_free(EVP_PKEY * pkey) 433int_ec_free(EVP_PKEY *pkey)
434{ 434{
435 EC_KEY_free(pkey->pkey.ec); 435 EC_KEY_free(pkey->pkey.ec);
436} 436}
437 437
438static int 438static int
439do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) 439do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype)
440{ 440{
441 unsigned char *buffer = NULL; 441 unsigned char *buffer = NULL;
442 const char *ecstr; 442 const char *ecstr;
@@ -520,7 +520,7 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype)
520} 520}
521 521
522static int 522static int
523eckey_param_decode(EVP_PKEY * pkey, 523eckey_param_decode(EVP_PKEY *pkey,
524 const unsigned char **pder, int derlen) 524 const unsigned char **pder, int derlen)
525{ 525{
526 EC_KEY *eckey; 526 EC_KEY *eckey;
@@ -533,35 +533,35 @@ eckey_param_decode(EVP_PKEY * pkey,
533} 533}
534 534
535static int 535static int
536eckey_param_encode(const EVP_PKEY * pkey, unsigned char **pder) 536eckey_param_encode(const EVP_PKEY *pkey, unsigned char **pder)
537{ 537{
538 return i2d_ECParameters(pkey->pkey.ec, pder); 538 return i2d_ECParameters(pkey->pkey.ec, pder);
539} 539}
540 540
541static int 541static int
542eckey_param_print(BIO * bp, const EVP_PKEY * pkey, int indent, 542eckey_param_print(BIO *bp, const EVP_PKEY *pkey, int indent,
543 ASN1_PCTX * ctx) 543 ASN1_PCTX *ctx)
544{ 544{
545 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0); 545 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0);
546} 546}
547 547
548static int 548static int
549eckey_pub_print(BIO * bp, const EVP_PKEY * pkey, int indent, 549eckey_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent,
550 ASN1_PCTX * ctx) 550 ASN1_PCTX *ctx)
551{ 551{
552 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1); 552 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1);
553} 553}
554 554
555 555
556static int 556static int
557eckey_priv_print(BIO * bp, const EVP_PKEY * pkey, int indent, 557eckey_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent,
558 ASN1_PCTX * ctx) 558 ASN1_PCTX *ctx)
559{ 559{
560 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2); 560 return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2);
561} 561}
562 562
563static int 563static int
564old_ec_priv_decode(EVP_PKEY * pkey, 564old_ec_priv_decode(EVP_PKEY *pkey,
565 const unsigned char **pder, int derlen) 565 const unsigned char **pder, int derlen)
566{ 566{
567 EC_KEY *ec; 567 EC_KEY *ec;
@@ -574,13 +574,13 @@ old_ec_priv_decode(EVP_PKEY * pkey,
574} 574}
575 575
576static int 576static int
577old_ec_priv_encode(const EVP_PKEY * pkey, unsigned char **pder) 577old_ec_priv_encode(const EVP_PKEY *pkey, unsigned char **pder)
578{ 578{
579 return i2d_ECPrivateKey(pkey->pkey.ec, pder); 579 return i2d_ECPrivateKey(pkey->pkey.ec, pder);
580} 580}
581 581
582static int 582static int
583ec_pkey_ctrl(EVP_PKEY * pkey, int op, long arg1, void *arg2) 583ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
584{ 584{
585 switch (op) { 585 switch (op) {
586 case ASN1_PKEY_CTRL_PKCS7_SIGN: 586 case ASN1_PKEY_CTRL_PKCS7_SIGN: