summaryrefslogtreecommitdiff
path: root/src/regress/lib/libssl/ssl/ssltest.c
diff options
context:
space:
mode:
authormiod <>2015-03-08 16:48:47 +0000
committermiod <>2015-03-08 16:48:47 +0000
commit7a8f138352aa4eb7b65ac4b1a5fe7630fbee1427 (patch)
tree6db03e296593fd98dcef3d6d72d36fc31c03b6d4 /src/regress/lib/libssl/ssl/ssltest.c
parent1e55b7f6250a8ae90d8b1aed376d8e93e3d7fc97 (diff)
downloadopenbsd-7a8f138352aa4eb7b65ac4b1a5fe7630fbee1427.tar.gz
openbsd-7a8f138352aa4eb7b65ac4b1a5fe7630fbee1427.tar.bz2
openbsd-7a8f138352aa4eb7b65ac4b1a5fe7630fbee1427.zip
Reject DH keys sent by a server if they are considered too small; inspired
by a similar BoringSSL change, but raising the limit to 1024 bits. ok jsing@ markus@ guenther@ deraadt@
Diffstat (limited to 'src/regress/lib/libssl/ssl/ssltest.c')
-rw-r--r--src/regress/lib/libssl/ssl/ssltest.c42
1 files changed, 4 insertions, 38 deletions
diff --git a/src/regress/lib/libssl/ssl/ssltest.c b/src/regress/lib/libssl/ssl/ssltest.c
index 91956a1322..5b03e0e0b8 100644
--- a/src/regress/lib/libssl/ssl/ssltest.c
+++ b/src/regress/lib/libssl/ssl/ssltest.c
@@ -194,7 +194,6 @@ struct app_verify_arg {
194 char *proxy_cond; 194 char *proxy_cond;
195}; 195};
196 196
197static DH *get_dh512(void);
198static DH *get_dh1024(void); 197static DH *get_dh1024(void);
199static DH *get_dh1024dsa(void); 198static DH *get_dh1024dsa(void);
200 199
@@ -428,7 +427,6 @@ sv_usage(void)
428 fprintf(stderr, " -reuse - use session-id reuse\n"); 427 fprintf(stderr, " -reuse - use session-id reuse\n");
429 fprintf(stderr, " -num <val> - number of connections to perform\n"); 428 fprintf(stderr, " -num <val> - number of connections to perform\n");
430 fprintf(stderr, " -bytes <val> - number of bytes to swap between client/server\n"); 429 fprintf(stderr, " -bytes <val> - number of bytes to swap between client/server\n");
431 fprintf(stderr, " -dhe1024 - use 1024 bit key (safe prime) for DHE\n");
432 fprintf(stderr, " -dhe1024dsa - use 1024 bit key (with 160-bit subprime) for DHE\n"); 430 fprintf(stderr, " -dhe1024dsa - use 1024 bit key (with 160-bit subprime) for DHE\n");
433 fprintf(stderr, " -no_dhe - disable DHE\n"); 431 fprintf(stderr, " -no_dhe - disable DHE\n");
434 fprintf(stderr, " -no_ecdhe - disable ECDHE\n"); 432 fprintf(stderr, " -no_ecdhe - disable ECDHE\n");
@@ -569,7 +567,7 @@ main(int argc, char *argv[])
569 int number = 1, reuse = 0; 567 int number = 1, reuse = 0;
570 long bytes = 256L; 568 long bytes = 256L;
571 DH *dh; 569 DH *dh;
572 int dhe1024 = 0, dhe1024dsa = 0; 570 int dhe1024dsa = 0;
573 EC_KEY *ecdh = NULL; 571 EC_KEY *ecdh = NULL;
574 int no_dhe = 0; 572 int no_dhe = 0;
575 int no_ecdhe = 0; 573 int no_ecdhe = 0;
@@ -612,9 +610,7 @@ main(int argc, char *argv[])
612 debug = 1; 610 debug = 1;
613 else if (strcmp(*argv, "-reuse") == 0) 611 else if (strcmp(*argv, "-reuse") == 0)
614 reuse = 1; 612 reuse = 1;
615 else if (strcmp(*argv, "-dhe1024") == 0) { 613 else if (strcmp(*argv, "-dhe1024dsa") == 0) {
616 dhe1024 = 1;
617 } else if (strcmp(*argv, "-dhe1024dsa") == 0) {
618 dhe1024dsa = 1; 614 dhe1024dsa = 1;
619 } else if (strcmp(*argv, "-no_dhe") == 0) 615 } else if (strcmp(*argv, "-no_dhe") == 0)
620 no_dhe = 1; 616 no_dhe = 1;
@@ -787,10 +783,8 @@ bad:
787 /* use SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */ 783 /* use SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */
788 SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE); 784 SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE);
789 dh = get_dh1024dsa(); 785 dh = get_dh1024dsa();
790 } else if (dhe1024) 786 } else
791 dh = get_dh1024(); 787 dh = get_dh1024();
792 else
793 dh = get_dh512();
794 SSL_CTX_set_tmp_dh(s_ctx, dh); 788 SSL_CTX_set_tmp_dh(s_ctx, dh);
795 DH_free(dh); 789 DH_free(dh);
796 } 790 }
@@ -2089,39 +2083,11 @@ free_tmp_rsa(void)
2089} 2083}
2090 2084
2091/* These DH parameters have been generated as follows: 2085/* These DH parameters have been generated as follows:
2092 * $ openssl dhparam -C -noout 512
2093 * $ openssl dhparam -C -noout 1024 2086 * $ openssl dhparam -C -noout 1024
2094 * $ openssl dhparam -C -noout -dsaparam 1024 2087 * $ openssl dhparam -C -noout -dsaparam 1024
2095 * (The third function has been renamed to avoid name conflicts.) 2088 * (The second function has been renamed to avoid name conflicts.)
2096 */ 2089 */
2097static DH * 2090static DH *
2098get_dh512()
2099{
2100 static unsigned char dh512_p[] = {
2101 0xCB, 0xC8, 0xE1, 0x86, 0xD0, 0x1F, 0x94, 0x17, 0xA6, 0x99, 0xF0, 0xC6,
2102 0x1F, 0x0D, 0xAC, 0xB6, 0x25, 0x3E, 0x06, 0x39, 0xCA, 0x72, 0x04, 0xB0,
2103 0x6E, 0xDA, 0xC0, 0x61, 0xE6, 0x7A, 0x77, 0x25, 0xE8, 0x3B, 0xB9, 0x5F,
2104 0x9A, 0xB6, 0xB5, 0xFE, 0x99, 0x0B, 0xA1, 0x93, 0x4E, 0x35, 0x33, 0xB8,
2105 0xE1, 0xF1, 0x13, 0x4F, 0x59, 0x1A, 0xD2, 0x57, 0xC0, 0x26, 0x21, 0x33,
2106 0x02, 0xC5, 0xAE, 0x23,
2107 };
2108 static unsigned char dh512_g[] = {
2109 0x02,
2110 };
2111 DH *dh;
2112
2113 if ((dh = DH_new()) == NULL)
2114 return (NULL);
2115 dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), NULL);
2116 dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), NULL);
2117 if ((dh->p == NULL) || (dh->g == NULL)) {
2118 DH_free(dh);
2119 return (NULL);
2120 }
2121 return (dh);
2122}
2123
2124static DH *
2125get_dh1024() 2091get_dh1024()
2126{ 2092{
2127 static unsigned char dh1024_p[] = { 2093 static unsigned char dh1024_p[] = {