=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/key.c,v retrieving revision 1.43 retrieving revision 1.43.2.3 diff -u -r1.43 -r1.43.2.3 --- src/usr.bin/ssh/Attic/key.c 2002/03/19 10:49:35 1.43 +++ src/usr.bin/ssh/Attic/key.c 2003/04/03 22:35:17 1.43.2.3 @@ -32,15 +32,13 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: key.c,v 1.43 2002/03/19 10:49:35 markus Exp $"); +RCSID("$OpenBSD: key.c,v 1.43.2.3 2003/04/03 22:35:17 miod 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" @@ -89,6 +87,7 @@ } return k; } + Key * key_new_private(int type) { @@ -120,6 +119,7 @@ } 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,6 +359,7 @@ *cpp = cp; return 1; } + static int write_bignum(FILE *f, BIGNUM *num) { @@ -407,14 +408,14 @@ case KEY_DSA: space = strchr(cp, ' '); if (space == NULL) { - debug3("key_read: no space"); + debug3("key_read: missing whitespace"); return -1; } *space = '\0'; type = key_type_from_name(cp); *space = ' '; if (type == KEY_UNSPEC) { - debug3("key_read: no key found"); + debug3("key_read: missing keytype"); return -1; } cp = space+1; @@ -485,12 +486,14 @@ } return success; } + int key_write(Key *key, FILE *f) { int n, success = 0; u_int len, bits = 0; - u_char *blob, *uu; + u_char *blob; + char *uu; if (key->type == KEY_RSA1 && key->rsa != NULL) { /* size of modulus 'n' */ @@ -516,6 +519,7 @@ } return success; } + char * key_type(Key *k) { @@ -532,6 +536,7 @@ } return "unknown"; } + char * key_ssh_name(Key *k) { @@ -545,6 +550,7 @@ } return "ssh-unknown"; } + u_int key_size(Key *k) { @@ -722,7 +728,6 @@ { Buffer b; int len; - u_char *buf; if (key == NULL) { error("key_to_blob: key == NULL"); @@ -748,14 +753,14 @@ return 0; } len = buffer_len(&b); - 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; + if (blobp != NULL) { + *blobp = xmalloc(len); + memcpy(*blobp, buffer_ptr(&b), len); + } + memset(buffer_ptr(&b), 0, len); + buffer_free(&b); return len; } @@ -779,6 +784,10 @@ } } +/* + * key_verify returns 1 for a correct signature, 0 for an incorrect signature + * and -1 on error. + */ int key_verify( Key *key, @@ -803,7 +812,6 @@ } /* Converts a private to a public key */ - Key * key_demote(Key *k) {