Mercurial > dropbear
comparison svr-runopts.c @ 873:17b15683648d
Exit if we don't have keys and -R wasn't specified
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 03 Dec 2013 20:59:03 +0800 |
parents | c19acba28590 |
children | 5bfce5dcd461 |
comparison
equal
deleted
inserted
replaced
872:a287954a16d6 | 873:17b15683648d |
---|---|
450 } | 450 } |
451 | 451 |
452 void load_all_hostkeys() { | 452 void load_all_hostkeys() { |
453 int i; | 453 int i; |
454 int disable_unset_keys = 1; | 454 int disable_unset_keys = 1; |
455 int any_keys = 0; | |
455 | 456 |
456 svr_opts.hostkey = new_sign_key(); | 457 svr_opts.hostkey = new_sign_key(); |
457 | 458 |
458 for (i = 0; i < svr_opts.num_hostkey_files; i++) { | 459 for (i = 0; i < svr_opts.num_hostkey_files; i++) { |
459 char *hostkey_file = svr_opts.hostkey_files[i]; | 460 char *hostkey_file = svr_opts.hostkey_files[i]; |
482 | 483 |
483 #ifdef DROPBEAR_RSA | 484 #ifdef DROPBEAR_RSA |
484 if (disable_unset_keys && !svr_opts.hostkey->rsakey) { | 485 if (disable_unset_keys && !svr_opts.hostkey->rsakey) { |
485 disablekey(DROPBEAR_SIGNKEY_RSA); | 486 disablekey(DROPBEAR_SIGNKEY_RSA); |
486 } | 487 } |
488 else | |
489 { | |
490 any_keys = 1; | |
491 } | |
487 #endif | 492 #endif |
488 | 493 |
489 #ifdef DROPBEAR_DSS | 494 #ifdef DROPBEAR_DSS |
490 if (disable_unset_keys && !svr_opts.hostkey->dsskey) { | 495 if (disable_unset_keys && !svr_opts.hostkey->dsskey) { |
491 disablekey(DROPBEAR_SIGNKEY_RSA); | 496 disablekey(DROPBEAR_SIGNKEY_RSA); |
497 } | |
498 else | |
499 { | |
500 any_keys = 1; | |
492 } | 501 } |
493 #endif | 502 #endif |
494 | 503 |
495 | 504 |
496 #ifdef DROPBEAR_ECDSA | 505 #ifdef DROPBEAR_ECDSA |
497 #ifdef DROPBEAR_ECC_256 | 506 #ifdef DROPBEAR_ECC_256 |
498 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 256) | 507 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 256) |
499 && !svr_opts.hostkey->ecckey256) { | 508 && !svr_opts.hostkey->ecckey256) { |
500 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP256); | 509 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP256); |
501 } | 510 } |
511 else | |
512 { | |
513 any_keys = 1; | |
514 } | |
502 #endif | 515 #endif |
503 | 516 |
504 #ifdef DROPBEAR_ECC_384 | 517 #ifdef DROPBEAR_ECC_384 |
505 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 384) | 518 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 384) |
506 && !svr_opts.hostkey->ecckey384) { | 519 && !svr_opts.hostkey->ecckey384) { |
507 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP384); | 520 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP384); |
508 } | 521 } |
522 else | |
523 { | |
524 any_keys = 1; | |
525 } | |
509 #endif | 526 #endif |
510 | 527 |
511 #ifdef DROPBEAR_ECC_521 | 528 #ifdef DROPBEAR_ECC_521 |
512 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 521) | 529 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 521) |
513 && !svr_opts.hostkey->ecckey521) { | 530 && !svr_opts.hostkey->ecckey521) { |
514 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP521); | 531 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP521); |
515 } | 532 } |
533 else | |
534 { | |
535 any_keys = 1; | |
536 } | |
516 #endif | 537 #endif |
517 #endif /* DROPBEAR_ECDSA */ | 538 #endif /* DROPBEAR_ECDSA */ |
518 | 539 |
519 } | 540 if (!any_keys) |
541 { | |
542 dropbear_exit("No hostkeys available"); | |
543 } | |
544 | |
545 } |