summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'key.c')
-rw-r--r--key.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/key.c b/key.c
index 283aea99e..96619fe60 100644
--- a/key.c
+++ b/key.c
@@ -156,14 +156,12 @@ key_equal(const Key *a, const Key *b)
156 return a->rsa != NULL && b->rsa != NULL && 156 return a->rsa != NULL && b->rsa != NULL &&
157 BN_cmp(a->rsa->e, b->rsa->e) == 0 && 157 BN_cmp(a->rsa->e, b->rsa->e) == 0 &&
158 BN_cmp(a->rsa->n, b->rsa->n) == 0; 158 BN_cmp(a->rsa->n, b->rsa->n) == 0;
159 break;
160 case KEY_DSA: 159 case KEY_DSA:
161 return a->dsa != NULL && b->dsa != NULL && 160 return a->dsa != NULL && b->dsa != NULL &&
162 BN_cmp(a->dsa->p, b->dsa->p) == 0 && 161 BN_cmp(a->dsa->p, b->dsa->p) == 0 &&
163 BN_cmp(a->dsa->q, b->dsa->q) == 0 && 162 BN_cmp(a->dsa->q, b->dsa->q) == 0 &&
164 BN_cmp(a->dsa->g, b->dsa->g) == 0 && 163 BN_cmp(a->dsa->g, b->dsa->g) == 0 &&
165 BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0; 164 BN_cmp(a->dsa->pub_key, b->dsa->pub_key) == 0;
166 break;
167 default: 165 default:
168 fatal("key_equal: bad key type %d", a->type); 166 fatal("key_equal: bad key type %d", a->type);
169 break; 167 break;
@@ -210,7 +208,6 @@ key_fingerprint_raw(const Key *k, enum fp_type dgst_type,
210 break; 208 break;
211 case KEY_UNSPEC: 209 case KEY_UNSPEC:
212 return retval; 210 return retval;
213 break;
214 default: 211 default:
215 fatal("key_fingerprint_raw: bad key type %d", k->type); 212 fatal("key_fingerprint_raw: bad key type %d", k->type);
216 break; 213 break;
@@ -531,13 +528,10 @@ key_type(const Key *k)
531 switch (k->type) { 528 switch (k->type) {
532 case KEY_RSA1: 529 case KEY_RSA1:
533 return "RSA1"; 530 return "RSA1";
534 break;
535 case KEY_RSA: 531 case KEY_RSA:
536 return "RSA"; 532 return "RSA";
537 break;
538 case KEY_DSA: 533 case KEY_DSA:
539 return "DSA"; 534 return "DSA";
540 break;
541 } 535 }
542 return "unknown"; 536 return "unknown";
543} 537}
@@ -548,10 +542,8 @@ key_ssh_name(const Key *k)
548 switch (k->type) { 542 switch (k->type) {
549 case KEY_RSA: 543 case KEY_RSA:
550 return "ssh-rsa"; 544 return "ssh-rsa";
551 break;
552 case KEY_DSA: 545 case KEY_DSA:
553 return "ssh-dss"; 546 return "ssh-dss";
554 break;
555 } 547 }
556 return "ssh-unknown"; 548 return "ssh-unknown";
557} 549}
@@ -563,10 +555,8 @@ key_size(const Key *k)
563 case KEY_RSA1: 555 case KEY_RSA1:
564 case KEY_RSA: 556 case KEY_RSA:
565 return BN_num_bits(k->rsa->n); 557 return BN_num_bits(k->rsa->n);
566 break;
567 case KEY_DSA: 558 case KEY_DSA:
568 return BN_num_bits(k->dsa->p); 559 return BN_num_bits(k->dsa->p);
569 break;
570 } 560 }
571 return 0; 561 return 0;
572} 562}
@@ -575,6 +565,7 @@ static RSA *
575rsa_generate_private_key(u_int bits) 565rsa_generate_private_key(u_int bits)
576{ 566{
577 RSA *private; 567 RSA *private;
568
578 private = RSA_generate_key(bits, 35, NULL, NULL); 569 private = RSA_generate_key(bits, 35, NULL, NULL);
579 if (private == NULL) 570 if (private == NULL)
580 fatal("rsa_generate_private_key: key generation failed."); 571 fatal("rsa_generate_private_key: key generation failed.");
@@ -585,6 +576,7 @@ static DSA*
585dsa_generate_private_key(u_int bits) 576dsa_generate_private_key(u_int bits)
586{ 577{
587 DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); 578 DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL);
579
588 if (private == NULL) 580 if (private == NULL)
589 fatal("dsa_generate_private_key: DSA_generate_parameters failed"); 581 fatal("dsa_generate_private_key: DSA_generate_parameters failed");
590 if (!DSA_generate_key(private)) 582 if (!DSA_generate_key(private))
@@ -794,14 +786,11 @@ key_sign(
794 switch (key->type) { 786 switch (key->type) {
795 case KEY_DSA: 787 case KEY_DSA:
796 return ssh_dss_sign(key, sigp, lenp, data, datalen); 788 return ssh_dss_sign(key, sigp, lenp, data, datalen);
797 break;
798 case KEY_RSA: 789 case KEY_RSA:
799 return ssh_rsa_sign(key, sigp, lenp, data, datalen); 790 return ssh_rsa_sign(key, sigp, lenp, data, datalen);
800 break;
801 default: 791 default:
802 error("key_sign: invalid key type %d", key->type); 792 error("key_sign: invalid key type %d", key->type);
803 return -1; 793 return -1;
804 break;
805 } 794 }
806} 795}
807 796
@@ -821,14 +810,11 @@ key_verify(
821 switch (key->type) { 810 switch (key->type) {
822 case KEY_DSA: 811 case KEY_DSA:
823 return ssh_dss_verify(key, signature, signaturelen, data, datalen); 812 return ssh_dss_verify(key, signature, signaturelen, data, datalen);
824 break;
825 case KEY_RSA: 813 case KEY_RSA:
826 return ssh_rsa_verify(key, signature, signaturelen, data, datalen); 814 return ssh_rsa_verify(key, signature, signaturelen, data, datalen);
827 break;
828 default: 815 default:
829 error("key_verify: invalid key type %d", key->type); 816 error("key_verify: invalid key type %d", key->type);
830 return -1; 817 return -1;
831 break;
832 } 818 }
833} 819}
834 820