=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/ssh-keygen.c,v retrieving revision 1.32.2.4 retrieving revision 1.53 diff -u -r1.32.2.4 -r1.53 --- src/usr.bin/ssh/ssh-keygen.c 2001/05/07 21:09:36 1.32.2.4 +++ src/usr.bin/ssh/ssh-keygen.c 2001/03/26 23:23:24 1.53 @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-keygen.c,v 1.32.2.4 2001/05/07 21:09:36 jason Exp $"); +RCSID("$OpenBSD: ssh-keygen.c,v 1.53 2001/03/26 23:23:24 markus Exp $"); #include #include @@ -114,7 +114,7 @@ char *pass; Key *prv; - prv = key_load_private(filename, "", NULL); + prv = key_load_private(filename, "", NULL); if (prv == NULL) { pass = read_passphrase("Enter passphrase: ", 1); prv = key_load_private(filename, pass, NULL); @@ -132,7 +132,7 @@ void do_convert_to_ssh2(struct passwd *pw) { - Key *k; + Key *prv; int len; u_char *blob; struct stat st; @@ -143,21 +143,20 @@ perror(identity_file); exit(1); } - if ((k = key_load_public(identity_file, NULL)) == NULL) { - if ((k = try_load_pem_key(identity_file)) == NULL) { - fprintf(stderr, "load failed\n"); - exit(1); - } + prv = try_load_pem_key(identity_file); + if (prv == NULL) { + fprintf(stderr, "load failed\n"); + exit(1); } - key_to_blob(k, &blob, &len); + key_to_blob(prv, &blob, &len); fprintf(stdout, "%s\n", SSH_COM_PUBLIC_BEGIN); fprintf(stdout, "Comment: \"%d-bit %s, converted from OpenSSH by %s@%s\"\n", - key_size(k), key_type(k), + key_size(prv), key_type(prv), pw->pw_name, hostname); dump_base64(stdout, blob, len); fprintf(stdout, "%s\n", SSH_COM_PUBLIC_END); - key_free(k); + key_free(prv); xfree(blob); exit(0); } @@ -253,7 +252,7 @@ key_sign(key, &sig, &slen, data, sizeof data); key_verify(key, sig, slen, data, sizeof data); - xfree(sig); + free(sig); } #endif return key; @@ -294,12 +293,12 @@ strstr(line, ": ") != NULL) { if (strstr(line, SSH_COM_PRIVATE_BEGIN) != NULL) private = 1; - /* fprintf(stderr, "ignore: %s", line); */ + fprintf(stderr, "ignore: %s", line); continue; } if (escaped) { escaped--; - /* fprintf(stderr, "escaped: %s", line); */ + fprintf(stderr, "escaped: %s", line); continue; } *p = '\0'; @@ -509,7 +508,8 @@ /* Save the file using the new passphrase. */ if (!key_save_private(private, identity_file, passphrase1, comment)) { - printf("Saving the key failed: %s.\n", identity_file); + printf("Saving the key failed: %s: %s.\n", + identity_file, strerror(errno)); memset(passphrase1, 0, strlen(passphrase1)); xfree(passphrase1); key_free(private); @@ -587,7 +587,8 @@ /* Save the file using the new passphrase. */ if (!key_save_private(private, identity_file, passphrase, new_comment)) { - printf("Saving the key failed: %s.\n", identity_file); + printf("Saving the key failed: %s: %s.\n", + identity_file, strerror(errno)); memset(passphrase, 0, strlen(passphrase)); xfree(passphrase); key_free(private); @@ -625,7 +626,7 @@ void usage(void) { - printf("Usage: %s [-ceilpqyB] [-t type] [-b bits] [-f file] [-C comment] " + printf("Usage: %s [-lBpqxXyc] [-t type] [-b bits] [-f file] [-C comment] " "[-N new-pass] [-P pass]\n", __progname); exit(1); } @@ -659,7 +660,7 @@ exit(1); } - while ((opt = getopt(ac, av, "deiqpclBRxXyb:f:t:P:N:C:")) != -1) { + while ((opt = getopt(ac, av, "dqpclBRxXyb:f:t:P:N:C:")) != -1) { switch (opt) { case 'b': bits = atoi(optarg); @@ -711,15 +712,11 @@ exit(0); break; - case 'e': case 'x': - /* export key */ convert_to_ssh2 = 1; break; - case 'i': case 'X': - /* import key */ convert_from_ssh2 = 1; break; @@ -833,7 +830,8 @@ /* Save the key with the given passphrase and comment. */ if (!key_save_private(private, identity_file, passphrase1, comment)) { - printf("Saving the key failed: %s.\n", identity_file); + printf("Saving the key failed: %s: %s.\n", + identity_file, strerror(errno)); memset(passphrase1, 0, strlen(passphrase1)); xfree(passphrase1); exit(1);