=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/key.c,v retrieving revision 1.43.2.3 retrieving revision 1.44 diff -u -r1.43.2.3 -r1.44 --- src/usr.bin/ssh/Attic/key.c 2003/04/03 22:35:17 1.43.2.3 +++ src/usr.bin/ssh/Attic/key.c 2002/05/31 13:16:48 1.44 @@ -32,13 +32,15 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: key.c,v 1.43.2.3 2003/04/03 22:35:17 miod Exp $"); +RCSID("$OpenBSD: key.c,v 1.44 2002/05/31 13:16:48 markus Exp $"); #include #include "xmalloc.h" #include "key.h" #include "rsa.h" +#include "ssh-dss.h" +#include "ssh-rsa.h" #include "uuencode.h" #include "buffer.h" #include "bufaux.h" @@ -87,7 +89,6 @@ } return k; } - Key * key_new_private(int type) { @@ -119,7 +120,6 @@ } return k; } - void key_free(Key *k) { @@ -169,7 +169,7 @@ return 0; } -static u_char * +static u_char* key_fingerprint_raw(Key *k, enum fp_type dgst_type, u_int *dgst_raw_length) { const EVP_MD *md = NULL; @@ -225,8 +225,8 @@ return retval; } -static char * -key_fingerprint_hex(u_char *dgst_raw, u_int dgst_raw_len) +static char* +key_fingerprint_hex(u_char* dgst_raw, u_int dgst_raw_len) { char *retval; int i; @@ -242,8 +242,8 @@ return retval; } -static char * -key_fingerprint_bubblebabble(u_char *dgst_raw, u_int dgst_raw_len) +static char* +key_fingerprint_bubblebabble(u_char* dgst_raw, u_int dgst_raw_len) { char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; char consonants[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', @@ -289,7 +289,7 @@ return retval; } -char * +char* key_fingerprint(Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep) { char *retval = NULL; @@ -359,7 +359,6 @@ *cpp = cp; return 1; } - static int write_bignum(FILE *f, BIGNUM *num) { @@ -408,14 +407,14 @@ case KEY_DSA: space = strchr(cp, ' '); if (space == NULL) { - debug3("key_read: missing whitespace"); + debug3("key_read: no space"); return -1; } *space = '\0'; type = key_type_from_name(cp); *space = ' '; if (type == KEY_UNSPEC) { - debug3("key_read: missing keytype"); + debug3("key_read: no key found"); return -1; } cp = space+1; @@ -486,14 +485,12 @@ } return success; } - int key_write(Key *key, FILE *f) { int n, success = 0; u_int len, bits = 0; - u_char *blob; - char *uu; + u_char *blob, *uu; if (key->type == KEY_RSA1 && key->rsa != NULL) { /* size of modulus 'n' */ @@ -519,7 +516,6 @@ } return success; } - char * key_type(Key *k) { @@ -536,7 +532,6 @@ } return "unknown"; } - char * key_ssh_name(Key *k) { @@ -550,7 +545,6 @@ } return "ssh-unknown"; } - u_int key_size(Key *k) { @@ -728,6 +722,7 @@ { Buffer b; int len; + u_char *buf; if (key == NULL) { error("key_to_blob: key == NULL"); @@ -753,14 +748,14 @@ return 0; } len = buffer_len(&b); - if (lenp != NULL) - *lenp = len; - if (blobp != NULL) { - *blobp = xmalloc(len); - memcpy(*blobp, buffer_ptr(&b), len); - } + buf = xmalloc(len); + memcpy(buf, buffer_ptr(&b), len); memset(buffer_ptr(&b), 0, len); buffer_free(&b); + if (lenp != NULL) + *lenp = len; + if (blobp != NULL) + *blobp = buf; return len; } @@ -812,6 +807,7 @@ } /* Converts a private to a public key */ + Key * key_demote(Key *k) {