summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2018-11-06 01:19:35 +0000
committerjsing <>2018-11-06 01:19:35 +0000
commit68865489340cd97d72f3e2a30c703e70555a0e46 (patch)
treeca9288c3cf1969cb459cfbcc86065a34d0b73960 /src
parent9fe67d92c844ca96428126668ee46195c6fdb009 (diff)
downloadopenbsd-68865489340cd97d72f3e2a30c703e70555a0e46.tar.gz
openbsd-68865489340cd97d72f3e2a30c703e70555a0e46.tar.bz2
openbsd-68865489340cd97d72f3e2a30c703e70555a0e46.zip
Unbreak regress following Supported Elliptic Curve extension rename.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libssl/tlsext/tlsexttest.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/src/regress/lib/libssl/tlsext/tlsexttest.c b/src/regress/lib/libssl/tlsext/tlsexttest.c
index d628299e3e..b50736d802 100644
--- a/src/regress/lib/libssl/tlsext/tlsexttest.c
+++ b/src/regress/lib/libssl/tlsext/tlsexttest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tlsexttest.c,v 1.18 2017/12/28 12:52:45 jsing Exp $ */ 1/* $OpenBSD: tlsexttest.c,v 1.19 2018/11/06 01:19:35 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org> 4 * Copyright (c) 2017 Doug Hogan <doug@openbsd.org>
@@ -468,34 +468,34 @@ test_tlsext_alpn_serverhello(void)
468 * This extension is only used by the client. 468 * This extension is only used by the client.
469 */ 469 */
470 470
471static uint8_t tlsext_ec_clienthello_default[] = { 471static uint8_t tlsext_supportedgroups_clienthello_default[] = {
472 0x00, 0x06, 472 0x00, 0x06,
473 0x00, 0x1d, /* X25519 (29) */ 473 0x00, 0x1d, /* X25519 (29) */
474 0x00, 0x17, /* secp256r1 (23) */ 474 0x00, 0x17, /* secp256r1 (23) */
475 0x00, 0x18 /* secp384r1 (24) */ 475 0x00, 0x18 /* secp384r1 (24) */
476}; 476};
477 477
478static uint16_t tlsext_ec_clienthello_secp384r1_val[] = { 478static uint16_t tlsext_supportedgroups_clienthello_secp384r1_val[] = {
479 0x0018 /* tls1_ec_nid2curve_id(NID_secp384r1) */ 479 0x0018 /* tls1_ec_nid2curve_id(NID_secp384r1) */
480}; 480};
481static uint8_t tlsext_ec_clienthello_secp384r1[] = { 481static uint8_t tlsext_supportedgroups_clienthello_secp384r1[] = {
482 0x00, 0x02, 482 0x00, 0x02,
483 0x00, 0x18 /* secp384r1 (24) */ 483 0x00, 0x18 /* secp384r1 (24) */
484}; 484};
485 485
486/* Example from RFC 4492 section 5.1.1 */ 486/* Example from RFC 4492 section 5.1.1 */
487static uint16_t tlsext_ec_clienthello_nistp192and224_val[] = { 487static uint16_t tlsext_supportedgroups_clienthello_nistp192and224_val[] = {
488 0x0013, /* tls1_ec_nid2curve_id(NID_X9_62_prime192v1) */ 488 0x0013, /* tls1_ec_nid2curve_id(NID_X9_62_prime192v1) */
489 0x0015 /* tls1_ec_nid2curve_id(NID_secp224r1) */ 489 0x0015 /* tls1_ec_nid2curve_id(NID_secp224r1) */
490}; 490};
491static uint8_t tlsext_ec_clienthello_nistp192and224[] = { 491static uint8_t tlsext_supportedgroups_clienthello_nistp192and224[] = {
492 0x00, 0x04, 492 0x00, 0x04,
493 0x00, 0x13, /* secp192r1 aka NIST P-192 */ 493 0x00, 0x13, /* secp192r1 aka NIST P-192 */
494 0x00, 0x15 /* secp224r1 aka NIST P-224 */ 494 0x00, 0x15 /* secp224r1 aka NIST P-224 */
495}; 495};
496 496
497static int 497static int
498test_tlsext_ec_clienthello(void) 498test_tlsext_supportedgroups_clienthello(void)
499{ 499{
500 unsigned char *data = NULL; 500 unsigned char *data = NULL;
501 SSL_CTX *ssl_ctx = NULL; 501 SSL_CTX *ssl_ctx = NULL;
@@ -518,7 +518,7 @@ test_tlsext_ec_clienthello(void)
518 /* 518 /*
519 * Default ciphers include EC so we need it by default. 519 * Default ciphers include EC so we need it by default.
520 */ 520 */
521 if (!tlsext_ec_clienthello_needs(ssl)) { 521 if (!tlsext_supportedgroups_clienthello_needs(ssl)) {
522 FAIL("clienthello should need Ellipticcurves for default " 522 FAIL("clienthello should need Ellipticcurves for default "
523 "ciphers\n"); 523 "ciphers\n");
524 goto err; 524 goto err;
@@ -531,7 +531,7 @@ test_tlsext_ec_clienthello(void)
531 FAIL("clienthello should be able to set cipher list\n"); 531 FAIL("clienthello should be able to set cipher list\n");
532 goto err; 532 goto err;
533 } 533 }
534 if (tlsext_ec_clienthello_needs(ssl)) { 534 if (tlsext_supportedgroups_clienthello_needs(ssl)) {
535 FAIL("clienthello should not need Ellipticcurves\n"); 535 FAIL("clienthello should not need Ellipticcurves\n");
536 goto err; 536 goto err;
537 } 537 }
@@ -543,7 +543,7 @@ test_tlsext_ec_clienthello(void)
543 FAIL("clienthello should be able to set cipher list\n"); 543 FAIL("clienthello should be able to set cipher list\n");
544 goto err; 544 goto err;
545 } 545 }
546 if (!tlsext_ec_clienthello_needs(ssl)) { 546 if (!tlsext_supportedgroups_clienthello_needs(ssl)) {
547 FAIL("clienthello should need Ellipticcurves\n"); 547 FAIL("clienthello should need Ellipticcurves\n");
548 goto err; 548 goto err;
549 } 549 }
@@ -562,12 +562,12 @@ test_tlsext_ec_clienthello(void)
562 SSI(ssl)->tlsext_supportedgroups[0] = tls1_ec_nid2curve_id(NID_secp384r1); 562 SSI(ssl)->tlsext_supportedgroups[0] = tls1_ec_nid2curve_id(NID_secp384r1);
563 SSI(ssl)->tlsext_supportedgroups_length = 1; 563 SSI(ssl)->tlsext_supportedgroups_length = 1;
564 564
565 if (!tlsext_ec_clienthello_needs(ssl)) { 565 if (!tlsext_supportedgroups_clienthello_needs(ssl)) {
566 FAIL("clienthello should need Ellipticcurves\n"); 566 FAIL("clienthello should need Ellipticcurves\n");
567 goto err; 567 goto err;
568 } 568 }
569 569
570 if (!tlsext_ec_clienthello_build(ssl, &cbb)) { 570 if (!tlsext_supportedgroups_clienthello_build(ssl, &cbb)) {
571 FAIL("clienthello failed to build Ellipticcurves\n"); 571 FAIL("clienthello failed to build Ellipticcurves\n");
572 goto err; 572 goto err;
573 } 573 }
@@ -575,19 +575,19 @@ test_tlsext_ec_clienthello(void)
575 if (!CBB_finish(&cbb, &data, &dlen)) 575 if (!CBB_finish(&cbb, &data, &dlen))
576 errx(1, "failed to finish CBB"); 576 errx(1, "failed to finish CBB");
577 577
578 if (dlen != sizeof(tlsext_ec_clienthello_default)) { 578 if (dlen != sizeof(tlsext_supportedgroups_clienthello_default)) {
579 FAIL("got clienthello Ellipticcurves with length %zu, " 579 FAIL("got clienthello Ellipticcurves with length %zu, "
580 "want length %zu\n", dlen, 580 "want length %zu\n", dlen,
581 sizeof(tlsext_ec_clienthello_default)); 581 sizeof(tlsext_supportedgroups_clienthello_default));
582 compare_data(data, dlen, tlsext_ec_clienthello_default, 582 compare_data(data, dlen, tlsext_supportedgroups_clienthello_default,
583 sizeof(tlsext_ec_clienthello_default)); 583 sizeof(tlsext_supportedgroups_clienthello_default));
584 goto err; 584 goto err;
585 } 585 }
586 586
587 if (memcmp(data, tlsext_ec_clienthello_default, dlen) != 0) { 587 if (memcmp(data, tlsext_supportedgroups_clienthello_default, dlen) != 0) {
588 FAIL("clienthello Ellipticcurves differs:\n"); 588 FAIL("clienthello Ellipticcurves differs:\n");
589 compare_data(data, dlen, tlsext_ec_clienthello_default, 589 compare_data(data, dlen, tlsext_supportedgroups_clienthello_default,
590 sizeof(tlsext_ec_clienthello_default)); 590 sizeof(tlsext_supportedgroups_clienthello_default));
591 goto err; 591 goto err;
592 } 592 }
593 593
@@ -603,9 +603,9 @@ test_tlsext_ec_clienthello(void)
603 if ((ssl->session = SSL_SESSION_new()) == NULL) 603 if ((ssl->session = SSL_SESSION_new()) == NULL)
604 errx(1, "failed to create session"); 604 errx(1, "failed to create session");
605 605
606 CBS_init(&cbs, tlsext_ec_clienthello_secp384r1, 606 CBS_init(&cbs, tlsext_supportedgroups_clienthello_secp384r1,
607 sizeof(tlsext_ec_clienthello_secp384r1)); 607 sizeof(tlsext_supportedgroups_clienthello_secp384r1));
608 if (!tlsext_ec_clienthello_parse(ssl, &cbs, &alert)) { 608 if (!tlsext_supportedgroups_clienthello_parse(ssl, &cbs, &alert)) {
609 FAIL("failed to parse clienthello Ellipticcurves\n"); 609 FAIL("failed to parse clienthello Ellipticcurves\n");
610 goto err; 610 goto err;
611 } 611 }
@@ -615,21 +615,21 @@ test_tlsext_ec_clienthello(void)
615 } 615 }
616 616
617 if (SSI(ssl)->tlsext_supportedgroups_length != 617 if (SSI(ssl)->tlsext_supportedgroups_length !=
618 sizeof(tlsext_ec_clienthello_secp384r1_val) / sizeof(uint16_t)) { 618 sizeof(tlsext_supportedgroups_clienthello_secp384r1_val) / sizeof(uint16_t)) {
619 FAIL("no tlsext_ellipticcurves from clienthello " 619 FAIL("no tlsext_ellipticcurves from clienthello "
620 "Ellipticcurves\n"); 620 "Ellipticcurves\n");
621 goto err; 621 goto err;
622 } 622 }
623 623
624 if (memcmp(SSI(ssl)->tlsext_supportedgroups, 624 if (memcmp(SSI(ssl)->tlsext_supportedgroups,
625 tlsext_ec_clienthello_secp384r1_val, 625 tlsext_supportedgroups_clienthello_secp384r1_val,
626 sizeof(tlsext_ec_clienthello_secp384r1_val)) != 0) { 626 sizeof(tlsext_supportedgroups_clienthello_secp384r1_val)) != 0) {
627 FAIL("clienthello had an incorrect Ellipticcurves " 627 FAIL("clienthello had an incorrect Ellipticcurves "
628 "entry\n"); 628 "entry\n");
629 compare_data2(SSI(ssl)->tlsext_supportedgroups, 629 compare_data2(SSI(ssl)->tlsext_supportedgroups,
630 SSI(ssl)->tlsext_supportedgroups_length * 2, 630 SSI(ssl)->tlsext_supportedgroups_length * 2,
631 tlsext_ec_clienthello_secp384r1_val, 631 tlsext_supportedgroups_clienthello_secp384r1_val,
632 sizeof(tlsext_ec_clienthello_secp384r1_val)); 632 sizeof(tlsext_supportedgroups_clienthello_secp384r1_val));
633 goto err; 633 goto err;
634 } 634 }
635 635
@@ -651,12 +651,12 @@ test_tlsext_ec_clienthello(void)
651 ssl->internal->tlsext_supportedgroups[1] = tls1_ec_nid2curve_id(NID_secp224r1); 651 ssl->internal->tlsext_supportedgroups[1] = tls1_ec_nid2curve_id(NID_secp224r1);
652 ssl->internal->tlsext_supportedgroups_length = 2; 652 ssl->internal->tlsext_supportedgroups_length = 2;
653 653
654 if (!tlsext_ec_clienthello_needs(ssl)) { 654 if (!tlsext_supportedgroups_clienthello_needs(ssl)) {
655 FAIL("clienthello should need Ellipticcurves\n"); 655 FAIL("clienthello should need Ellipticcurves\n");
656 goto err; 656 goto err;
657 } 657 }
658 658
659 if (!tlsext_ec_clienthello_build(ssl, &cbb)) { 659 if (!tlsext_supportedgroups_clienthello_build(ssl, &cbb)) {
660 FAIL("clienthello failed to build Ellipticcurves\n"); 660 FAIL("clienthello failed to build Ellipticcurves\n");
661 goto err; 661 goto err;
662 } 662 }
@@ -664,25 +664,25 @@ test_tlsext_ec_clienthello(void)
664 if (!CBB_finish(&cbb, &data, &dlen)) 664 if (!CBB_finish(&cbb, &data, &dlen))
665 errx(1, "failed to finish CBB"); 665 errx(1, "failed to finish CBB");
666 666
667 if (dlen != sizeof(tlsext_ec_clienthello_nistp192and224)) { 667 if (dlen != sizeof(tlsext_supportedgroups_clienthello_nistp192and224)) {
668 FAIL("got clienthello Ellipticcurves with length %zu, " 668 FAIL("got clienthello Ellipticcurves with length %zu, "
669 "want length %zu\n", dlen, 669 "want length %zu\n", dlen,
670 sizeof(tlsext_ec_clienthello_nistp192and224)); 670 sizeof(tlsext_supportedgroups_clienthello_nistp192and224));
671 fprintf(stderr, "received:\n"); 671 fprintf(stderr, "received:\n");
672 hexdump(data, dlen); 672 hexdump(data, dlen);
673 fprintf(stderr, "test data:\n"); 673 fprintf(stderr, "test data:\n");
674 hexdump(tlsext_ec_clienthello_nistp192and224, 674 hexdump(tlsext_supportedgroups_clienthello_nistp192and224,
675 sizeof(tlsext_ec_clienthello_nistp192and224)); 675 sizeof(tlsext_supportedgroups_clienthello_nistp192and224));
676 goto err; 676 goto err;
677 } 677 }
678 678
679 if (memcmp(data, tlsext_ec_clienthello_nistp192and224, dlen) != 0) { 679 if (memcmp(data, tlsext_supportedgroups_clienthello_nistp192and224, dlen) != 0) {
680 FAIL("clienthello Ellipticcurves differs:\n"); 680 FAIL("clienthello Ellipticcurves differs:\n");
681 fprintf(stderr, "received:\n"); 681 fprintf(stderr, "received:\n");
682 hexdump(data, dlen); 682 hexdump(data, dlen);
683 fprintf(stderr, "test data:\n"); 683 fprintf(stderr, "test data:\n");
684 hexdump(tlsext_ec_clienthello_nistp192and224, 684 hexdump(tlsext_supportedgroups_clienthello_nistp192and224,
685 sizeof(tlsext_ec_clienthello_nistp192and224)); 685 sizeof(tlsext_supportedgroups_clienthello_nistp192and224));
686 goto err; 686 goto err;
687 } 687 }
688 688
@@ -703,9 +703,9 @@ test_tlsext_ec_clienthello(void)
703 ssl->internal->tlsext_supportedgroups = NULL; 703 ssl->internal->tlsext_supportedgroups = NULL;
704 ssl->internal->tlsext_supportedgroups_length = 0; 704 ssl->internal->tlsext_supportedgroups_length = 0;
705 705
706 CBS_init(&cbs, tlsext_ec_clienthello_nistp192and224, 706 CBS_init(&cbs, tlsext_supportedgroups_clienthello_nistp192and224,
707 sizeof(tlsext_ec_clienthello_nistp192and224)); 707 sizeof(tlsext_supportedgroups_clienthello_nistp192and224));
708 if (!tlsext_ec_clienthello_parse(ssl, &cbs, &alert)) { 708 if (!tlsext_supportedgroups_clienthello_parse(ssl, &cbs, &alert)) {
709 FAIL("failed to parse clienthello Ellipticcurves\n"); 709 FAIL("failed to parse clienthello Ellipticcurves\n");
710 goto err; 710 goto err;
711 } 711 }
@@ -715,20 +715,20 @@ test_tlsext_ec_clienthello(void)
715 } 715 }
716 716
717 if (SSI(ssl)->tlsext_supportedgroups_length != 717 if (SSI(ssl)->tlsext_supportedgroups_length !=
718 sizeof(tlsext_ec_clienthello_nistp192and224_val) / sizeof(uint16_t)) { 718 sizeof(tlsext_supportedgroups_clienthello_nistp192and224_val) / sizeof(uint16_t)) {
719 FAIL("no tlsext_ellipticcurves from clienthello " 719 FAIL("no tlsext_ellipticcurves from clienthello "
720 "Ellipticcurves\n"); 720 "Ellipticcurves\n");
721 goto err; 721 goto err;
722 } 722 }
723 723
724 if (memcmp(SSI(ssl)->tlsext_supportedgroups, 724 if (memcmp(SSI(ssl)->tlsext_supportedgroups,
725 tlsext_ec_clienthello_nistp192and224_val, 725 tlsext_supportedgroups_clienthello_nistp192and224_val,
726 sizeof(tlsext_ec_clienthello_nistp192and224_val)) != 0) { 726 sizeof(tlsext_supportedgroups_clienthello_nistp192and224_val)) != 0) {
727 FAIL("clienthello had an incorrect Ellipticcurves entry\n"); 727 FAIL("clienthello had an incorrect Ellipticcurves entry\n");
728 compare_data2(SSI(ssl)->tlsext_supportedgroups, 728 compare_data2(SSI(ssl)->tlsext_supportedgroups,
729 SSI(ssl)->tlsext_supportedgroups_length * 2, 729 SSI(ssl)->tlsext_supportedgroups_length * 2,
730 tlsext_ec_clienthello_nistp192and224_val, 730 tlsext_supportedgroups_clienthello_nistp192and224_val,
731 sizeof(tlsext_ec_clienthello_nistp192and224_val)); 731 sizeof(tlsext_supportedgroups_clienthello_nistp192and224_val));
732 goto err; 732 goto err;
733 } 733 }
734 734
@@ -746,7 +746,7 @@ test_tlsext_ec_clienthello(void)
746 746
747/* elliptic_curves is only used by the client so this doesn't test much. */ 747/* elliptic_curves is only used by the client so this doesn't test much. */
748static int 748static int
749test_tlsext_ec_serverhello(void) 749test_tlsext_supportedgroups_serverhello(void)
750{ 750{
751 SSL_CTX *ssl_ctx = NULL; 751 SSL_CTX *ssl_ctx = NULL;
752 SSL *ssl = NULL; 752 SSL *ssl = NULL;
@@ -759,7 +759,7 @@ test_tlsext_ec_serverhello(void)
759 if ((ssl = SSL_new(ssl_ctx)) == NULL) 759 if ((ssl = SSL_new(ssl_ctx)) == NULL)
760 errx(1, "failed to create SSL"); 760 errx(1, "failed to create SSL");
761 761
762 if (tlsext_ec_serverhello_needs(ssl)) { 762 if (tlsext_supportedgroups_serverhello_needs(ssl)) {
763 FAIL("serverhello should not need elliptic_curves\n"); 763 FAIL("serverhello should not need elliptic_curves\n");
764 goto err; 764 goto err;
765 } 765 }
@@ -767,7 +767,7 @@ test_tlsext_ec_serverhello(void)
767 if ((ssl->session = SSL_SESSION_new()) == NULL) 767 if ((ssl->session = SSL_SESSION_new()) == NULL)
768 errx(1, "failed to create session"); 768 errx(1, "failed to create session");
769 769
770 if (tlsext_ec_serverhello_needs(ssl)) { 770 if (tlsext_supportedgroups_serverhello_needs(ssl)) {
771 FAIL("serverhello should not need elliptic_curves\n"); 771 FAIL("serverhello should not need elliptic_curves\n");
772 goto err; 772 goto err;
773 } 773 }
@@ -2946,8 +2946,8 @@ main(int argc, char **argv)
2946 failed |= test_tlsext_alpn_clienthello(); 2946 failed |= test_tlsext_alpn_clienthello();
2947 failed |= test_tlsext_alpn_serverhello(); 2947 failed |= test_tlsext_alpn_serverhello();
2948 2948
2949 failed |= test_tlsext_ec_clienthello(); 2949 failed |= test_tlsext_supportedgroups_clienthello();
2950 failed |= test_tlsext_ec_serverhello(); 2950 failed |= test_tlsext_supportedgroups_serverhello();
2951 2951
2952 failed |= test_tlsext_ecpf_clienthello(); 2952 failed |= test_tlsext_ecpf_clienthello();
2953 failed |= test_tlsext_ecpf_serverhello(); 2953 failed |= test_tlsext_ecpf_serverhello();