diff options
author | tb <> | 2024-10-18 09:34:20 +0000 |
---|---|---|
committer | tb <> | 2024-10-18 09:34:20 +0000 |
commit | 69c2adc0e8e0289d9403ffd40eb046be660c0ed7 (patch) | |
tree | b13fd1446ee6d4b1285795a33e579ec4932841ce /src | |
parent | 0ad30516ab56113d4662d890c78fe0618aad0d22 (diff) | |
download | openbsd-69c2adc0e8e0289d9403ffd40eb046be660c0ed7.tar.gz openbsd-69c2adc0e8e0289d9403ffd40eb046be660c0ed7.tar.bz2 openbsd-69c2adc0e8e0289d9403ffd40eb046be660c0ed7.zip |
ec_asn1_test: test Wei25519.2 and Wei25519.-3 as well
Covers a few more corner cases in the elliptic curve code.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/ec/ec_asn1_test.c | 200 |
1 files changed, 163 insertions, 37 deletions
diff --git a/src/regress/lib/libcrypto/ec/ec_asn1_test.c b/src/regress/lib/libcrypto/ec/ec_asn1_test.c index c53864cadd..d9da2afca5 100644 --- a/src/regress/lib/libcrypto/ec/ec_asn1_test.c +++ b/src/regress/lib/libcrypto/ec/ec_asn1_test.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_asn1_test.c,v 1.7 2024/10/18 09:01:44 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1_test.c,v 1.8 2024/10/18 09:34:20 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2017, 2021 Joel Sing <jsing@openbsd.org> |
4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2024 Theo Buehler <tb@openbsd.org> |
@@ -340,6 +340,24 @@ ec_group_roundtrip_builtin_curves(void) | |||
340 | return failed; | 340 | return failed; |
341 | } | 341 | } |
342 | 342 | ||
343 | struct curve { | ||
344 | const char *descr; | ||
345 | const char *oid; | ||
346 | const char *sn; | ||
347 | const char *ln; | ||
348 | const char *p; | ||
349 | const char *a; | ||
350 | const char *b; | ||
351 | const char *order; | ||
352 | const char *cofactor; | ||
353 | const char *x; | ||
354 | const char *y; | ||
355 | const char *named; | ||
356 | size_t named_len; | ||
357 | const char *param; | ||
358 | size_t param_len; | ||
359 | }; | ||
360 | |||
343 | /* | 361 | /* |
344 | * From draft-ietf-lwig-curve-representation-23, Appendix E.3 | 362 | * From draft-ietf-lwig-curve-representation-23, Appendix E.3 |
345 | */ | 363 | */ |
@@ -380,24 +398,8 @@ const uint8_t ec_wei25519_pkparameters_parameters[] = { | |||
380 | 0x08, | 398 | 0x08, |
381 | }; | 399 | }; |
382 | 400 | ||
383 | struct curve { | ||
384 | const char *oid; | ||
385 | const char *sn; | ||
386 | const char *ln; | ||
387 | const char *p; | ||
388 | const char *a; | ||
389 | const char *b; | ||
390 | const char *order; | ||
391 | const char *cofactor; | ||
392 | const char *x; | ||
393 | const char *y; | ||
394 | const char *named; | ||
395 | size_t named_len; | ||
396 | const char *param; | ||
397 | size_t param_len; | ||
398 | }; | ||
399 | |||
400 | static const struct curve wei25519 = { | 401 | static const struct curve wei25519 = { |
402 | .descr = "short Weierstrass 25519", | ||
401 | .oid = "1.3.101.108", | 403 | .oid = "1.3.101.108", |
402 | .sn = "Wei25519", | 404 | .sn = "Wei25519", |
403 | .p = "7fffffff" "ffffffff" "ffffffff" "ffffffff" | 405 | .p = "7fffffff" "ffffffff" "ffffffff" "ffffffff" |
@@ -419,6 +421,124 @@ static const struct curve wei25519 = { | |||
419 | .param_len = sizeof(ec_wei25519_pkparameters_parameters), | 421 | .param_len = sizeof(ec_wei25519_pkparameters_parameters), |
420 | }; | 422 | }; |
421 | 423 | ||
424 | /* | ||
425 | * From draft-ietf-lwig-curve-representation-23, Appendix G.3 | ||
426 | */ | ||
427 | |||
428 | const uint8_t ec_wei25519_2_pkparameters_parameters[] = { | ||
429 | 0x30, 0x81, 0xde, 0x02, 0x01, 0x01, 0x30, 0x2b, | ||
430 | 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, | ||
431 | 0x01, 0x02, 0x20, 0x7f, 0xff, 0xff, 0xff, 0xff, | ||
432 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
433 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
434 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
435 | 0xff, 0xff, 0xed, 0x30, 0x44, 0x04, 0x20, 0x00, | ||
436 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
437 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
438 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
439 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, | ||
440 | 0x20, 0x1a, 0xc1, 0xda, 0x05, 0xb5, 0x5b, 0xc1, | ||
441 | 0x46, 0x33, 0xbd, 0x39, 0xe4, 0x7f, 0x94, 0x30, | ||
442 | 0x2e, 0xf1, 0x98, 0x43, 0xdc, 0xf6, 0x69, 0x91, | ||
443 | 0x6f, 0x6a, 0x5d, 0xfd, 0x01, 0x65, 0x53, 0x8c, | ||
444 | 0xd1, 0x04, 0x41, 0x04, 0x17, 0xcf, 0xea, 0xc3, | ||
445 | 0x78, 0xae, 0xd6, 0x61, 0x31, 0x8e, 0x86, 0x34, | ||
446 | 0x58, 0x22, 0x75, 0xb6, 0xd9, 0xad, 0x4d, 0xef, | ||
447 | 0x07, 0x2e, 0xa1, 0x93, 0x5e, 0xe3, 0xc4, 0xe8, | ||
448 | 0x7a, 0x94, 0x0f, 0xfa, 0x0c, 0x08, 0xa9, 0x52, | ||
449 | 0xc5, 0x5d, 0xfa, 0xd6, 0x2c, 0x4f, 0x13, 0xf1, | ||
450 | 0xa8, 0xf6, 0x8d, 0xca, 0xdc, 0x5c, 0x33, 0x1d, | ||
451 | 0x29, 0x7a, 0x37, 0xb6, 0xf0, 0xd7, 0xfd, 0xcc, | ||
452 | 0x51, 0xe1, 0x6b, 0x4d, 0x02, 0x20, 0x10, 0x00, | ||
453 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
454 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xde, | ||
455 | 0xf9, 0xde, 0xa2, 0xf7, 0x9c, 0xd6, 0x58, 0x12, | ||
456 | 0x63, 0x1a, 0x5c, 0xf5, 0xd3, 0xed, 0x02, 0x01, | ||
457 | 0x08, | ||
458 | }; | ||
459 | |||
460 | static const struct curve wei25519_2 = { | ||
461 | .descr = "short Weierstrass 25519.2", | ||
462 | .oid = "1.3.101.108", | ||
463 | .sn = "Wei25519", | ||
464 | .p = "7fffffff" "ffffffff" "ffffffff" "ffffffff" | ||
465 | "ffffffff" "ffffffff" "ffffffff" "ffffffed", | ||
466 | .a = "02", | ||
467 | .b = "1ac1da05" "b55bc146" "33bd39e4" "7f94302e" | ||
468 | "f19843dc" "f669916f" "6a5dfd01" "65538cd1", | ||
469 | .x = "17cfeac3" "78aed661" "318e8634" "582275b6" | ||
470 | "d9ad4def" "072ea193" "5ee3c4e8" "7a940ffa", | ||
471 | .y = "0c08a952" "c55dfad6" "2c4f13f1" "a8f68dca" | ||
472 | "dc5c331d" "297a37b6" "f0d7fdcc" "51e16b4d", | ||
473 | .order = "10000000" "00000000" "00000000" "00000000" | ||
474 | "14def9de" "a2f79cd6" "5812631a" "5cf5d3ed", | ||
475 | .cofactor = "8", | ||
476 | .named = ec_wei25519_pkparameters_named_curve, | ||
477 | .named_len = sizeof(ec_wei25519_pkparameters_named_curve), | ||
478 | .param = ec_wei25519_2_pkparameters_parameters, | ||
479 | .param_len = sizeof(ec_wei25519_2_pkparameters_parameters), | ||
480 | }; | ||
481 | |||
482 | const uint8_t ec_wei25519_3_pkparameters_parameters[] = { | ||
483 | 0x30, 0x81, 0xde, 0x02, 0x01, 0x01, 0x30, 0x2b, | ||
484 | 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x01, | ||
485 | 0x01, 0x02, 0x20, 0x7f, 0xff, 0xff, 0xff, 0xff, | ||
486 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
487 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
488 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
489 | 0xff, 0xff, 0xed, 0x30, 0x44, 0x04, 0x20, 0x7f, | ||
490 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
491 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
492 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
493 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xea, 0x04, | ||
494 | 0x20, 0x41, 0xa3, 0xb6, 0xbf, 0xc6, 0x68, 0x77, | ||
495 | 0x8e, 0xbe, 0x29, 0x54, 0xa4, 0xb1, 0xdf, 0x36, | ||
496 | 0xd1, 0x48, 0x5e, 0xce, 0xf1, 0xea, 0x61, 0x42, | ||
497 | 0x95, 0x79, 0x6e, 0x10, 0x22, 0x40, 0x89, 0x1f, | ||
498 | 0xaa, 0x04, 0x41, 0x04, 0x77, 0x06, 0xc3, 0x7b, | ||
499 | 0x5a, 0x84, 0x12, 0x8a, 0x38, 0x84, 0xa5, 0xd7, | ||
500 | 0x18, 0x11, 0xf1, 0xb5, 0x5d, 0xa3, 0x23, 0x0f, | ||
501 | 0xfb, 0x17, 0xa8, 0xab, 0x0b, 0x32, 0xe4, 0x8d, | ||
502 | 0x31, 0xa6, 0x68, 0x5c, 0x0f, 0x60, 0x48, 0x0c, | ||
503 | 0x7a, 0x5c, 0x0e, 0x11, 0x40, 0x34, 0x0a, 0xdc, | ||
504 | 0x79, 0xd6, 0xa2, 0xbf, 0x0c, 0xb5, 0x7a, 0xd0, | ||
505 | 0x49, 0xd0, 0x25, 0xdc, 0x38, 0xd8, 0x0c, 0x77, | ||
506 | 0x98, 0x5f, 0x03, 0x29, 0x02, 0x20, 0x10, 0x00, | ||
507 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
508 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xde, | ||
509 | 0xf9, 0xde, 0xa2, 0xf7, 0x9c, 0xd6, 0x58, 0x12, | ||
510 | 0x63, 0x1a, 0x5c, 0xf5, 0xd3, 0xed, 0x02, 0x01, | ||
511 | 0x08, | ||
512 | }; | ||
513 | |||
514 | static const struct curve wei25519_3 = { | ||
515 | .descr = "short Weierstrass 25519.-3", | ||
516 | .oid = "1.3.101.108", | ||
517 | .sn = "Wei25519", | ||
518 | .p = "7fffffff" "ffffffff" "ffffffff" "ffffffff" | ||
519 | "ffffffff" "ffffffff" "ffffffff" "ffffffed", | ||
520 | /* XXX - change this if we are going to enforce 0 <= a,b < p. */ | ||
521 | #if 0 | ||
522 | .a = "7fffffff" "ffffffff" "ffffffff" "ffffffff" | ||
523 | "ffffffff" "ffffffff" "ffffffff" "ffffffea", | ||
524 | #else | ||
525 | .a = "-03", | ||
526 | #endif | ||
527 | .b = "41a3b6bf" "c668778e" "be2954a4" "b1df36d1" | ||
528 | "485ecef1" "ea614295" "796e1022" "40891faa", | ||
529 | .x = "7706c37b" "5a84128a" "3884a5d7" "1811f1b5" | ||
530 | "5da3230f" "fb17a8ab" "0b32e48d" "31a6685c", | ||
531 | .y = "0f60480c" "7a5c0e11" "40340adc" "79d6a2bf" | ||
532 | "0cb57ad0" "49d025dc" "38d80c77" "985f0329", | ||
533 | .order = "10000000" "00000000" "00000000" "00000000" | ||
534 | "14def9de" "a2f79cd6" "5812631a" "5cf5d3ed", | ||
535 | .cofactor = "8", | ||
536 | .named = ec_wei25519_pkparameters_named_curve, | ||
537 | .named_len = sizeof(ec_wei25519_pkparameters_named_curve), | ||
538 | .param = ec_wei25519_3_pkparameters_parameters, | ||
539 | .param_len = sizeof(ec_wei25519_3_pkparameters_parameters), | ||
540 | }; | ||
541 | |||
422 | static EC_GROUP * | 542 | static EC_GROUP * |
423 | ec_group_from_curve_method(const struct curve *curve, const EC_METHOD *method, | 543 | ec_group_from_curve_method(const struct curve *curve, const EC_METHOD *method, |
424 | BN_CTX *ctx) | 544 | BN_CTX *ctx) |
@@ -468,8 +588,8 @@ ec_group_from_curve_method(const struct curve *curve, const EC_METHOD *method, | |||
468 | errx(1, "EC_POINT_new()"); | 588 | errx(1, "EC_POINT_new()"); |
469 | 589 | ||
470 | if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) { | 590 | if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) { |
471 | fprintf(stderr, "FAIL: %s EC_POINT_set_affine_coordinates", | 591 | fprintf(stderr, "FAIL: %s EC_POINT_set_affine_coordinates\n", |
472 | curve->sn); | 592 | curve->descr); |
473 | ERR_print_errors_fp(stderr); | 593 | ERR_print_errors_fp(stderr); |
474 | goto err; | 594 | goto err; |
475 | } | 595 | } |
@@ -479,7 +599,7 @@ ec_group_from_curve_method(const struct curve *curve, const EC_METHOD *method, | |||
479 | 599 | ||
480 | /* Don't set cofactor to exercise the cofactor guessing code. */ | 600 | /* Don't set cofactor to exercise the cofactor guessing code. */ |
481 | if (!EC_GROUP_set_generator(group, generator, order, NULL)) { | 601 | if (!EC_GROUP_set_generator(group, generator, order, NULL)) { |
482 | fprintf(stderr, "FAIL: %s EC_GROUP_set_generator\n", curve->sn); | 602 | fprintf(stderr, "FAIL: %s EC_GROUP_set_generator\n", curve->descr); |
483 | ERR_print_errors_fp(stderr); | 603 | ERR_print_errors_fp(stderr); |
484 | goto err; | 604 | goto err; |
485 | } | 605 | } |
@@ -511,7 +631,7 @@ ec_group_new(const struct curve *curve, const EC_METHOD *method, BN_CTX *ctx) | |||
511 | if ((nid = OBJ_txt2nid(curve->oid)) == NID_undef) | 631 | if ((nid = OBJ_txt2nid(curve->oid)) == NID_undef) |
512 | nid = OBJ_create(curve->oid, curve->sn, curve->ln); | 632 | nid = OBJ_create(curve->oid, curve->sn, curve->ln); |
513 | if (nid == NID_undef) { | 633 | if (nid == NID_undef) { |
514 | fprintf(stderr, "FAIL: OBJ_create(%s)\n", curve->sn); | 634 | fprintf(stderr, "FAIL: OBJ_create(%s)\n", curve->descr); |
515 | goto err; | 635 | goto err; |
516 | } | 636 | } |
517 | 637 | ||
@@ -524,19 +644,19 @@ ec_group_new(const struct curve *curve, const EC_METHOD *method, BN_CTX *ctx) | |||
524 | errx(1, "BN_hex2bn(cofactor)"); | 644 | errx(1, "BN_hex2bn(cofactor)"); |
525 | 645 | ||
526 | if ((group = ec_group_from_curve_method(curve, method, ctx)) == NULL) { | 646 | if ((group = ec_group_from_curve_method(curve, method, ctx)) == NULL) { |
527 | fprintf(stderr, "FAIL: %s ec_group_from_curve_method\n", curve->sn); | 647 | fprintf(stderr, "FAIL: %s ec_group_from_curve_method\n", curve->descr); |
528 | ERR_print_errors_fp(stderr); | 648 | ERR_print_errors_fp(stderr); |
529 | goto err; | 649 | goto err; |
530 | } | 650 | } |
531 | 651 | ||
532 | if (!EC_GROUP_get_cofactor(group, guessed_cofactor, ctx)) { | 652 | if (!EC_GROUP_get_cofactor(group, guessed_cofactor, ctx)) { |
533 | fprintf(stderr, "FAIL: %s EC_GROUP_get_cofactor\n", curve->sn); | 653 | fprintf(stderr, "FAIL: %s EC_GROUP_get_cofactor\n", curve->descr); |
534 | ERR_print_errors_fp(stderr); | 654 | ERR_print_errors_fp(stderr); |
535 | goto err; | 655 | goto err; |
536 | } | 656 | } |
537 | 657 | ||
538 | if (BN_cmp(cofactor, guessed_cofactor) != 0) { | 658 | if (BN_cmp(cofactor, guessed_cofactor) != 0) { |
539 | fprintf(stderr, "FAIL: %s cofactor: want ", curve->sn); | 659 | fprintf(stderr, "FAIL: %s cofactor: want ", curve->descr); |
540 | BN_print_fp(stderr, cofactor); | 660 | BN_print_fp(stderr, cofactor); |
541 | fprintf(stderr, ", got "); | 661 | fprintf(stderr, ", got "); |
542 | BN_print_fp(stderr, guessed_cofactor); | 662 | BN_print_fp(stderr, guessed_cofactor); |
@@ -545,7 +665,7 @@ ec_group_new(const struct curve *curve, const EC_METHOD *method, BN_CTX *ctx) | |||
545 | } | 665 | } |
546 | 666 | ||
547 | if (!EC_GROUP_check(group, ctx)) { | 667 | if (!EC_GROUP_check(group, ctx)) { |
548 | fprintf(stderr, "FAIL: %s EC_GROUP_check\n", curve->sn); | 668 | fprintf(stderr, "FAIL: %s EC_GROUP_check\n", curve->descr); |
549 | ERR_print_errors_fp(stderr); | 669 | ERR_print_errors_fp(stderr); |
550 | goto err; | 670 | goto err; |
551 | } | 671 | } |
@@ -583,7 +703,7 @@ ec_group_non_builtin_curve(const struct curve *curve, const EC_METHOD *method, | |||
583 | goto err; | 703 | goto err; |
584 | 704 | ||
585 | if ((nid = EC_GROUP_get_curve_name(group)) == NID_undef) { | 705 | if ((nid = EC_GROUP_get_curve_name(group)) == NID_undef) { |
586 | fprintf(stderr, "FAIL: no curve name set for %s\n", curve->sn); | 706 | fprintf(stderr, "FAIL: no curve name set for %s\n", curve->descr); |
587 | goto err; | 707 | goto err; |
588 | } | 708 | } |
589 | 709 | ||
@@ -592,7 +712,7 @@ ec_group_non_builtin_curve(const struct curve *curve, const EC_METHOD *method, | |||
592 | der = NULL; | 712 | der = NULL; |
593 | if ((der_len = i2d_ECPKParameters(group, &der)) <= 0) { | 713 | if ((der_len = i2d_ECPKParameters(group, &der)) <= 0) { |
594 | fprintf(stderr, "FAIL: %s i2d_ECPKParameters (named)\n", | 714 | fprintf(stderr, "FAIL: %s i2d_ECPKParameters (named)\n", |
595 | curve->sn); | 715 | curve->descr); |
596 | ERR_print_errors_fp(stderr); | 716 | ERR_print_errors_fp(stderr); |
597 | goto err; | 717 | goto err; |
598 | } | 718 | } |
@@ -612,12 +732,12 @@ ec_group_non_builtin_curve(const struct curve *curve, const EC_METHOD *method, | |||
612 | der = NULL; | 732 | der = NULL; |
613 | if ((der_len = i2d_ECPKParameters(group, &der)) <= 0) { | 733 | if ((der_len = i2d_ECPKParameters(group, &der)) <= 0) { |
614 | fprintf(stderr, "FAIL: i2d_ECPKParameters (explicit) %s\n", | 734 | fprintf(stderr, "FAIL: i2d_ECPKParameters (explicit) %s\n", |
615 | curve->sn); | 735 | curve->descr); |
616 | ERR_print_errors_fp(stderr); | 736 | ERR_print_errors_fp(stderr); |
617 | goto err; | 737 | goto err; |
618 | } | 738 | } |
619 | 739 | ||
620 | if (compare_data(curve->sn, der, der_len, | 740 | if (compare_data(curve->descr, der, der_len, |
621 | curve->param, curve->param_len) == -1) | 741 | curve->param, curve->param_len) == -1) |
622 | goto err; | 742 | goto err; |
623 | 743 | ||
@@ -626,7 +746,7 @@ ec_group_non_builtin_curve(const struct curve *curve, const EC_METHOD *method, | |||
626 | 746 | ||
627 | /* At this point we should have no error on the stack. */ | 747 | /* At this point we should have no error on the stack. */ |
628 | if (ERR_peek_last_error() != 0) { | 748 | if (ERR_peek_last_error() != 0) { |
629 | fprintf(stderr, "FAIL: %s unexpected error %lu\n", curve->sn, | 749 | fprintf(stderr, "FAIL: %s unexpected error %lu\n", curve->descr, |
630 | ERR_peek_last_error()); | 750 | ERR_peek_last_error()); |
631 | goto err; | 751 | goto err; |
632 | } | 752 | } |
@@ -635,14 +755,14 @@ ec_group_non_builtin_curve(const struct curve *curve, const EC_METHOD *method, | |||
635 | der_len = curve->named_len; | 755 | der_len = curve->named_len; |
636 | if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) != NULL) { | 756 | if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) != NULL) { |
637 | fprintf(stderr, "FAIL: managed to decode unknown named curve %s\n", | 757 | fprintf(stderr, "FAIL: managed to decode unknown named curve %s\n", |
638 | curve->sn); | 758 | curve->descr); |
639 | goto err; | 759 | goto err; |
640 | } | 760 | } |
641 | 761 | ||
642 | error = ERR_get_error(); | 762 | error = ERR_get_error(); |
643 | if (ERR_GET_REASON(error) != EC_R_UNKNOWN_GROUP) { | 763 | if (ERR_GET_REASON(error) != EC_R_UNKNOWN_GROUP) { |
644 | fprintf(stderr, "FAIL: %s unexpected error: want %d, got %d\n", | 764 | fprintf(stderr, "FAIL: %s unexpected error: want %d, got %d\n", |
645 | curve->sn, EC_R_UNKNOWN_GROUP, ERR_GET_REASON(error)); | 765 | curve->descr, EC_R_UNKNOWN_GROUP, ERR_GET_REASON(error)); |
646 | goto err; | 766 | goto err; |
647 | } | 767 | } |
648 | 768 | ||
@@ -652,25 +772,25 @@ ec_group_non_builtin_curve(const struct curve *curve, const EC_METHOD *method, | |||
652 | #if 0 | 772 | #if 0 |
653 | if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) != NULL) { | 773 | if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) != NULL) { |
654 | fprintf(stderr, "FAIL: managed to decode non-builtin parameters %s\n", | 774 | fprintf(stderr, "FAIL: managed to decode non-builtin parameters %s\n", |
655 | curve->sn); | 775 | curve->descr); |
656 | goto err; | 776 | goto err; |
657 | } | 777 | } |
658 | 778 | ||
659 | error = ERR_peek_last_error(); | 779 | error = ERR_peek_last_error(); |
660 | if (ERR_GET_REASON(error) != EC_R_PKPARAMETERS2GROUP_FAILURE) { | 780 | if (ERR_GET_REASON(error) != EC_R_PKPARAMETERS2GROUP_FAILURE) { |
661 | fprintf(stderr, "FAIL: %s unexpected error: want %d, got %d\n", | 781 | fprintf(stderr, "FAIL: %s unexpected error: want %d, got %d\n", |
662 | curve->sn, EC_R_UNKNOWN_GROUP, ERR_GET_REASON(error)); | 782 | curve->descr, EC_R_UNKNOWN_GROUP, ERR_GET_REASON(error)); |
663 | goto err; | 783 | goto err; |
664 | } | 784 | } |
665 | #else | 785 | #else |
666 | if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) == NULL) { | 786 | if ((new_group = d2i_ECPKParameters(NULL, &pder, der_len)) == NULL) { |
667 | fprintf(stderr, "FAIL: d2i_ECPKParameters(%s)\n", curve->sn); | 787 | fprintf(stderr, "FAIL: d2i_ECPKParameters(%s)\n", curve->descr); |
668 | goto err; | 788 | goto err; |
669 | } | 789 | } |
670 | if (method == EC_GFp_mont_method() && | 790 | if (method == EC_GFp_mont_method() && |
671 | EC_GROUP_cmp(group, new_group, ctx) != 0) { | 791 | EC_GROUP_cmp(group, new_group, ctx) != 0) { |
672 | fprintf(stderr, "FAIL: %s Weierstrass groups do not match!\n", | 792 | fprintf(stderr, "FAIL: %s Weierstrass groups do not match!\n", |
673 | curve->sn); | 793 | curve->descr); |
674 | goto err; | 794 | goto err; |
675 | } | 795 | } |
676 | #endif | 796 | #endif |
@@ -700,6 +820,12 @@ ec_group_non_builtin_curves(void) | |||
700 | failed |= ec_group_non_builtin_curve(&wei25519, EC_GFp_mont_method(), ctx); | 820 | failed |= ec_group_non_builtin_curve(&wei25519, EC_GFp_mont_method(), ctx); |
701 | failed |= ec_group_non_builtin_curve(&wei25519, EC_GFp_simple_method(), ctx); | 821 | failed |= ec_group_non_builtin_curve(&wei25519, EC_GFp_simple_method(), ctx); |
702 | 822 | ||
823 | failed |= ec_group_non_builtin_curve(&wei25519_2, EC_GFp_mont_method(), ctx); | ||
824 | failed |= ec_group_non_builtin_curve(&wei25519_2, EC_GFp_simple_method(), ctx); | ||
825 | |||
826 | failed |= ec_group_non_builtin_curve(&wei25519_3, EC_GFp_mont_method(), ctx); | ||
827 | failed |= ec_group_non_builtin_curve(&wei25519_3, EC_GFp_simple_method(), ctx); | ||
828 | |||
703 | BN_CTX_free(ctx); | 829 | BN_CTX_free(ctx); |
704 | 830 | ||
705 | return failed; | 831 | return failed; |