summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/ec/ec_curve.c58
1 files changed, 4 insertions, 54 deletions
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c
index f4d726b616..f9a177ca0d 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.33 2023/05/01 13:14:00 tb Exp $ */ 1/* $OpenBSD: ec_curve.c,v 1.34 2023/05/01 13:49:26 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -79,7 +79,6 @@
79#include "ec_local.h" 79#include "ec_local.h"
80 80
81typedef struct { 81typedef struct {
82 int field_type;
83 int seed_len; 82 int seed_len;
84 int param_len; 83 int param_len;
85 unsigned int cofactor; /* promoted to BN_ULONG */ 84 unsigned int cofactor; /* promoted to BN_ULONG */
@@ -92,7 +91,6 @@ static const struct {
92} 91}
93 _EC_NIST_PRIME_192 = { 92 _EC_NIST_PRIME_192 = {
94 { 93 {
95 .field_type = NID_X9_62_prime_field,
96 .seed_len = 20, 94 .seed_len = 20,
97 .param_len = 24, 95 .param_len = 24,
98 .cofactor = 1, 96 .cofactor = 1,
@@ -128,7 +126,6 @@ static const struct {
128} 126}
129 _EC_NIST_PRIME_224 = { 127 _EC_NIST_PRIME_224 = {
130 { 128 {
131 .field_type = NID_X9_62_prime_field,
132 .seed_len = 20, 129 .seed_len = 20,
133 .param_len = 28, 130 .param_len = 28,
134 .cofactor = 1, 131 .cofactor = 1,
@@ -164,7 +161,6 @@ static const struct {
164} 161}
165 _EC_NIST_PRIME_384 = { 162 _EC_NIST_PRIME_384 = {
166 { 163 {
167 .field_type = NID_X9_62_prime_field,
168 .seed_len = 20, 164 .seed_len = 20,
169 .param_len = 48, 165 .param_len = 48,
170 .cofactor = 1, 166 .cofactor = 1,
@@ -212,7 +208,6 @@ static const struct {
212} 208}
213 _EC_NIST_PRIME_521 = { 209 _EC_NIST_PRIME_521 = {
214 { 210 {
215 .field_type = NID_X9_62_prime_field,
216 .seed_len = 20, 211 .seed_len = 20,
217 .param_len = 66, 212 .param_len = 66,
218 .cofactor = 1, 213 .cofactor = 1,
@@ -273,7 +268,6 @@ static const struct {
273} 268}
274 _EC_X9_62_PRIME_192V2 = { 269 _EC_X9_62_PRIME_192V2 = {
275 { 270 {
276 .field_type = NID_X9_62_prime_field,
277 .seed_len = 20, 271 .seed_len = 20,
278 .param_len = 24, 272 .param_len = 24,
279 .cofactor = 1, 273 .cofactor = 1,
@@ -309,7 +303,6 @@ static const struct {
309} 303}
310 _EC_X9_62_PRIME_192V3 = { 304 _EC_X9_62_PRIME_192V3 = {
311 { 305 {
312 .field_type = NID_X9_62_prime_field,
313 .seed_len = 20, 306 .seed_len = 20,
314 .param_len = 24, 307 .param_len = 24,
315 .cofactor = 1, 308 .cofactor = 1,
@@ -345,7 +338,6 @@ static const struct {
345} 338}
346 _EC_X9_62_PRIME_239V1 = { 339 _EC_X9_62_PRIME_239V1 = {
347 { 340 {
348 .field_type = NID_X9_62_prime_field,
349 .seed_len = 20, 341 .seed_len = 20,
350 .param_len = 30, 342 .param_len = 30,
351 .cofactor = 1, 343 .cofactor = 1,
@@ -386,7 +378,6 @@ static const struct {
386} 378}
387 _EC_X9_62_PRIME_239V2 = { 379 _EC_X9_62_PRIME_239V2 = {
388 { 380 {
389 .field_type = NID_X9_62_prime_field,
390 .seed_len = 20, 381 .seed_len = 20,
391 .param_len = 30, 382 .param_len = 30,
392 .cofactor = 1, 383 .cofactor = 1,
@@ -427,7 +418,6 @@ static const struct {
427} 418}
428 _EC_X9_62_PRIME_239V3 = { 419 _EC_X9_62_PRIME_239V3 = {
429 { 420 {
430 .field_type = NID_X9_62_prime_field,
431 .seed_len = 20, 421 .seed_len = 20,
432 .param_len = 30, 422 .param_len = 30,
433 .cofactor = 1, 423 .cofactor = 1,
@@ -469,7 +459,6 @@ static const struct {
469} 459}
470 _EC_X9_62_PRIME_256V1 = { 460 _EC_X9_62_PRIME_256V1 = {
471 { 461 {
472 .field_type = NID_X9_62_prime_field,
473 .seed_len = 20, 462 .seed_len = 20,
474 .param_len = 32, 463 .param_len = 32,
475 .cofactor = 1, 464 .cofactor = 1,
@@ -512,7 +501,6 @@ static const struct {
512} 501}
513 _EC_SECG_PRIME_112R1 = { 502 _EC_SECG_PRIME_112R1 = {
514 { 503 {
515 .field_type = NID_X9_62_prime_field,
516 .seed_len = 20, 504 .seed_len = 20,
517 .param_len = 14, 505 .param_len = 14,
518 .cofactor = 1, 506 .cofactor = 1,
@@ -542,7 +530,6 @@ static const struct {
542} 530}
543 _EC_SECG_PRIME_112R2 = { 531 _EC_SECG_PRIME_112R2 = {
544 { 532 {
545 .field_type = NID_X9_62_prime_field,
546 .seed_len = 20, 533 .seed_len = 20,
547 .param_len = 14, 534 .param_len = 14,
548 .cofactor = 4, 535 .cofactor = 4,
@@ -572,7 +559,6 @@ static const struct {
572} 559}
573 _EC_SECG_PRIME_128R1 = { 560 _EC_SECG_PRIME_128R1 = {
574 { 561 {
575 .field_type = NID_X9_62_prime_field,
576 .seed_len = 20, 562 .seed_len = 20,
577 .param_len = 16, 563 .param_len = 16,
578 .cofactor = 1, 564 .cofactor = 1,
@@ -602,7 +588,6 @@ static const struct {
602} 588}
603 _EC_SECG_PRIME_128R2 = { 589 _EC_SECG_PRIME_128R2 = {
604 { 590 {
605 .field_type = NID_X9_62_prime_field,
606 .seed_len = 20, 591 .seed_len = 20,
607 .param_len = 16, 592 .param_len = 16,
608 .cofactor = 4, 593 .cofactor = 4,
@@ -632,7 +617,6 @@ static const struct {
632} 617}
633 _EC_SECG_PRIME_160K1 = { 618 _EC_SECG_PRIME_160K1 = {
634 { 619 {
635 .field_type = NID_X9_62_prime_field,
636 .seed_len = 0, 620 .seed_len = 0,
637 .param_len = 21, 621 .param_len = 21,
638 .cofactor = 1, 622 .cofactor = 1,
@@ -665,7 +649,6 @@ static const struct {
665} 649}
666 _EC_SECG_PRIME_160R1 = { 650 _EC_SECG_PRIME_160R1 = {
667 { 651 {
668 .field_type = NID_X9_62_prime_field,
669 .seed_len = 20, 652 .seed_len = 20,
670 .param_len = 21, 653 .param_len = 21,
671 .cofactor = 1, 654 .cofactor = 1,
@@ -701,7 +684,6 @@ static const struct {
701} 684}
702 _EC_SECG_PRIME_160R2 = { 685 _EC_SECG_PRIME_160R2 = {
703 { 686 {
704 .field_type = NID_X9_62_prime_field,
705 .seed_len = 20, 687 .seed_len = 20,
706 .param_len = 21, 688 .param_len = 21,
707 .cofactor = 1, 689 .cofactor = 1,
@@ -737,7 +719,6 @@ static const struct {
737} 719}
738 _EC_SECG_PRIME_192K1 = { 720 _EC_SECG_PRIME_192K1 = {
739 { 721 {
740 .field_type = NID_X9_62_prime_field,
741 .seed_len = 0, 722 .seed_len = 0,
742 .param_len = 24, 723 .param_len = 24,
743 .cofactor = 1, 724 .cofactor = 1,
@@ -770,7 +751,6 @@ static const struct {
770} 751}
771 _EC_SECG_PRIME_224K1 = { 752 _EC_SECG_PRIME_224K1 = {
772 { 753 {
773 .field_type = NID_X9_62_prime_field,
774 .seed_len = 0, 754 .seed_len = 0,
775 .param_len = 29, 755 .param_len = 29,
776 .cofactor = 1, 756 .cofactor = 1,
@@ -803,7 +783,6 @@ static const struct {
803} 783}
804 _EC_SECG_PRIME_256K1 = { 784 _EC_SECG_PRIME_256K1 = {
805 { 785 {
806 .field_type = NID_X9_62_prime_field,
807 .seed_len = 0, 786 .seed_len = 0,
808 .param_len = 32, 787 .param_len = 32,
809 .cofactor = 1, 788 .cofactor = 1,
@@ -843,7 +822,6 @@ static const struct {
843} 822}
844 _EC_WTLS_8 = { 823 _EC_WTLS_8 = {
845 { 824 {
846 .field_type = NID_X9_62_prime_field,
847 .seed_len = 0, 825 .seed_len = 0,
848 .param_len = 15, 826 .param_len = 15,
849 .cofactor = 1, 827 .cofactor = 1,
@@ -870,7 +848,6 @@ static const struct {
870} 848}
871 _EC_WTLS_9 = { 849 _EC_WTLS_9 = {
872 { 850 {
873 .field_type = NID_X9_62_prime_field,
874 .seed_len = 0, 851 .seed_len = 0,
875 .param_len = 21, 852 .param_len = 21,
876 .cofactor = 1, 853 .cofactor = 1,
@@ -903,7 +880,6 @@ static const struct {
903} 880}
904 _EC_WTLS_12 = { 881 _EC_WTLS_12 = {
905 { 882 {
906 .field_type = NID_X9_62_prime_field,
907 .seed_len = 0, 883 .seed_len = 0,
908 .param_len = 28, 884 .param_len = 28,
909 .cofactor = 1, 885 .cofactor = 1,
@@ -944,7 +920,6 @@ static const struct {
944} 920}
945 _EC_brainpoolP160r1 = { 921 _EC_brainpoolP160r1 = {
946 { 922 {
947 .field_type = NID_X9_62_prime_field,
948 .seed_len = 0, 923 .seed_len = 0,
949 .param_len = 20, 924 .param_len = 20,
950 .cofactor = 1, 925 .cofactor = 1,
@@ -971,7 +946,6 @@ static const struct {
971} 946}
972 _EC_brainpoolP160t1 = { 947 _EC_brainpoolP160t1 = {
973 { 948 {
974 .field_type = NID_X9_62_prime_field,
975 .seed_len = 0, 949 .seed_len = 0,
976 .param_len = 20, 950 .param_len = 20,
977 .cofactor = 1, 951 .cofactor = 1,
@@ -998,7 +972,6 @@ static const struct {
998} 972}
999 _EC_brainpoolP192r1 = { 973 _EC_brainpoolP192r1 = {
1000 { 974 {
1001 .field_type = NID_X9_62_prime_field,
1002 .seed_len = 0, 975 .seed_len = 0,
1003 .param_len = 24, 976 .param_len = 24,
1004 .cofactor = 1, 977 .cofactor = 1,
@@ -1031,7 +1004,6 @@ static const struct {
1031} 1004}
1032 _EC_brainpoolP192t1 = { 1005 _EC_brainpoolP192t1 = {
1033 { 1006 {
1034 .field_type = NID_X9_62_prime_field,
1035 .seed_len = 0, 1007 .seed_len = 0,
1036 .param_len = 24, 1008 .param_len = 24,
1037 .cofactor = 1, 1009 .cofactor = 1,
@@ -1064,7 +1036,6 @@ static const struct {
1064} 1036}
1065 _EC_brainpoolP224r1 = { 1037 _EC_brainpoolP224r1 = {
1066 { 1038 {
1067 .field_type = NID_X9_62_prime_field,
1068 .seed_len = 0, 1039 .seed_len = 0,
1069 .param_len = 28, 1040 .param_len = 28,
1070 .cofactor = 1, 1041 .cofactor = 1,
@@ -1097,7 +1068,6 @@ static const struct {
1097} 1068}
1098 _EC_brainpoolP224t1 = { 1069 _EC_brainpoolP224t1 = {
1099 { 1070 {
1100 .field_type = NID_X9_62_prime_field,
1101 .seed_len = 0, 1071 .seed_len = 0,
1102 .param_len = 28, 1072 .param_len = 28,
1103 .cofactor = 1, 1073 .cofactor = 1,
@@ -1130,7 +1100,6 @@ static const struct {
1130} 1100}
1131 _EC_brainpoolP256r1 = { 1101 _EC_brainpoolP256r1 = {
1132 { 1102 {
1133 .field_type = NID_X9_62_prime_field,
1134 .seed_len = 0, 1103 .seed_len = 0,
1135 .param_len = 32, 1104 .param_len = 32,
1136 .cofactor = 1, 1105 .cofactor = 1,
@@ -1169,7 +1138,6 @@ static const struct {
1169} 1138}
1170 _EC_brainpoolP256t1 = { 1139 _EC_brainpoolP256t1 = {
1171 { 1140 {
1172 .field_type = NID_X9_62_prime_field,
1173 .seed_len = 0, 1141 .seed_len = 0,
1174 .param_len = 32, 1142 .param_len = 32,
1175 .cofactor = 1, 1143 .cofactor = 1,
@@ -1208,7 +1176,6 @@ static const struct {
1208} 1176}
1209 _EC_brainpoolP320r1 = { 1177 _EC_brainpoolP320r1 = {
1210 { 1178 {
1211 .field_type = NID_X9_62_prime_field,
1212 .seed_len = 0, 1179 .seed_len = 0,
1213 .param_len = 40, 1180 .param_len = 40,
1214 .cofactor = 1, 1181 .cofactor = 1,
@@ -1247,7 +1214,6 @@ static const struct {
1247} 1214}
1248 _EC_brainpoolP320t1 = { 1215 _EC_brainpoolP320t1 = {
1249 { 1216 {
1250 .field_type = NID_X9_62_prime_field,
1251 .seed_len = 0, 1217 .seed_len = 0,
1252 .param_len = 40, 1218 .param_len = 40,
1253 .cofactor = 1, 1219 .cofactor = 1,
@@ -1286,7 +1252,6 @@ static const struct {
1286} 1252}
1287 _EC_brainpoolP384r1 = { 1253 _EC_brainpoolP384r1 = {
1288 { 1254 {
1289 .field_type = NID_X9_62_prime_field,
1290 .seed_len = 0, 1255 .seed_len = 0,
1291 .param_len = 48, 1256 .param_len = 48,
1292 .cofactor = 1, 1257 .cofactor = 1,
@@ -1331,7 +1296,6 @@ static const struct {
1331} 1296}
1332 _EC_brainpoolP384t1 = { 1297 _EC_brainpoolP384t1 = {
1333 { 1298 {
1334 .field_type = NID_X9_62_prime_field,
1335 .seed_len = 0, 1299 .seed_len = 0,
1336 .param_len = 48, 1300 .param_len = 48,
1337 .cofactor = 1, 1301 .cofactor = 1,
@@ -1376,7 +1340,6 @@ static const struct {
1376} 1340}
1377 _EC_brainpoolP512r1 = { 1341 _EC_brainpoolP512r1 = {
1378 { 1342 {
1379 .field_type = NID_X9_62_prime_field,
1380 .seed_len = 0, 1343 .seed_len = 0,
1381 .param_len = 64, 1344 .param_len = 64,
1382 .cofactor = 1, 1345 .cofactor = 1,
@@ -1433,7 +1396,6 @@ static const struct {
1433} 1396}
1434 _EC_brainpoolP512t1 = { 1397 _EC_brainpoolP512t1 = {
1435 { 1398 {
1436 .field_type = NID_X9_62_prime_field,
1437 .seed_len = 0, 1399 .seed_len = 0,
1438 .param_len = 64, 1400 .param_len = 64,
1439 .cofactor = 1, 1401 .cofactor = 1,
@@ -1490,7 +1452,6 @@ static const struct {
1490} 1452}
1491 _EC_FRP256v1 = { 1453 _EC_FRP256v1 = {
1492 { 1454 {
1493 .field_type = NID_X9_62_prime_field,
1494 .seed_len = 0, 1455 .seed_len = 0,
1495 .param_len = 32, 1456 .param_len = 32,
1496 .cofactor = 1, 1457 .cofactor = 1,
@@ -1530,7 +1491,6 @@ static const struct {
1530} 1491}
1531 _EC_GOST_2001_Test = { 1492 _EC_GOST_2001_Test = {
1532 { 1493 {
1533 .field_type = NID_X9_62_prime_field,
1534 .seed_len = 0, 1494 .seed_len = 0,
1535 .param_len = 32, 1495 .param_len = 32,
1536 .cofactor = 1, 1496 .cofactor = 1,
@@ -1569,7 +1529,6 @@ static const struct {
1569} 1529}
1570 _EC_GOST_2001_CryptoPro_A = { 1530 _EC_GOST_2001_CryptoPro_A = {
1571 { 1531 {
1572 .field_type = NID_X9_62_prime_field,
1573 .seed_len = 0, 1532 .seed_len = 0,
1574 .param_len = 32, 1533 .param_len = 32,
1575 .cofactor = 1, 1534 .cofactor = 1,
@@ -1608,7 +1567,6 @@ static const struct {
1608} 1567}
1609 _EC_GOST_2001_CryptoPro_B = { 1568 _EC_GOST_2001_CryptoPro_B = {
1610 { 1569 {
1611 .field_type = NID_X9_62_prime_field,
1612 .seed_len = 0, 1570 .seed_len = 0,
1613 .param_len = 32, 1571 .param_len = 32,
1614 .cofactor = 1, 1572 .cofactor = 1,
@@ -1647,7 +1605,6 @@ static const struct {
1647} 1605}
1648 _EC_GOST_2001_CryptoPro_C = { 1606 _EC_GOST_2001_CryptoPro_C = {
1649 { 1607 {
1650 .field_type = NID_X9_62_prime_field,
1651 .seed_len = 0, 1608 .seed_len = 0,
1652 .param_len = 32, 1609 .param_len = 32,
1653 .cofactor = 1, 1610 .cofactor = 1,
@@ -1690,7 +1647,6 @@ static const struct {
1690} 1647}
1691 _EC_GOST_2012_256_TC26_A = { 1648 _EC_GOST_2012_256_TC26_A = {
1692 { 1649 {
1693 .field_type = NID_X9_62_prime_field,
1694 .seed_len = 0, 1650 .seed_len = 0,
1695 .param_len = 32, 1651 .param_len = 32,
1696 .cofactor = 4, 1652 .cofactor = 4,
@@ -1729,7 +1685,6 @@ static const struct {
1729} 1685}
1730 _EC_GOST_2012_512_Test = { 1686 _EC_GOST_2012_512_Test = {
1731 { 1687 {
1732 .field_type = NID_X9_62_prime_field,
1733 .seed_len = 0, 1688 .seed_len = 0,
1734 .param_len = 64, 1689 .param_len = 64,
1735 .cofactor = 1, 1690 .cofactor = 1,
@@ -1786,7 +1741,6 @@ static const struct {
1786} 1741}
1787 _EC_GOST_2012_512_TC26_A = { 1742 _EC_GOST_2012_512_TC26_A = {
1788 { 1743 {
1789 .field_type = NID_X9_62_prime_field,
1790 .seed_len = 0, 1744 .seed_len = 0,
1791 .param_len = 64, 1745 .param_len = 64,
1792 .cofactor = 1, 1746 .cofactor = 1,
@@ -1843,7 +1797,6 @@ static const struct {
1843} 1797}
1844 _EC_GOST_2012_512_TC26_B = { 1798 _EC_GOST_2012_512_TC26_B = {
1845 { 1799 {
1846 .field_type = NID_X9_62_prime_field,
1847 .seed_len = 0, 1800 .seed_len = 0,
1848 .param_len = 64, 1801 .param_len = 64,
1849 .cofactor = 1, 1802 .cofactor = 1,
@@ -1904,7 +1857,6 @@ static const struct {
1904} 1857}
1905 _EC_GOST_2012_512_TC26_C = { 1858 _EC_GOST_2012_512_TC26_C = {
1906 { 1859 {
1907 .field_type = NID_X9_62_prime_field,
1908 .seed_len = 0, 1860 .seed_len = 0,
1909 .param_len = 64, 1861 .param_len = 64,
1910 .cofactor = 4, 1862 .cofactor = 4,
@@ -2313,11 +2265,9 @@ ec_group_new_from_data(const ec_list_element curve)
2313 ECerror(ERR_R_BN_LIB); 2265 ECerror(ERR_R_BN_LIB);
2314 goto err; 2266 goto err;
2315 } 2267 }
2316 if (data->field_type == NID_X9_62_prime_field) { 2268 if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) {
2317 if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) { 2269 ECerror(ERR_R_EC_LIB);
2318 ECerror(ERR_R_EC_LIB); 2270 goto err;
2319 goto err;
2320 }
2321 } 2271 }
2322 2272
2323 if ((P = EC_POINT_new(group)) == NULL) { 2273 if ((P = EC_POINT_new(group)) == NULL) {