diff options
Diffstat (limited to 'key.c')
-rw-r--r-- | key.c | 40 |
1 files changed, 21 insertions, 19 deletions
@@ -32,7 +32,7 @@ | |||
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ | 33 | */ |
34 | #include "includes.h" | 34 | #include "includes.h" |
35 | RCSID("$OpenBSD: key.c,v 1.54 2003/07/09 13:58:19 avsm Exp $"); | 35 | RCSID("$OpenBSD: key.c,v 1.55 2003/11/10 16:23:41 jakob Exp $"); |
36 | 36 | ||
37 | #include <openssl/evp.h> | 37 | #include <openssl/evp.h> |
38 | 38 | ||
@@ -143,8 +143,9 @@ key_free(Key *k) | |||
143 | } | 143 | } |
144 | xfree(k); | 144 | xfree(k); |
145 | } | 145 | } |
146 | |||
146 | int | 147 | int |
147 | key_equal(Key *a, Key *b) | 148 | key_equal(const Key *a, const Key *b) |
148 | { | 149 | { |
149 | if (a == NULL || b == NULL || a->type != b->type) | 150 | if (a == NULL || b == NULL || a->type != b->type) |
150 | return 0; | 151 | return 0; |
@@ -170,7 +171,8 @@ key_equal(Key *a, Key *b) | |||
170 | } | 171 | } |
171 | 172 | ||
172 | u_char* | 173 | u_char* |
173 | key_fingerprint_raw(Key *k, enum fp_type dgst_type, u_int *dgst_raw_length) | 174 | key_fingerprint_raw(const Key *k, enum fp_type dgst_type, |
175 | u_int *dgst_raw_length) | ||
174 | { | 176 | { |
175 | const EVP_MD *md = NULL; | 177 | const EVP_MD *md = NULL; |
176 | EVP_MD_CTX ctx; | 178 | EVP_MD_CTX ctx; |
@@ -292,7 +294,7 @@ key_fingerprint_bubblebabble(u_char *dgst_raw, u_int dgst_raw_len) | |||
292 | } | 294 | } |
293 | 295 | ||
294 | char * | 296 | char * |
295 | key_fingerprint(Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep) | 297 | key_fingerprint(const Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep) |
296 | { | 298 | { |
297 | char *retval = NULL; | 299 | char *retval = NULL; |
298 | u_char *dgst_raw; | 300 | u_char *dgst_raw; |
@@ -490,7 +492,7 @@ key_read(Key *ret, char **cpp) | |||
490 | } | 492 | } |
491 | 493 | ||
492 | int | 494 | int |
493 | key_write(Key *key, FILE *f) | 495 | key_write(const Key *key, FILE *f) |
494 | { | 496 | { |
495 | int n, success = 0; | 497 | int n, success = 0; |
496 | u_int len, bits = 0; | 498 | u_int len, bits = 0; |
@@ -522,8 +524,8 @@ key_write(Key *key, FILE *f) | |||
522 | return success; | 524 | return success; |
523 | } | 525 | } |
524 | 526 | ||
525 | char * | 527 | const char * |
526 | key_type(Key *k) | 528 | key_type(const Key *k) |
527 | { | 529 | { |
528 | switch (k->type) { | 530 | switch (k->type) { |
529 | case KEY_RSA1: | 531 | case KEY_RSA1: |
@@ -539,8 +541,8 @@ key_type(Key *k) | |||
539 | return "unknown"; | 541 | return "unknown"; |
540 | } | 542 | } |
541 | 543 | ||
542 | char * | 544 | const char * |
543 | key_ssh_name(Key *k) | 545 | key_ssh_name(const Key *k) |
544 | { | 546 | { |
545 | switch (k->type) { | 547 | switch (k->type) { |
546 | case KEY_RSA: | 548 | case KEY_RSA: |
@@ -554,7 +556,7 @@ key_ssh_name(Key *k) | |||
554 | } | 556 | } |
555 | 557 | ||
556 | u_int | 558 | u_int |
557 | key_size(Key *k) | 559 | key_size(const Key *k) |
558 | { | 560 | { |
559 | switch (k->type) { | 561 | switch (k->type) { |
560 | case KEY_RSA1: | 562 | case KEY_RSA1: |
@@ -611,7 +613,7 @@ key_generate(int type, u_int bits) | |||
611 | } | 613 | } |
612 | 614 | ||
613 | Key * | 615 | Key * |
614 | key_from_private(Key *k) | 616 | key_from_private(const Key *k) |
615 | { | 617 | { |
616 | Key *n = NULL; | 618 | Key *n = NULL; |
617 | switch (k->type) { | 619 | switch (k->type) { |
@@ -676,7 +678,7 @@ key_names_valid2(const char *names) | |||
676 | } | 678 | } |
677 | 679 | ||
678 | Key * | 680 | Key * |
679 | key_from_blob(u_char *blob, u_int blen) | 681 | key_from_blob(const u_char *blob, u_int blen) |
680 | { | 682 | { |
681 | Buffer b; | 683 | Buffer b; |
682 | char *ktype; | 684 | char *ktype; |
@@ -726,7 +728,7 @@ key_from_blob(u_char *blob, u_int blen) | |||
726 | } | 728 | } |
727 | 729 | ||
728 | int | 730 | int |
729 | key_to_blob(Key *key, u_char **blobp, u_int *lenp) | 731 | key_to_blob(const Key *key, u_char **blobp, u_int *lenp) |
730 | { | 732 | { |
731 | Buffer b; | 733 | Buffer b; |
732 | int len; | 734 | int len; |
@@ -768,9 +770,9 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp) | |||
768 | 770 | ||
769 | int | 771 | int |
770 | key_sign( | 772 | key_sign( |
771 | Key *key, | 773 | const Key *key, |
772 | u_char **sigp, u_int *lenp, | 774 | u_char **sigp, u_int *lenp, |
773 | u_char *data, u_int datalen) | 775 | const u_char *data, u_int datalen) |
774 | { | 776 | { |
775 | switch (key->type) { | 777 | switch (key->type) { |
776 | case KEY_DSA: | 778 | case KEY_DSA: |
@@ -792,9 +794,9 @@ key_sign( | |||
792 | */ | 794 | */ |
793 | int | 795 | int |
794 | key_verify( | 796 | key_verify( |
795 | Key *key, | 797 | const Key *key, |
796 | u_char *signature, u_int signaturelen, | 798 | const u_char *signature, u_int signaturelen, |
797 | u_char *data, u_int datalen) | 799 | const u_char *data, u_int datalen) |
798 | { | 800 | { |
799 | if (signaturelen == 0) | 801 | if (signaturelen == 0) |
800 | return -1; | 802 | return -1; |
@@ -815,7 +817,7 @@ key_verify( | |||
815 | 817 | ||
816 | /* Converts a private to a public key */ | 818 | /* Converts a private to a public key */ |
817 | Key * | 819 | Key * |
818 | key_demote(Key *k) | 820 | key_demote(const Key *k) |
819 | { | 821 | { |
820 | Key *pk; | 822 | Key *pk; |
821 | 823 | ||