summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/ssl/ssltest.c
diff options
context:
space:
mode:
authorbeck <>2000-04-15 06:18:51 +0000
committerbeck <>2000-04-15 06:18:51 +0000
commitb608c7f2b175e121f2c22d53341a317153afdc8e (patch)
treee94b160b3fcd8180df79e4251d68d24d665f0195 /src/lib/libssl/src/ssl/ssltest.c
parentc8d6701c396cebdcd0d45eac73b762e9498f6b01 (diff)
downloadopenbsd-b608c7f2b175e121f2c22d53341a317153afdc8e.tar.gz
openbsd-b608c7f2b175e121f2c22d53341a317153afdc8e.tar.bz2
openbsd-b608c7f2b175e121f2c22d53341a317153afdc8e.zip
OpenSSL 0.9.5a merge
Diffstat (limited to 'src/lib/libssl/src/ssl/ssltest.c')
-rw-r--r--src/lib/libssl/src/ssl/ssltest.c350
1 files changed, 247 insertions, 103 deletions
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c
index d655bbbd84..dde35794f5 100644
--- a/src/lib/libssl/src/ssl/ssltest.c
+++ b/src/lib/libssl/src/ssl/ssltest.c
@@ -62,11 +62,13 @@
62#include <stdio.h> 62#include <stdio.h>
63#include <stdlib.h> 63#include <stdlib.h>
64#include <string.h> 64#include <string.h>
65#include <time.h>
65 66
66#include "openssl/e_os.h" 67#include "openssl/e_os.h"
67 68
68#include <openssl/bio.h> 69#include <openssl/bio.h>
69#include <openssl/crypto.h> 70#include <openssl/crypto.h>
71#include <openssl/evp.h>
70#include <openssl/x509.h> 72#include <openssl/x509.h>
71#include <openssl/ssl.h> 73#include <openssl/ssl.h>
72#include <openssl/err.h> 74#include <openssl/err.h>
@@ -89,9 +91,8 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
89#endif 91#endif
90#ifndef NO_DH 92#ifndef NO_DH
91static DH *get_dh512(void); 93static DH *get_dh512(void);
92#endif 94static DH *get_dh1024(void);
93#ifndef NO_DSA 95static DH *get_dh1024dsa(void);
94static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
95#endif 96#endif
96 97
97static BIO *bio_err=NULL; 98static BIO *bio_err=NULL;
@@ -109,7 +110,7 @@ static int s_nbio=0;
109 110
110static const char rnd_seed[] = "string to make the random number generator think it has entropy"; 111static const char rnd_seed[] = "string to make the random number generator think it has entropy";
111 112
112int doit_biopair(SSL *s_ssl,SSL *c_ssl,long bytes); 113int doit_biopair(SSL *s_ssl,SSL *c_ssl,long bytes,clock_t *s_time,clock_t *c_time);
113int doit(SSL *s_ssl,SSL *c_ssl,long bytes); 114int doit(SSL *s_ssl,SSL *c_ssl,long bytes);
114static void sv_usage(void) 115static void sv_usage(void)
115 { 116 {
@@ -122,10 +123,9 @@ static void sv_usage(void)
122 fprintf(stderr," -reuse - use session-id reuse\n"); 123 fprintf(stderr," -reuse - use session-id reuse\n");
123 fprintf(stderr," -num <val> - number of connections to perform\n"); 124 fprintf(stderr," -num <val> - number of connections to perform\n");
124 fprintf(stderr," -bytes <val> - number of bytes to swap between client/server\n"); 125 fprintf(stderr," -bytes <val> - number of bytes to swap between client/server\n");
125#if !defined NO_DH && !defined NO_DSA 126#ifndef NO_DH
126 fprintf(stderr," -dhe1024 - generate 1024 bit key for DHE\n"); 127 fprintf(stderr," -dhe1024 - use 1024 bit key (safe prime) for DHE\n");
127#endif 128 fprintf(stderr," -dhe1024dsa - use 1024 bit key (with 160-bit subprime) for DHE\n");
128#if !defined NO_DH
129 fprintf(stderr," -no_dhe - disable DHE\n"); 129 fprintf(stderr," -no_dhe - disable DHE\n");
130#endif 130#endif
131#ifndef NO_SSL2 131#ifndef NO_SSL2
@@ -139,12 +139,58 @@ static void sv_usage(void)
139#endif 139#endif
140 fprintf(stderr," -CApath arg - PEM format directory of CA's\n"); 140 fprintf(stderr," -CApath arg - PEM format directory of CA's\n");
141 fprintf(stderr," -CAfile arg - PEM format file of CA's\n"); 141 fprintf(stderr," -CAfile arg - PEM format file of CA's\n");
142 fprintf(stderr," -cert arg - Certificate file\n"); 142 fprintf(stderr," -cert arg - Server certificate file\n");
143 fprintf(stderr," -s_cert arg - Just the server certificate file\n"); 143 fprintf(stderr," -key arg - Server key file (default: same as -cert)\n");
144 fprintf(stderr," -c_cert arg - Just the client certificate file\n"); 144 fprintf(stderr," -c_cert arg - Client certificate file\n");
145 fprintf(stderr," -c_key arg - Client key file (default: same as -c_cert)\n");
145 fprintf(stderr," -cipher arg - The cipher list\n"); 146 fprintf(stderr," -cipher arg - The cipher list\n");
146 fprintf(stderr," -bio_pair - Use BIO pairs\n"); 147 fprintf(stderr," -bio_pair - Use BIO pairs\n");
147 fprintf(stderr," -f - Test even cases that can't work\n"); 148 fprintf(stderr," -f - Test even cases that can't work\n");
149 fprintf(stderr," -time - measure processor time used by client and server\n");
150 }
151
152static void print_details(SSL *c_ssl, const char *prefix)
153 {
154 SSL_CIPHER *ciph;
155 X509 *cert;
156
157 ciph=SSL_get_current_cipher(c_ssl);
158 BIO_printf(bio_stdout,"%s%s, cipher %s %s",
159 prefix,
160 SSL_get_version(c_ssl),
161 SSL_CIPHER_get_version(ciph),
162 SSL_CIPHER_get_name(ciph));
163 cert=SSL_get_peer_certificate(c_ssl);
164 if (cert != NULL)
165 {
166 EVP_PKEY *pkey = X509_get_pubkey(cert);
167 if (pkey != NULL)
168 {
169 if (0)
170 ;
171#ifndef NO_RSA
172 else if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL
173 && pkey->pkey.rsa->n != NULL)
174 {
175 BIO_printf(bio_stdout, ", %d bit RSA",
176 BN_num_bits(pkey->pkey.rsa->n));
177 }
178#endif
179#ifndef NO_DSA
180 else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL
181 && pkey->pkey.dsa->p != NULL)
182 {
183 BIO_printf(bio_stdout, ", %d bit DSA",
184 BN_num_bits(pkey->pkey.dsa->p));
185 }
186#endif
187 EVP_PKEY_free(pkey);
188 }
189 X509_free(cert);
190 }
191 /* The SSL API does not allow us to look at temporary RSA/DH keys,
192 * otherwise we should print their lengths too */
193 BIO_printf(bio_stdout,"\n");
148 } 194 }
149 195
150int main(int argc, char *argv[]) 196int main(int argc, char *argv[])
@@ -157,18 +203,23 @@ int main(int argc, char *argv[])
157 int client_auth=0; 203 int client_auth=0;
158 int server_auth=0,i; 204 int server_auth=0,i;
159 char *server_cert=TEST_SERVER_CERT; 205 char *server_cert=TEST_SERVER_CERT;
206 char *server_key=NULL;
160 char *client_cert=TEST_CLIENT_CERT; 207 char *client_cert=TEST_CLIENT_CERT;
208 char *client_key=NULL;
161 SSL_CTX *s_ctx=NULL; 209 SSL_CTX *s_ctx=NULL;
162 SSL_CTX *c_ctx=NULL; 210 SSL_CTX *c_ctx=NULL;
163 SSL_METHOD *meth=NULL; 211 SSL_METHOD *meth=NULL;
164 SSL *c_ssl,*s_ssl; 212 SSL *c_ssl,*s_ssl;
165 int number=1,reuse=0; 213 int number=1,reuse=0;
166 long bytes=1L; 214 long bytes=1L;
167 SSL_CIPHER *ciph;
168 int dhe1024 = 0, no_dhe = 0;
169#ifndef NO_DH 215#ifndef NO_DH
170 DH *dh; 216 DH *dh;
217 int dhe1024 = 0, dhe1024dsa = 0;
171#endif 218#endif
219 int no_dhe = 0;
220 int print_time = 0;
221 clock_t s_time = 0, c_time = 0;
222
172 verbose = 0; 223 verbose = 0;
173 debug = 0; 224 debug = 0;
174 cipher = 0; 225 cipher = 0;
@@ -195,8 +246,12 @@ int main(int argc, char *argv[])
195 debug=1; 246 debug=1;
196 else if (strcmp(*argv,"-reuse") == 0) 247 else if (strcmp(*argv,"-reuse") == 0)
197 reuse=1; 248 reuse=1;
249#ifndef NO_DH
198 else if (strcmp(*argv,"-dhe1024") == 0) 250 else if (strcmp(*argv,"-dhe1024") == 0)
199 dhe1024=1; 251 dhe1024=1;
252 else if (strcmp(*argv,"-dhe1024dsa") == 0)
253 dhe1024dsa=1;
254#endif
200 else if (strcmp(*argv,"-no_dhe") == 0) 255 else if (strcmp(*argv,"-no_dhe") == 0)
201 no_dhe=1; 256 no_dhe=1;
202 else if (strcmp(*argv,"-ssl2") == 0) 257 else if (strcmp(*argv,"-ssl2") == 0)
@@ -230,11 +285,26 @@ int main(int argc, char *argv[])
230 if (--argc < 1) goto bad; 285 if (--argc < 1) goto bad;
231 server_cert= *(++argv); 286 server_cert= *(++argv);
232 } 287 }
288 else if (strcmp(*argv,"-key") == 0)
289 {
290 if (--argc < 1) goto bad;
291 server_key= *(++argv);
292 }
293 else if (strcmp(*argv,"-s_key") == 0)
294 {
295 if (--argc < 1) goto bad;
296 server_key= *(++argv);
297 }
233 else if (strcmp(*argv,"-c_cert") == 0) 298 else if (strcmp(*argv,"-c_cert") == 0)
234 { 299 {
235 if (--argc < 1) goto bad; 300 if (--argc < 1) goto bad;
236 client_cert= *(++argv); 301 client_cert= *(++argv);
237 } 302 }
303 else if (strcmp(*argv,"-c_key") == 0)
304 {
305 if (--argc < 1) goto bad;
306 client_key= *(++argv);
307 }
238 else if (strcmp(*argv,"-cipher") == 0) 308 else if (strcmp(*argv,"-cipher") == 0)
239 { 309 {
240 if (--argc < 1) goto bad; 310 if (--argc < 1) goto bad;
@@ -258,6 +328,10 @@ int main(int argc, char *argv[])
258 { 328 {
259 force = 1; 329 force = 1;
260 } 330 }
331 else if (strcmp(*argv,"-time") == 0)
332 {
333 print_time = 1;
334 }
261 else 335 else
262 { 336 {
263 fprintf(stderr,"unknown option %s\n",*argv); 337 fprintf(stderr,"unknown option %s\n",*argv);
@@ -276,15 +350,24 @@ bad:
276 350
277 if (!ssl2 && !ssl3 && !tls1 && number > 1 && !reuse && !force) 351 if (!ssl2 && !ssl3 && !tls1 && number > 1 && !reuse && !force)
278 { 352 {
279 fprintf(stderr, "This case cannot work. Use -f switch to perform " 353 fprintf(stderr, "This case cannot work. Use -f to perform "
280 "the test anyway\n" 354 "the test anyway (and\n-d to see what happens), "
281 "(and -d to see what happens, " 355 "or add one of -ssl2, -ssl3, -tls1, -reuse\n"
282 "and -bio_pair to really make it happen :-)\n" 356 "to avoid protocol mismatch.\n");
283 "or add one of -ssl2, -ssl3, -tls1, -reuse to "
284 "avoid protocol mismatch.\n");
285 exit(1); 357 exit(1);
286 } 358 }
287 359
360 if (print_time)
361 {
362 if (!bio_pair)
363 {
364 fprintf(stderr, "Using BIO pair (-bio_pair)\n");
365 bio_pair = 1;
366 }
367 if (number < 50 && !force)
368 fprintf(stderr, "Warning: For accurate timings, use more connections (e.g. -num 1000)\n");
369 }
370
288/* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */ 371/* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */
289 372
290 SSL_library_init(); 373 SSL_library_init();
@@ -326,34 +409,21 @@ bad:
326#ifndef NO_DH 409#ifndef NO_DH
327 if (!no_dhe) 410 if (!no_dhe)
328 { 411 {
329# ifndef NO_DSA 412 if (dhe1024dsa)
330 if (dhe1024)
331 { 413 {
332 DSA *dsa; 414 /* use SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */
333 unsigned char seed[20];
334
335 if (verbose)
336 {
337 BIO_printf(bio_err, "Creating 1024 bit DHE parameters\n");
338 BIO_flush(bio_err);
339 }
340
341 memcpy(seed, "Random String no. 12", 20);
342 dsa = DSA_generate_parameters(1024, seed, 20, NULL, NULL, dsa_cb, bio_err);
343 dh = DSA_dup_DH(dsa);
344 DSA_free(dsa);
345 /* important: SSL_OP_SINGLE_DH_USE to avoid small subgroup attacks */
346 SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE); 415 SSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE);
347 416 dh=get_dh1024dsa();
348 if (verbose)
349 fprintf(stdout, " done\n");
350 } 417 }
418 else if (dhe1024)
419 dh=get_dh1024();
351 else 420 else
352# endif
353 dh=get_dh512(); 421 dh=get_dh512();
354 SSL_CTX_set_tmp_dh(s_ctx,dh); 422 SSL_CTX_set_tmp_dh(s_ctx,dh);
355 DH_free(dh); 423 DH_free(dh);
356 } 424 }
425#else
426 (void)no_dhe;
357#endif 427#endif
358 428
359#ifndef NO_RSA 429#ifndef NO_RSA
@@ -364,8 +434,8 @@ bad:
364 { 434 {
365 ERR_print_errors(bio_err); 435 ERR_print_errors(bio_err);
366 } 436 }
367 else if (!SSL_CTX_use_PrivateKey_file(s_ctx,server_cert, 437 else if (!SSL_CTX_use_PrivateKey_file(s_ctx,
368 SSL_FILETYPE_PEM)) 438 (server_key?server_key:server_cert), SSL_FILETYPE_PEM))
369 { 439 {
370 ERR_print_errors(bio_err); 440 ERR_print_errors(bio_err);
371 goto end; 441 goto end;
@@ -375,7 +445,8 @@ bad:
375 { 445 {
376 SSL_CTX_use_certificate_file(c_ctx,client_cert, 446 SSL_CTX_use_certificate_file(c_ctx,client_cert,
377 SSL_FILETYPE_PEM); 447 SSL_FILETYPE_PEM);
378 SSL_CTX_use_PrivateKey_file(c_ctx,client_cert, 448 SSL_CTX_use_PrivateKey_file(c_ctx,
449 (client_key?client_key:client_cert),
379 SSL_FILETYPE_PEM); 450 SSL_FILETYPE_PEM);
380 } 451 }
381 452
@@ -415,21 +486,38 @@ bad:
415 { 486 {
416 if (!reuse) SSL_set_session(c_ssl,NULL); 487 if (!reuse) SSL_set_session(c_ssl,NULL);
417 if (bio_pair) 488 if (bio_pair)
418 ret=doit_biopair(s_ssl,c_ssl,bytes); 489 ret=doit_biopair(s_ssl,c_ssl,bytes,&s_time,&c_time);
419 else 490 else
420 ret=doit(s_ssl,c_ssl,bytes); 491 ret=doit(s_ssl,c_ssl,bytes);
421 } 492 }
422 493
423 if (!verbose) 494 if (!verbose)
424 { 495 {
425 ciph=SSL_get_current_cipher(c_ssl); 496 print_details(c_ssl, "");
426 BIO_printf(bio_stdout,"Protocol %s, cipher %s, %s\n",
427 SSL_get_version(c_ssl),
428 SSL_CIPHER_get_version(ciph),
429 SSL_CIPHER_get_name(ciph));
430 } 497 }
431 if ((number > 1) || (bytes > 1L)) 498 if ((number > 1) || (bytes > 1L))
432 BIO_printf(bio_stdout, "%d handshakes of %ld bytes done\n",number,bytes); 499 BIO_printf(bio_stdout, "%d handshakes of %ld bytes done\n",number,bytes);
500 if (print_time)
501 {
502#ifdef CLOCKS_PER_SEC
503 /* "To determine the time in seconds, the value returned
504 * by the clock function should be divided by the value
505 * of the macro CLOCKS_PER_SEC."
506 * -- ISO/IEC 9899 */
507 BIO_printf(bio_stdout, "Approximate total server time: %6.2f s\n"
508 "Approximate total client time: %6.2f s\n",
509 (double)s_time/CLOCKS_PER_SEC,
510 (double)c_time/CLOCKS_PER_SEC);
511#else
512 /* "`CLOCKS_PER_SEC' undeclared (first use this function)"
513 * -- cc on NeXTstep/OpenStep */
514 BIO_printf(bio_stdout,
515 "Approximate total server time: %6.2f units\n"
516 "Approximate total client time: %6.2f units\n",
517 (double)s_time,
518 (double)c_time);
519#endif
520 }
433 521
434 SSL_free(s_ssl); 522 SSL_free(s_ssl);
435 SSL_free(c_ssl); 523 SSL_free(c_ssl);
@@ -448,12 +536,12 @@ end:
448 EXIT(ret); 536 EXIT(ret);
449 } 537 }
450 538
451int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count) 539int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count,
540 clock_t *s_time, clock_t *c_time)
452 { 541 {
453 long cw_num = count, cr_num = count, sw_num = count, sr_num = count; 542 long cw_num = count, cr_num = count, sw_num = count, sr_num = count;
454 BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL; 543 BIO *s_ssl_bio = NULL, *c_ssl_bio = NULL;
455 BIO *server = NULL, *server_io = NULL, *client = NULL, *client_io = NULL; 544 BIO *server = NULL, *server_io = NULL, *client = NULL, *client_io = NULL;
456 SSL_CIPHER *ciph;
457 int ret = 1; 545 int ret = 1;
458 546
459 size_t bufsiz = 256; /* small buffer for testing */ 547 size_t bufsiz = 256; /* small buffer for testing */
@@ -526,6 +614,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
526 614
527 MS_STATIC char cbuf[1024*8]; 615 MS_STATIC char cbuf[1024*8];
528 int i, r; 616 int i, r;
617 clock_t c_clock = clock();
529 618
530 if (debug) 619 if (debug)
531 if (SSL_in_init(c_ssl)) 620 if (SSL_in_init(c_ssl))
@@ -592,6 +681,16 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
592 cr_num -= r; 681 cr_num -= r;
593 } 682 }
594 } 683 }
684
685 /* c_time and s_time increments will typically be very small
686 * (depending on machine speed and clock tick intervals),
687 * but sampling over a large number of connections should
688 * result in fairly accurate figures. We cannot guarantee
689 * a lot, however -- if each connection lasts for exactly
690 * one clock tick, it will be counted only for the client
691 * or only for the server or even not at all.
692 */
693 *c_time += (clock() - c_clock);
595 } 694 }
596 695
597 { 696 {
@@ -599,6 +698,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
599 698
600 MS_STATIC char sbuf[1024*8]; 699 MS_STATIC char sbuf[1024*8];
601 int i, r; 700 int i, r;
701 clock_t s_clock = clock();
602 702
603 if (debug) 703 if (debug)
604 if (SSL_in_init(s_ssl)) 704 if (SSL_in_init(s_ssl))
@@ -662,6 +762,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
662 sr_num -= r; 762 sr_num -= r;
663 } 763 }
664 } 764 }
765
766 *s_time += (clock() - s_clock);
665 } 767 }
666 768
667 { 769 {
@@ -787,13 +889,9 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
787 } 889 }
788 while (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0); 890 while (cw_num > 0 || cr_num > 0 || sw_num > 0 || sr_num > 0);
789 891
790 ciph = SSL_get_current_cipher(c_ssl);
791 if (verbose) 892 if (verbose)
792 fprintf(stdout,"DONE via BIO pair, protocol %s, cipher %s, %s\n", 893 print_details(c_ssl, "DONE via BIO pair: ");
793 SSL_get_version(c_ssl), 894end:
794 SSL_CIPHER_get_version(ciph),
795 SSL_CIPHER_get_name(ciph));
796 end:
797 ret = 0; 895 ret = 0;
798 896
799 err: 897 err:
@@ -837,7 +935,6 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
837 int done=0; 935 int done=0;
838 int c_write,s_write; 936 int c_write,s_write;
839 int do_server=0,do_client=0; 937 int do_server=0,do_client=0;
840 SSL_CIPHER *ciph;
841 938
842 c_to_s=BIO_new(BIO_s_mem()); 939 c_to_s=BIO_new(BIO_s_mem());
843 s_to_c=BIO_new(BIO_s_mem()); 940 s_to_c=BIO_new(BIO_s_mem());
@@ -1087,12 +1184,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
1087 if ((done & S_DONE) && (done & C_DONE)) break; 1184 if ((done & S_DONE) && (done & C_DONE)) break;
1088 } 1185 }
1089 1186
1090 ciph=SSL_get_current_cipher(c_ssl);
1091 if (verbose) 1187 if (verbose)
1092 fprintf(stdout,"DONE, protocol %s, cipher %s, %s\n", 1188 print_details(c_ssl, "DONE: ");
1093 SSL_get_version(c_ssl),
1094 SSL_CIPHER_get_version(ciph),
1095 SSL_CIPHER_get_name(ciph));
1096 ret=0; 1189 ret=0;
1097err: 1190err:
1098 /* We have to set the BIO's to NULL otherwise they will be 1191 /* We have to set the BIO's to NULL otherwise they will be
@@ -1148,32 +1241,6 @@ static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
1148 return(ok); 1241 return(ok);
1149 } 1242 }
1150 1243
1151#ifndef NO_DH
1152static unsigned char dh512_p[]={
1153 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,
1154 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,
1155 0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3,
1156 0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,
1157 0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C,
1158 0x47,0x74,0xE8,0x33,
1159 };
1160static unsigned char dh512_g[]={
1161 0x02,
1162 };
1163
1164static DH *get_dh512(void)
1165 {
1166 DH *dh=NULL;
1167
1168 if ((dh=DH_new()) == NULL) return(NULL);
1169 dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
1170 dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
1171 if ((dh->p == NULL) || (dh->g == NULL))
1172 return(NULL);
1173 return(dh);
1174 }
1175#endif
1176
1177#ifndef NO_RSA 1244#ifndef NO_RSA
1178static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength) 1245static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
1179 { 1246 {
@@ -1191,23 +1258,100 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
1191 } 1258 }
1192#endif 1259#endif
1193 1260
1194#ifndef NO_DSA 1261#ifndef NO_DH
1195static void MS_CALLBACK dsa_cb(int p, int n, void *arg) 1262/* These DH parameters have been generated as follows:
1263 * $ openssl dhparam -C -noout 512
1264 * $ openssl dhparam -C -noout 1024
1265 * $ openssl dhparam -C -noout -dsaparam 1024
1266 * (The third function has been renamed to avoid name conflicts.)
1267 */
1268DH *get_dh512()
1196 { 1269 {
1197 char c='*'; 1270 static unsigned char dh512_p[]={
1198 static int ok=0,num=0; 1271 0xCB,0xC8,0xE1,0x86,0xD0,0x1F,0x94,0x17,0xA6,0x99,0xF0,0xC6,
1272 0x1F,0x0D,0xAC,0xB6,0x25,0x3E,0x06,0x39,0xCA,0x72,0x04,0xB0,
1273 0x6E,0xDA,0xC0,0x61,0xE6,0x7A,0x77,0x25,0xE8,0x3B,0xB9,0x5F,
1274 0x9A,0xB6,0xB5,0xFE,0x99,0x0B,0xA1,0x93,0x4E,0x35,0x33,0xB8,
1275 0xE1,0xF1,0x13,0x4F,0x59,0x1A,0xD2,0x57,0xC0,0x26,0x21,0x33,
1276 0x02,0xC5,0xAE,0x23,
1277 };
1278 static unsigned char dh512_g[]={
1279 0x02,
1280 };
1281 DH *dh;
1199 1282
1200 if (p == 0) { c='.'; num++; }; 1283 if ((dh=DH_new()) == NULL) return(NULL);
1201 if (p == 1) c='+'; 1284 dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
1202 if (p == 2) { c='*'; ok++; } 1285 dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
1203 if (p == 3) c='\n'; 1286 if ((dh->p == NULL) || (dh->g == NULL))
1204 BIO_write(arg,&c,1); 1287 { DH_free(dh); return(NULL); }
1205 (void)BIO_flush(arg); 1288 return(dh);
1289 }
1206 1290
1207 if (!ok && (p == 0) && (num > 1)) 1291DH *get_dh1024()
1208 { 1292 {
1209 BIO_printf((BIO *)arg,"error in dsatest\n"); 1293 static unsigned char dh1024_p[]={
1210 exit(1); 1294 0xF8,0x81,0x89,0x7D,0x14,0x24,0xC5,0xD1,0xE6,0xF7,0xBF,0x3A,
1211 } 1295 0xE4,0x90,0xF4,0xFC,0x73,0xFB,0x34,0xB5,0xFA,0x4C,0x56,0xA2,
1296 0xEA,0xA7,0xE9,0xC0,0xC0,0xCE,0x89,0xE1,0xFA,0x63,0x3F,0xB0,
1297 0x6B,0x32,0x66,0xF1,0xD1,0x7B,0xB0,0x00,0x8F,0xCA,0x87,0xC2,
1298 0xAE,0x98,0x89,0x26,0x17,0xC2,0x05,0xD2,0xEC,0x08,0xD0,0x8C,
1299 0xFF,0x17,0x52,0x8C,0xC5,0x07,0x93,0x03,0xB1,0xF6,0x2F,0xB8,
1300 0x1C,0x52,0x47,0x27,0x1B,0xDB,0xD1,0x8D,0x9D,0x69,0x1D,0x52,
1301 0x4B,0x32,0x81,0xAA,0x7F,0x00,0xC8,0xDC,0xE6,0xD9,0xCC,0xC1,
1302 0x11,0x2D,0x37,0x34,0x6C,0xEA,0x02,0x97,0x4B,0x0E,0xBB,0xB1,
1303 0x71,0x33,0x09,0x15,0xFD,0xDD,0x23,0x87,0x07,0x5E,0x89,0xAB,
1304 0x6B,0x7C,0x5F,0xEC,0xA6,0x24,0xDC,0x53,
1305 };
1306 static unsigned char dh1024_g[]={
1307 0x02,
1308 };
1309 DH *dh;
1310
1311 if ((dh=DH_new()) == NULL) return(NULL);
1312 dh->p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),NULL);
1313 dh->g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),NULL);
1314 if ((dh->p == NULL) || (dh->g == NULL))
1315 { DH_free(dh); return(NULL); }
1316 return(dh);
1317 }
1318
1319DH *get_dh1024dsa()
1320 {
1321 static unsigned char dh1024_p[]={
1322 0xC8,0x00,0xF7,0x08,0x07,0x89,0x4D,0x90,0x53,0xF3,0xD5,0x00,
1323 0x21,0x1B,0xF7,0x31,0xA6,0xA2,0xDA,0x23,0x9A,0xC7,0x87,0x19,
1324 0x3B,0x47,0xB6,0x8C,0x04,0x6F,0xFF,0xC6,0x9B,0xB8,0x65,0xD2,
1325 0xC2,0x5F,0x31,0x83,0x4A,0xA7,0x5F,0x2F,0x88,0x38,0xB6,0x55,
1326 0xCF,0xD9,0x87,0x6D,0x6F,0x9F,0xDA,0xAC,0xA6,0x48,0xAF,0xFC,
1327 0x33,0x84,0x37,0x5B,0x82,0x4A,0x31,0x5D,0xE7,0xBD,0x52,0x97,
1328 0xA1,0x77,0xBF,0x10,0x9E,0x37,0xEA,0x64,0xFA,0xCA,0x28,0x8D,
1329 0x9D,0x3B,0xD2,0x6E,0x09,0x5C,0x68,0xC7,0x45,0x90,0xFD,0xBB,
1330 0x70,0xC9,0x3A,0xBB,0xDF,0xD4,0x21,0x0F,0xC4,0x6A,0x3C,0xF6,
1331 0x61,0xCF,0x3F,0xD6,0x13,0xF1,0x5F,0xBC,0xCF,0xBC,0x26,0x9E,
1332 0xBC,0x0B,0xBD,0xAB,0x5D,0xC9,0x54,0x39,
1333 };
1334 static unsigned char dh1024_g[]={
1335 0x3B,0x40,0x86,0xE7,0xF3,0x6C,0xDE,0x67,0x1C,0xCC,0x80,0x05,
1336 0x5A,0xDF,0xFE,0xBD,0x20,0x27,0x74,0x6C,0x24,0xC9,0x03,0xF3,
1337 0xE1,0x8D,0xC3,0x7D,0x98,0x27,0x40,0x08,0xB8,0x8C,0x6A,0xE9,
1338 0xBB,0x1A,0x3A,0xD6,0x86,0x83,0x5E,0x72,0x41,0xCE,0x85,0x3C,
1339 0xD2,0xB3,0xFC,0x13,0xCE,0x37,0x81,0x9E,0x4C,0x1C,0x7B,0x65,
1340 0xD3,0xE6,0xA6,0x00,0xF5,0x5A,0x95,0x43,0x5E,0x81,0xCF,0x60,
1341 0xA2,0x23,0xFC,0x36,0xA7,0x5D,0x7A,0x4C,0x06,0x91,0x6E,0xF6,
1342 0x57,0xEE,0x36,0xCB,0x06,0xEA,0xF5,0x3D,0x95,0x49,0xCB,0xA7,
1343 0xDD,0x81,0xDF,0x80,0x09,0x4A,0x97,0x4D,0xA8,0x22,0x72,0xA1,
1344 0x7F,0xC4,0x70,0x56,0x70,0xE8,0x20,0x10,0x18,0x8F,0x2E,0x60,
1345 0x07,0xE7,0x68,0x1A,0x82,0x5D,0x32,0xA2,
1346 };
1347 DH *dh;
1348
1349 if ((dh=DH_new()) == NULL) return(NULL);
1350 dh->p=BN_bin2bn(dh1024_p,sizeof(dh1024_p),NULL);
1351 dh->g=BN_bin2bn(dh1024_g,sizeof(dh1024_g),NULL);
1352 if ((dh->p == NULL) || (dh->g == NULL))
1353 { DH_free(dh); return(NULL); }
1354 dh->length = 160;
1355 return(dh);
1212 } 1356 }
1213#endif 1357#endif