Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: openssl/apps/openssl.c

Issue 9254031: Upgrade chrome's OpenSSL to same version Android ships with. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/openssl/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « openssl/apps/ocsp.c ('k') | openssl/apps/openssl.cnf » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* apps/openssl.c */ 1 /* apps/openssl.c */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ 128 #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
129 #include "progs.h" 129 #include "progs.h"
130 #include "s_apps.h" 130 #include "s_apps.h"
131 #include <openssl/err.h> 131 #include <openssl/err.h>
132 132
133 /* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the 133 /* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the
134 * base prototypes (we cast each variable inside the function to the required 134 * base prototypes (we cast each variable inside the function to the required
135 * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper 135 * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper
136 * functions. */ 136 * functions. */
137 137
138 /* static unsigned long MS_CALLBACK hash(FUNCTION *a); */ 138 static LHASH_OF(FUNCTION) *prog_init(void );
139 static unsigned long MS_CALLBACK hash(const void *a_void); 139 static int do_cmd(LHASH_OF(FUNCTION) *prog,int argc,char *argv[]);
140 /* static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b); */ 140 static void list_pkey(BIO *out);
141 static int MS_CALLBACK cmp(const void *a_void,const void *b_void); 141 static void list_cipher(BIO *out);
142 static LHASH *prog_init(void ); 142 static void list_md(BIO *out);
143 static int do_cmd(LHASH *prog,int argc,char *argv[]);
144 char *default_config_file=NULL; 143 char *default_config_file=NULL;
145 144
146 /* Make sure there is only one when MONOLITH is defined */ 145 /* Make sure there is only one when MONOLITH is defined */
147 #ifdef MONOLITH 146 #ifdef MONOLITH
148 CONF *config=NULL; 147 CONF *config=NULL;
149 BIO *bio_err=NULL; 148 BIO *bio_err=NULL;
150 int in_FIPS_mode=0;
151 #endif 149 #endif
152 150
153 151
154 static void lock_dbg_cb(int mode, int type, const char *file, int line) 152 static void lock_dbg_cb(int mode, int type, const char *file, int line)
155 { 153 {
156 static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */ 154 static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */
157 const char *errstr = NULL; 155 const char *errstr = NULL;
158 int rw; 156 int rw;
159 157
160 rw = mode & (CRYPTO_READ|CRYPTO_WRITE); 158 rw = mode & (CRYPTO_READ|CRYPTO_WRITE);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 205
208 err: 206 err:
209 if (errstr) 207 if (errstr)
210 { 208 {
211 /* we cannot use bio_err here */ 209 /* we cannot use bio_err here */
212 fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", 210 fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
213 errstr, mode, type, file, line); 211 errstr, mode, type, file, line);
214 } 212 }
215 } 213 }
216 214
215 #if defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64)
216 # define ARGV _Argv
217 #else
218 # define ARGV Argv
219 #endif
217 220
218 int main(int Argc, char *Argv[]) 221 int main(int Argc, char *ARGV[])
219 { 222 {
220 ARGS arg; 223 ARGS arg;
221 #define PROG_NAME_SIZE 39 224 #define PROG_NAME_SIZE 39
222 char pname[PROG_NAME_SIZE+1]; 225 char pname[PROG_NAME_SIZE+1];
223 FUNCTION f,*fp; 226 FUNCTION f,*fp;
224 MS_STATIC const char *prompt; 227 MS_STATIC const char *prompt;
225 MS_STATIC char buf[1024]; 228 MS_STATIC char buf[1024];
226 char *to_free=NULL; 229 char *to_free=NULL;
227 int n,i,ret=0; 230 int n,i,ret=0;
228 int argc; 231 int argc;
229 char **argv,*p; 232 char **argv,*p;
230 » LHASH *prog=NULL; 233 » LHASH_OF(FUNCTION) *prog=NULL;
231 long errline; 234 long errline;
232 235
236 #if defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64)
237 » /* 2011-03-22 SMS.
238 » * If we have 32-bit pointers everywhere, then we're safe, and
239 » * we bypass this mess, as on non-VMS systems. (See ARGV,
240 » * above.)
241 » * Problem 1: Compaq/HP C before V7.3 always used 32-bit
242 » * pointers for argv[].
243 » * Fix 1: For a 32-bit argv[], when we're using 64-bit pointers
244 » * everywhere else, we always allocate and use a 64-bit
245 » * duplicate of argv[].
246 » * Problem 2: Compaq/HP C V7.3 (Alpha, IA64) before ECO1 failed
247 » * to NULL-terminate a 64-bit argv[]. (As this was written, the
248 » * compiler ECO was available only on IA64.)
249 » * Fix 2: Unless advised not to (VMS_TRUST_ARGV), we test a
250 » * 64-bit argv[argc] for NULL, and, if necessary, use a
251 » * (properly) NULL-terminated (64-bit) duplicate of argv[].
252 » * The same code is used in either case to duplicate argv[].
253 » * Some of these decisions could be handled in preprocessing,
254 » * but the code tends to get even uglier, and the penalty for
255 » * deciding at compile- or run-time is tiny.
256 » */
257 » char **Argv = NULL;
258 » int free_Argv = 0;
259
260 » if ((sizeof( _Argv) < 8) /* 32-bit argv[]. */
261 # if !defined( VMS_TRUST_ARGV)
262 » || (_Argv[ Argc] != NULL) /* Untrusted argv[argc] not NULL. */
263 # endif
264 » » )
265 » » {
266 » » int i;
267 » » Argv = OPENSSL_malloc( (Argc+ 1)* sizeof( char *));
268 » » if (Argv == NULL)
269 » » » { ret = -1; goto end; }
270 » » for(i = 0; i < Argc; i++)
271 » » » Argv[i] = _Argv[i];
272 » » Argv[ Argc] = NULL; /* Certain NULL termination. */
273 » » free_Argv = 1;
274 » » }
275 » else
276 » » {
277 » » /* Use the known-good 32-bit argv[] (which needs the
278 » » * type cast to satisfy the compiler), or the trusted or
279 » » * tested-good 64-bit argv[] as-is. */
280 » » Argv = (char **)_Argv;
281 » » }
282 #endif /* defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64) */
283
233 arg.data=NULL; 284 arg.data=NULL;
234 arg.count=0; 285 arg.count=0;
235 286
236 in_FIPS_mode = 0;
237
238 if(getenv("OPENSSL_FIPS")) {
239 #ifdef OPENSSL_FIPS
240 if (!FIPS_mode_set(1)) {
241 ERR_load_crypto_strings();
242 ERR_print_errors(BIO_new_fp(stderr,BIO_NOCLOSE));
243 EXIT(1);
244 }
245 in_FIPS_mode = 1;
246 #else
247 fprintf(stderr, "FIPS mode not supported.\n");
248 EXIT(1);
249 #endif
250 }
251
252 if (bio_err == NULL) 287 if (bio_err == NULL)
253 if ((bio_err=BIO_new(BIO_s_file())) != NULL) 288 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
254 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); 289 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
255 290
256 if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compi led-in library defaults */ 291 if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compi led-in library defaults */
257 { 292 {
258 if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))) 293 if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))
259 { 294 {
260 CRYPTO_malloc_debug_init(); 295 CRYPTO_malloc_debug_init();
261 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL); 296 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
(...skipping 21 matching lines...) Expand all
283 p=getenv("SSLEAY_CONF"); 318 p=getenv("SSLEAY_CONF");
284 if (p == NULL) 319 if (p == NULL)
285 p=to_free=make_config_name(); 320 p=to_free=make_config_name();
286 321
287 default_config_file=p; 322 default_config_file=p;
288 323
289 config=NCONF_new(NULL); 324 config=NCONF_new(NULL);
290 i=NCONF_load(config,p,&errline); 325 i=NCONF_load(config,p,&errline);
291 if (i == 0) 326 if (i == 0)
292 { 327 {
293 » » NCONF_free(config); 328 » » if (ERR_GET_REASON(ERR_peek_last_error())
294 » » config = NULL; 329 » » == CONF_R_NO_SUCH_FILE)
295 » » ERR_clear_error(); 330 » » » {
331 #if 0 /* ANDROID */
332 » » » BIO_printf(bio_err,
333 » » » » "WARNING: can't open config file: %s\n",p);
334 #endif
335 » » » ERR_clear_error();
336 » » » NCONF_free(config);
337 » » » config = NULL;
338 » » » }
339 » » else
340 » » » {
341 » » » ERR_print_errors(bio_err);
342 » » » NCONF_free(config);
343 » » » exit(1);
344 » » » }
296 } 345 }
297 346
298 prog=prog_init(); 347 prog=prog_init();
299 348
300 /* first check the program name */ 349 /* first check the program name */
301 program_name(Argv[0],pname,sizeof pname); 350 program_name(Argv[0],pname,sizeof pname);
302 351
303 f.name=pname; 352 f.name=pname;
304 » fp=(FUNCTION *)lh_retrieve(prog,&f); 353 » fp=lh_FUNCTION_retrieve(prog,&f);
305 if (fp != NULL) 354 if (fp != NULL)
306 { 355 {
307 Argv[0]=pname; 356 Argv[0]=pname;
308 ret=fp->func(Argc,Argv); 357 ret=fp->func(Argc,Argv);
309 goto end; 358 goto end;
310 } 359 }
311 360
312 /* ok, now check that there are not arguments, if there are, 361 /* ok, now check that there are not arguments, if there are,
313 * run with them, shifting the ssleay off the front */ 362 * run with them, shifting the ssleay off the front */
314 if (Argc != 1) 363 if (Argc != 1)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 BIO_printf(bio_err,"bad exit\n"); 410 BIO_printf(bio_err,"bad exit\n");
362 ret=1; 411 ret=1;
363 end: 412 end:
364 if (to_free) 413 if (to_free)
365 OPENSSL_free(to_free); 414 OPENSSL_free(to_free);
366 if (config != NULL) 415 if (config != NULL)
367 { 416 {
368 NCONF_free(config); 417 NCONF_free(config);
369 config=NULL; 418 config=NULL;
370 } 419 }
371 » if (prog != NULL) lh_free(prog); 420 » if (prog != NULL) lh_FUNCTION_free(prog);
372 if (arg.data != NULL) OPENSSL_free(arg.data); 421 if (arg.data != NULL) OPENSSL_free(arg.data);
373 422
374 apps_shutdown(); 423 apps_shutdown();
375 424
376 CRYPTO_mem_leaks(bio_err); 425 CRYPTO_mem_leaks(bio_err);
377 if (bio_err != NULL) 426 if (bio_err != NULL)
378 { 427 {
379 BIO_free(bio_err); 428 BIO_free(bio_err);
380 bio_err=NULL; 429 bio_err=NULL;
381 } 430 }
431 #if defined( OPENSSL_SYS_VMS) && (__INITIAL_POINTER_SIZE == 64)
432 /* Free any duplicate Argv[] storage. */
433 if (free_Argv)
434 {
435 OPENSSL_free(Argv);
436 }
437 #endif
382 OPENSSL_EXIT(ret); 438 OPENSSL_EXIT(ret);
383 } 439 }
384 440
385 #define LIST_STANDARD_COMMANDS "list-standard-commands" 441 #define LIST_STANDARD_COMMANDS "list-standard-commands"
386 #define LIST_MESSAGE_DIGEST_COMMANDS "list-message-digest-commands" 442 #define LIST_MESSAGE_DIGEST_COMMANDS "list-message-digest-commands"
443 #define LIST_MESSAGE_DIGEST_ALGORITHMS "list-message-digest-algorithms"
387 #define LIST_CIPHER_COMMANDS "list-cipher-commands" 444 #define LIST_CIPHER_COMMANDS "list-cipher-commands"
445 #define LIST_CIPHER_ALGORITHMS "list-cipher-algorithms"
446 #define LIST_PUBLIC_KEY_ALGORITHMS "list-public-key-algorithms"
388 447
389 static int do_cmd(LHASH *prog, int argc, char *argv[]) 448
449 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
390 { 450 {
391 FUNCTION f,*fp; 451 FUNCTION f,*fp;
392 int i,ret=1,tp,nl; 452 int i,ret=1,tp,nl;
393 453
394 if ((argc <= 0) || (argv[0] == NULL)) 454 if ((argc <= 0) || (argv[0] == NULL))
395 { ret=0; goto end; } 455 { ret=0; goto end; }
396 f.name=argv[0]; 456 f.name=argv[0];
397 » fp=(FUNCTION *)lh_retrieve(prog,&f); 457 » fp=lh_FUNCTION_retrieve(prog,&f);
458 » if (fp == NULL)
459 » » {
460 » » if (EVP_get_digestbyname(argv[0]))
461 » » » {
462 » » » f.type = FUNC_TYPE_MD;
463 » » » f.func = dgst_main;
464 » » » fp = &f;
465 » » » }
466 » » else if (EVP_get_cipherbyname(argv[0]))
467 » » » {
468 » » » f.type = FUNC_TYPE_CIPHER;
469 » » » f.func = enc_main;
470 » » » fp = &f;
471 » » » }
472 » » }
398 if (fp != NULL) 473 if (fp != NULL)
399 { 474 {
400 ret=fp->func(argc,argv); 475 ret=fp->func(argc,argv);
401 } 476 }
402 else if ((strncmp(argv[0],"no-",3)) == 0) 477 else if ((strncmp(argv[0],"no-",3)) == 0)
403 { 478 {
404 BIO *bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE); 479 BIO *bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
405 #ifdef OPENSSL_SYS_VMS 480 #ifdef OPENSSL_SYS_VMS
406 { 481 {
407 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 482 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
408 bio_stdout = BIO_push(tmpbio, bio_stdout); 483 bio_stdout = BIO_push(tmpbio, bio_stdout);
409 } 484 }
410 #endif 485 #endif
411 f.name=argv[0]+3; 486 f.name=argv[0]+3;
412 » » ret = (lh_retrieve(prog,&f) != NULL); 487 » » ret = (lh_FUNCTION_retrieve(prog,&f) != NULL);
413 if (!ret) 488 if (!ret)
414 BIO_printf(bio_stdout, "%s\n", argv[0]); 489 BIO_printf(bio_stdout, "%s\n", argv[0]);
415 else 490 else
416 BIO_printf(bio_stdout, "%s\n", argv[0]+3); 491 BIO_printf(bio_stdout, "%s\n", argv[0]+3);
417 BIO_free_all(bio_stdout); 492 BIO_free_all(bio_stdout);
418 goto end; 493 goto end;
419 } 494 }
420 else if ((strcmp(argv[0],"quit") == 0) || 495 else if ((strcmp(argv[0],"quit") == 0) ||
421 (strcmp(argv[0],"q") == 0) || 496 (strcmp(argv[0],"q") == 0) ||
422 (strcmp(argv[0],"exit") == 0) || 497 (strcmp(argv[0],"exit") == 0) ||
423 (strcmp(argv[0],"bye") == 0)) 498 (strcmp(argv[0],"bye") == 0))
424 { 499 {
425 ret= -1; 500 ret= -1;
426 goto end; 501 goto end;
427 } 502 }
428 else if ((strcmp(argv[0],LIST_STANDARD_COMMANDS) == 0) || 503 else if ((strcmp(argv[0],LIST_STANDARD_COMMANDS) == 0) ||
429 (strcmp(argv[0],LIST_MESSAGE_DIGEST_COMMANDS) == 0) || 504 (strcmp(argv[0],LIST_MESSAGE_DIGEST_COMMANDS) == 0) ||
430 » » (strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0)) 505 » » (strcmp(argv[0],LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) ||
506 » » (strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0) ||
507 » » (strcmp(argv[0],LIST_CIPHER_ALGORITHMS) == 0) ||
508 » » (strcmp(argv[0],LIST_PUBLIC_KEY_ALGORITHMS) == 0))
431 { 509 {
432 int list_type; 510 int list_type;
433 BIO *bio_stdout; 511 BIO *bio_stdout;
434 512
435 if (strcmp(argv[0],LIST_STANDARD_COMMANDS) == 0) 513 if (strcmp(argv[0],LIST_STANDARD_COMMANDS) == 0)
436 list_type = FUNC_TYPE_GENERAL; 514 list_type = FUNC_TYPE_GENERAL;
437 else if (strcmp(argv[0],LIST_MESSAGE_DIGEST_COMMANDS) == 0) 515 else if (strcmp(argv[0],LIST_MESSAGE_DIGEST_COMMANDS) == 0)
438 list_type = FUNC_TYPE_MD; 516 list_type = FUNC_TYPE_MD;
517 else if (strcmp(argv[0],LIST_MESSAGE_DIGEST_ALGORITHMS) == 0)
518 list_type = FUNC_TYPE_MD_ALG;
519 else if (strcmp(argv[0],LIST_PUBLIC_KEY_ALGORITHMS) == 0)
520 list_type = FUNC_TYPE_PKEY;
521 else if (strcmp(argv[0],LIST_CIPHER_ALGORITHMS) == 0)
522 list_type = FUNC_TYPE_CIPHER_ALG;
439 else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */ 523 else /* strcmp(argv[0],LIST_CIPHER_COMMANDS) == 0 */
440 list_type = FUNC_TYPE_CIPHER; 524 list_type = FUNC_TYPE_CIPHER;
441 bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE); 525 bio_stdout = BIO_new_fp(stdout,BIO_NOCLOSE);
442 #ifdef OPENSSL_SYS_VMS 526 #ifdef OPENSSL_SYS_VMS
443 { 527 {
444 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); 528 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
445 bio_stdout = BIO_push(tmpbio, bio_stdout); 529 bio_stdout = BIO_push(tmpbio, bio_stdout);
446 } 530 }
447 #endif 531 #endif
448 » » 532
449 » » for (fp=functions; fp->name != NULL; fp++) 533 » » if (!load_config(bio_err, NULL))
450 » » » if (fp->type == list_type) 534 » » » goto end;
451 » » » » BIO_printf(bio_stdout, "%s\n", fp->name); 535
536 » » if (list_type == FUNC_TYPE_PKEY)
537 » » » list_pkey(bio_stdout);»
538 » » if (list_type == FUNC_TYPE_MD_ALG)
539 » » » list_md(bio_stdout);»
540 » » if (list_type == FUNC_TYPE_CIPHER_ALG)
541 » » » list_cipher(bio_stdout);»
542 » » else
543 » » » {
544 » » » for (fp=functions; fp->name != NULL; fp++)
545 » » » » if (fp->type == list_type)
546 » » » » » BIO_printf(bio_stdout, "%s\n",
547 » » » » » » » » fp->name);
548 » » » }
452 BIO_free_all(bio_stdout); 549 BIO_free_all(bio_stdout);
453 ret=0; 550 ret=0;
454 goto end; 551 goto end;
455 } 552 }
456 else 553 else
457 { 554 {
458 BIO_printf(bio_err,"openssl:Error: '%s' is an invalid command.\n ", 555 BIO_printf(bio_err,"openssl:Error: '%s' is an invalid command.\n ",
459 argv[0]); 556 argv[0]);
460 BIO_printf(bio_err, "\nStandard commands"); 557 BIO_printf(bio_err, "\nStandard commands");
461 i=0; 558 i=0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 static int SortFnByName(const void *_f1,const void *_f2) 601 static int SortFnByName(const void *_f1,const void *_f2)
505 { 602 {
506 const FUNCTION *f1=_f1; 603 const FUNCTION *f1=_f1;
507 const FUNCTION *f2=_f2; 604 const FUNCTION *f2=_f2;
508 605
509 if(f1->type != f2->type) 606 if(f1->type != f2->type)
510 return f1->type-f2->type; 607 return f1->type-f2->type;
511 return strcmp(f1->name,f2->name); 608 return strcmp(f1->name,f2->name);
512 } 609 }
513 610
514 static LHASH *prog_init(void) 611 static void list_pkey(BIO *out)
515 { 612 {
516 » LHASH *ret; 613 » int i;
614 » for (i = 0; i < EVP_PKEY_asn1_get_count(); i++)
615 » » {
616 » » const EVP_PKEY_ASN1_METHOD *ameth;
617 » » int pkey_id, pkey_base_id, pkey_flags;
618 » » const char *pinfo, *pem_str;
619 » » ameth = EVP_PKEY_asn1_get0(i);
620 » » EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
621 » » » » » » &pinfo, &pem_str, ameth);
622 » » if (pkey_flags & ASN1_PKEY_ALIAS)
623 » » » {
624 » » » BIO_printf(out, "Name: %s\n",
625 » » » » » OBJ_nid2ln(pkey_id));
626 » » » BIO_printf(out, "\tType: Alias to %s\n",
627 » » » » » OBJ_nid2ln(pkey_base_id));
628 » » » }
629 » » else
630 » » » {
631 » » » BIO_printf(out, "Name: %s\n", pinfo);
632 » » » BIO_printf(out, "\tType: %s Algorithm\n",
633 » » » » pkey_flags & ASN1_PKEY_DYNAMIC ?
634 » » » » » "External" : "Builtin");
635 » » » BIO_printf(out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
636 » » » if (pem_str == NULL)
637 » » » » pem_str = "(none)";
638 » » » BIO_printf(out, "\tPEM string: %s\n", pem_str);
639 » » » }
640 » » » » »
641 » » }
642 » }
643
644 static void list_cipher_fn(const EVP_CIPHER *c,
645 » » » const char *from, const char *to, void *arg)
646 » {
647 » if (c)
648 » » BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
649 » else
650 » » {
651 » » if (!from)
652 » » » from = "<undefined>";
653 » » if (!to)
654 » » » to = "<undefined>";
655 » » BIO_printf(arg, "%s => %s\n", from, to);
656 » » }
657 » }
658
659 static void list_cipher(BIO *out)
660 » {
661 » EVP_CIPHER_do_all_sorted(list_cipher_fn, out);
662 » }
663
664 static void list_md_fn(const EVP_MD *m,
665 » » » const char *from, const char *to, void *arg)
666 » {
667 » if (m)
668 » » BIO_printf(arg, "%s\n", EVP_MD_name(m));
669 » else
670 » » {
671 » » if (!from)
672 » » » from = "<undefined>";
673 » » if (!to)
674 » » » to = "<undefined>";
675 » » BIO_printf(arg, "%s => %s\n", from, to);
676 » » }
677 » }
678
679 static void list_md(BIO *out)
680 » {
681 » EVP_MD_do_all_sorted(list_md_fn, out);
682 » }
683
684 static int MS_CALLBACK function_cmp(const FUNCTION *a, const FUNCTION *b)
685 » {
686 » return strncmp(a->name,b->name,8);
687 » }
688 static IMPLEMENT_LHASH_COMP_FN(function, FUNCTION)
689
690 static unsigned long MS_CALLBACK function_hash(const FUNCTION *a)
691 » {
692 » return lh_strhash(a->name);
693 » }»
694 static IMPLEMENT_LHASH_HASH_FN(function, FUNCTION)
695
696 static LHASH_OF(FUNCTION) *prog_init(void)
697 » {
698 » LHASH_OF(FUNCTION) *ret;
517 FUNCTION *f; 699 FUNCTION *f;
518 size_t i; 700 size_t i;
519 701
520 /* Purely so it looks nice when the user hits ? */ 702 /* Purely so it looks nice when the user hits ? */
521 for(i=0,f=functions ; f->name != NULL ; ++f,++i) 703 for(i=0,f=functions ; f->name != NULL ; ++f,++i)
522 ; 704 ;
523 qsort(functions,i,sizeof *functions,SortFnByName); 705 qsort(functions,i,sizeof *functions,SortFnByName);
524 706
525 » if ((ret=lh_new(hash, cmp)) == NULL) 707 » if ((ret=lh_FUNCTION_new()) == NULL)
526 return(NULL); 708 return(NULL);
527 709
528 for (f=functions; f->name != NULL; f++) 710 for (f=functions; f->name != NULL; f++)
529 » » lh_insert(ret,f); 711 » » (void)lh_FUNCTION_insert(ret,f);
530 return(ret); 712 return(ret);
531 } 713 }
532 714
533 /* static int MS_CALLBACK cmp(FUNCTION *a, FUNCTION *b) */
534 static int MS_CALLBACK cmp(const void *a_void, const void *b_void)
535 {
536 return(strncmp(((const FUNCTION *)a_void)->name,
537 ((const FUNCTION *)b_void)->name,8));
538 }
539
540 /* static unsigned long MS_CALLBACK hash(FUNCTION *a) */
541 static unsigned long MS_CALLBACK hash(const void *a_void)
542 {
543 return(lh_strhash(((const FUNCTION *)a_void)->name));
544 }
OLDNEW
« no previous file with comments | « openssl/apps/ocsp.c ('k') | openssl/apps/openssl.cnf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698