summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'key.c')
-rw-r--r--key.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/key.c b/key.c
index 54318cbbf..323e6ff84 100644
--- a/key.c
+++ b/key.c
@@ -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"
35RCSID("$OpenBSD: key.c,v 1.54 2003/07/09 13:58:19 avsm Exp $"); 35RCSID("$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
146int 147int
147key_equal(Key *a, Key *b) 148key_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
172u_char* 173u_char*
173key_fingerprint_raw(Key *k, enum fp_type dgst_type, u_int *dgst_raw_length) 174key_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
294char * 296char *
295key_fingerprint(Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep) 297key_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
492int 494int
493key_write(Key *key, FILE *f) 495key_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
525char * 527const char *
526key_type(Key *k) 528key_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
542char * 544const char *
543key_ssh_name(Key *k) 545key_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
556u_int 558u_int
557key_size(Key *k) 559key_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
613Key * 615Key *
614key_from_private(Key *k) 616key_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
678Key * 680Key *
679key_from_blob(u_char *blob, u_int blen) 681key_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
728int 730int
729key_to_blob(Key *key, u_char **blobp, u_int *lenp) 731key_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
769int 771int
770key_sign( 772key_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 */
793int 795int
794key_verify( 796key_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 */
817Key * 819Key *
818key_demote(Key *k) 820key_demote(const Key *k)
819{ 821{
820 Key *pk; 822 Key *pk;
821 823