X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/1e608e420beaca67ca6bc6bef308f9f9f6132a66..86a22a0a7eda4bbef1e9d7157145cf6b7f42f1a1:/openssh/ssh-keygen.c diff --git a/openssh/ssh-keygen.c b/openssh/ssh-keygen.c index 6aff4a4..6d50997 100644 --- a/openssh/ssh-keygen.c +++ b/openssh/ssh-keygen.c @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keygen.c,v 1.94 2002/02/25 16:33:27 markus Exp $"); +RCSID("$OpenBSD: ssh-keygen.c,v 1.83 2001/10/25 21:14:32 markus Exp $"); #include #include @@ -73,7 +73,8 @@ int convert_to_ssh2 = 0; int convert_from_ssh2 = 0; int print_public = 0; -char *key_type_name = NULL; +/* default to RSA for SSH-1 */ +char *key_type_name = "rsa1"; /* argv0 */ #ifdef HAVE___PROGNAME @@ -90,25 +91,21 @@ ask_filename(struct passwd *pw, const char *prompt) char buf[1024]; char *name = NULL; - if (key_type_name == NULL) + switch (key_type_from_name(key_type_name)) { + case KEY_RSA1: + name = _PATH_SSH_CLIENT_IDENTITY; + break; + case KEY_DSA: + name = _PATH_SSH_CLIENT_ID_DSA; + break; + case KEY_RSA: name = _PATH_SSH_CLIENT_ID_RSA; - else - switch (key_type_from_name(key_type_name)) { - case KEY_RSA1: - name = _PATH_SSH_CLIENT_IDENTITY; - break; - case KEY_DSA: - name = _PATH_SSH_CLIENT_ID_DSA; - break; - case KEY_RSA: - name = _PATH_SSH_CLIENT_ID_RSA; - break; - default: - fprintf(stderr, "bad key type"); - exit(1); - break; - } - + break; + default: + fprintf(stderr, "bad key type"); + exit(1); + break; + } snprintf(identity_file, sizeof(identity_file), "%s/%s", pw->pw_dir, name); fprintf(stderr, "%s (%s): ", prompt, identity_file); fflush(stderr); @@ -150,7 +147,7 @@ static void do_convert_to_ssh2(struct passwd *pw) { Key *k; - u_int len; + int len; u_char *blob; struct stat st; @@ -191,12 +188,12 @@ buffer_get_bignum_bits(Buffer *b, BIGNUM *value) if (buffer_len(b) < bytes) fatal("buffer_get_bignum_bits: input buffer too small: " "need %d have %d", bytes, buffer_len(b)); - BN_bin2bn(buffer_ptr(b), bytes, value); + BN_bin2bn((u_char *)buffer_ptr(b), bytes, value); buffer_consume(b, bytes); } static Key * -do_convert_private_ssh2_from_blob(u_char *blob, u_int blen) +do_convert_private_ssh2_from_blob(u_char *blob, int blen) { Buffer b; Key *key = NULL; @@ -275,7 +272,7 @@ do_convert_private_ssh2_from_blob(u_char *blob, u_int blen) break; } rlen = buffer_len(&b); - if (rlen != 0) + if(rlen != 0) error("do_convert_private_ssh2_from_blob: " "remaining bytes in key blob %d", rlen); buffer_free(&b); @@ -336,7 +333,7 @@ do_convert_from_ssh2(struct passwd *pw) *p = '\0'; strlcat(encoded, line, sizeof(encoded)); } - blen = uudecode(encoded, blob, sizeof(blob)); + blen = uudecode(encoded, (u_char *)blob, sizeof(blob)); if (blen < 0) { fprintf(stderr, "uudecode failed.\n"); exit(1); @@ -358,8 +355,7 @@ do_convert_from_ssh2(struct passwd *pw) exit(1); } key_free(k); - if (!private) - fprintf(stdout, "\n"); + fprintf(stdout, "\n"); fclose(fp); exit(0); } @@ -397,7 +393,7 @@ do_print_public(struct passwd *pw) debug("#bytes %d", len); \ if (BN_bn2bin(prv->rsa->x, elements[i]) < 0) \ goto done; \ - } while (0) + } while(0) static int get_AUT0(char *aut0) @@ -538,9 +534,7 @@ do_fingerprint(struct passwd *pw) FILE *f; Key *public; char *comment = NULL, *cp, *ep, line[16*1024], *fp; - int i, skip = 0, num = 1, invalid = 1; - enum fp_rep rep; - enum fp_type fptype; + int i, skip = 0, num = 1, invalid = 1, rep, fptype; struct stat st; fptype = print_bubblebabble ? SSH_FP_SHA1 : SSH_FP_MD5; @@ -674,7 +668,7 @@ do_change_passphrase(struct passwd *pw) read_passphrase("Enter new passphrase (empty for no " "passphrase): ", RP_ALLOW_STDIN); passphrase2 = read_passphrase("Enter same passphrase again: ", - RP_ALLOW_STDIN); + RP_ALLOW_STDIN); /* Verify that they are the same. */ if (strcmp(passphrase1, passphrase2) != 0) { @@ -752,7 +746,7 @@ do_change_comment(struct passwd *pw) fprintf(stderr, "Comments are only supported for RSA1 keys.\n"); key_free(private); exit(1); - } + } printf("Key now has comment '%s'\n", comment); if (identity_comment) { @@ -839,7 +833,7 @@ usage(void) int main(int ac, char **av) { - char dotsshdir[MAXPATHLEN], comment[1024], *passphrase1, *passphrase2; + char dotsshdir[16 * 1024], comment[1024], *passphrase1, *passphrase2; char *reader_id = NULL; Key *private, *public; struct passwd *pw; @@ -851,6 +845,8 @@ main(int ac, char **av) extern char *optarg; __progname = get_progname(av[0]); + init_rng(); + seed_rng(); SSLeay_add_all_algorithms(); @@ -966,14 +962,8 @@ main(int ac, char **av) #endif /* SMARTCARD */ } - init_rng(); - seed_rng(); arc4random_stir(); - if (key_type_name == NULL) { - printf("You must specify a key type (-t).\n"); - usage(); - } type = key_type_from_name(key_type_name); if (type == KEY_UNSPEC) { fprintf(stderr, "unknown key type %s\n", key_type_name);