=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/ssh-keygen.c,v retrieving revision 1.19 retrieving revision 1.28 diff -u -r1.19 -r1.28 --- src/usr.bin/ssh/ssh-keygen.c 2000/04/26 20:56:29 1.19 +++ src/usr.bin/ssh/ssh-keygen.c 2000/07/07 03:55:04 1.28 @@ -7,7 +7,7 @@ */ #include "includes.h" -RCSID("$Id: ssh-keygen.c,v 1.19 2000/04/26 20:56:29 markus Exp $"); +RCSID("$OpenBSD: ssh-keygen.c,v 1.28 2000/07/07 03:55:04 todd Exp $"); #include #include @@ -72,7 +72,8 @@ { char buf[1024]; snprintf(identity_file, sizeof(identity_file), "%s/%s", - pw->pw_dir, SSH_CLIENT_IDENTITY); + pw->pw_dir, + dsa_mode ? SSH_CLIENT_ID_DSA: SSH_CLIENT_IDENTITY); printf("%s (%s): ", prompt, identity_file); fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) @@ -122,14 +123,15 @@ exit(1); } dsa_make_key_blob(k, &blob, &len); - fprintf(stdout, SSH_COM_MAGIC_BEGIN "\n"); + fprintf(stdout, "%s\n", SSH_COM_MAGIC_BEGIN); fprintf(stdout, "Comment: \"%d-bit DSA, converted from openssh by %s@%s\"\n", BN_num_bits(k->dsa->p), pw->pw_name, hostname); dump_base64(stdout, blob, len); - fprintf(stdout, SSH_COM_MAGIC_END "\n"); + fprintf(stdout, "%s\n", SSH_COM_MAGIC_END); key_free(k); + xfree(blob); exit(0); } @@ -142,6 +144,7 @@ char blob[8096]; char encoded[8096]; struct stat st; + int escaped = 0; FILE *fp; if (!have_identity) @@ -157,14 +160,21 @@ } encoded[0] = '\0'; while (fgets(line, sizeof(line), fp)) { + if (!(p = strchr(line, '\n'))) { + fprintf(stderr, "input line too long.\n"); + exit(1); + } + if (p > line && p[-1] == '\\') + escaped++; if (strncmp(line, "----", 4) == 0 || strstr(line, ": ") != NULL) { fprintf(stderr, "ignore: %s", line); continue; } - if (!(p = strchr(line, '\n'))) { - fprintf(stderr, "input line too long.\n"); - exit(1); + if (escaped) { + escaped--; + fprintf(stderr, "escaped: %s", line); + continue; } *p = '\0'; strlcat(encoded, line, sizeof(encoded)); @@ -206,6 +216,7 @@ if (!key_write(k, stdout)) fprintf(stderr, "key_write failed"); key_free(k); + xfree(blob); fprintf(stdout, "\n"); exit(0); } @@ -485,8 +496,7 @@ void usage(void) { - printf("ssh-keygen version %s\n", SSH_VERSION); - printf("Usage: %s [-b bits] [-p] [-c] [-l] [-x] [-X] [-y] [-f file] [-P pass] [-N new-pass] [-C comment]\n", __progname); + printf("Usage: %s [-lpqxXydc] [-b bits] [-f file] [-C comment] [-N new-pass] [-P pass]\n", __progname); exit(1); } @@ -506,7 +516,7 @@ extern int optind; extern char *optarg; - OpenSSL_add_all_algorithms(); + SSLeay_add_all_algorithms(); /* we need this for the home * directory. */ pw = getpwuid(getuid()); @@ -519,7 +529,7 @@ exit(1); } - while ((opt = getopt(ac, av, "dqpclxXyb:f:P:N:C:")) != EOF) { + while ((opt = getopt(ac, av, "dqpclRxXyb:f:P:N:C:")) != EOF) { switch (opt) { case 'b': bits = atoi(optarg); @@ -560,6 +570,13 @@ case 'q': quiet = 1; + break; + + case 'R': + if (rsa_alive() == 0) + exit(1); + else + exit(0); break; case 'x':