summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-10-11 18:58:04 +0000
committertb <>2024-10-11 18:58:04 +0000
commit96512bd19204e0b4282212e67c2acc75b3042360 (patch)
treec41ab34a51e7e0d573f549bac4edef0a1f5f4d51
parentc24a29b0fcf61cf5b8d2c92ef2647c2ae5f77021 (diff)
downloadopenbsd-96512bd19204e0b4282212e67c2acc75b3042360.tar.gz
openbsd-96512bd19204e0b4282212e67c2acc75b3042360.tar.bz2
openbsd-96512bd19204e0b4282212e67c2acc75b3042360.zip
Use a and b for the curve coefficients
No idea how anyone would think that tmp_1 and tmp_2 are better suited for this. ok jsing
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c
index 291b59ac06..865934ccf0 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.67 2024/10/11 18:55:44 tb Exp $ */ 1/* $OpenBSD: ec_asn1.c,v 1.68 2024/10/11 18:58:04 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -604,7 +604,7 @@ ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
604static int 604static int
605ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) 605ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
606{ 606{
607 BIGNUM *tmp_1 = NULL, *tmp_2 = NULL; 607 BIGNUM *a = NULL, *b = NULL;
608 unsigned char *buffer_1 = NULL, *buffer_2 = NULL, *a_buf = NULL, 608 unsigned char *buffer_1 = NULL, *buffer_2 = NULL, *a_buf = NULL,
609 *b_buf = NULL; 609 *b_buf = NULL;
610 size_t len_1, len_2; 610 size_t len_1, len_2;
@@ -614,18 +614,18 @@ ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
614 if (!group || !curve || !curve->a || !curve->b) 614 if (!group || !curve || !curve->a || !curve->b)
615 return 0; 615 return 0;
616 616
617 if ((tmp_1 = BN_new()) == NULL || (tmp_2 = BN_new()) == NULL) { 617 if ((a = BN_new()) == NULL || (b = BN_new()) == NULL) {
618 ECerror(ERR_R_MALLOC_FAILURE); 618 ECerror(ERR_R_MALLOC_FAILURE);
619 goto err; 619 goto err;
620 } 620 }
621 621
622 /* get a and b */ 622 /* get a and b */
623 if (!EC_GROUP_get_curve(group, NULL, tmp_1, tmp_2, NULL)) { 623 if (!EC_GROUP_get_curve(group, NULL, a, b, NULL)) {
624 ECerror(ERR_R_EC_LIB); 624 ECerror(ERR_R_EC_LIB);
625 goto err; 625 goto err;
626 } 626 }
627 len_1 = (size_t) BN_num_bytes(tmp_1); 627 len_1 = (size_t) BN_num_bytes(a);
628 len_2 = (size_t) BN_num_bytes(tmp_2); 628 len_2 = (size_t) BN_num_bytes(b);
629 629
630 if (len_1 == 0) { 630 if (len_1 == 0) {
631 /* len_1 == 0 => a == 0 */ 631 /* len_1 == 0 => a == 0 */
@@ -636,7 +636,7 @@ ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
636 ECerror(ERR_R_MALLOC_FAILURE); 636 ECerror(ERR_R_MALLOC_FAILURE);
637 goto err; 637 goto err;
638 } 638 }
639 if ((len_1 = BN_bn2bin(tmp_1, buffer_1)) == 0) { 639 if ((len_1 = BN_bn2bin(a, buffer_1)) == 0) {
640 ECerror(ERR_R_BN_LIB); 640 ECerror(ERR_R_BN_LIB);
641 goto err; 641 goto err;
642 } 642 }
@@ -652,7 +652,7 @@ ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
652 ECerror(ERR_R_MALLOC_FAILURE); 652 ECerror(ERR_R_MALLOC_FAILURE);
653 goto err; 653 goto err;
654 } 654 }
655 if ((len_2 = BN_bn2bin(tmp_2, buffer_2)) == 0) { 655 if ((len_2 = BN_bn2bin(b, buffer_2)) == 0) {
656 ECerror(ERR_R_BN_LIB); 656 ECerror(ERR_R_BN_LIB);
657 goto err; 657 goto err;
658 } 658 }
@@ -691,8 +691,9 @@ ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
691 err: 691 err:
692 free(buffer_1); 692 free(buffer_1);
693 free(buffer_2); 693 free(buffer_2);
694 BN_free(tmp_1); 694 BN_free(a);
695 BN_free(tmp_2); 695 BN_free(b);
696
696 return (ok); 697 return (ok);
697} 698}
698 699