version 1.54, 2001/04/03 13:56:11 |
version 1.60, 2001/04/23 22:14:13 |
|
|
char *pass; |
char *pass; |
Key *prv; |
Key *prv; |
|
|
prv = key_load_private(filename, "", NULL); |
prv = key_load_private(filename, "", NULL); |
if (prv == NULL) { |
if (prv == NULL) { |
pass = read_passphrase("Enter passphrase: ", 1); |
pass = read_passphrase("Enter passphrase: ", 1); |
prv = key_load_private(filename, pass, NULL); |
prv = key_load_private(filename, pass, NULL); |
|
|
void |
void |
do_convert_to_ssh2(struct passwd *pw) |
do_convert_to_ssh2(struct passwd *pw) |
{ |
{ |
Key *prv; |
Key *k; |
int len; |
int len; |
u_char *blob; |
u_char *blob; |
struct stat st; |
struct stat st; |
|
|
perror(identity_file); |
perror(identity_file); |
exit(1); |
exit(1); |
} |
} |
prv = try_load_pem_key(identity_file); |
if ((k = key_load_public(identity_file, NULL)) == NULL) { |
if (prv == NULL) { |
if ((k = try_load_pem_key(identity_file)) == NULL) { |
fprintf(stderr, "load failed\n"); |
fprintf(stderr, "load failed\n"); |
exit(1); |
exit(1); |
|
} |
} |
} |
key_to_blob(prv, &blob, &len); |
key_to_blob(k, &blob, &len); |
fprintf(stdout, "%s\n", SSH_COM_PUBLIC_BEGIN); |
fprintf(stdout, "%s\n", SSH_COM_PUBLIC_BEGIN); |
fprintf(stdout, |
fprintf(stdout, |
"Comment: \"%d-bit %s, converted from OpenSSH by %s@%s\"\n", |
"Comment: \"%d-bit %s, converted from OpenSSH by %s@%s\"\n", |
key_size(prv), key_type(prv), |
key_size(k), key_type(k), |
pw->pw_name, hostname); |
pw->pw_name, hostname); |
dump_base64(stdout, blob, len); |
dump_base64(stdout, blob, len); |
fprintf(stdout, "%s\n", SSH_COM_PUBLIC_END); |
fprintf(stdout, "%s\n", SSH_COM_PUBLIC_END); |
key_free(prv); |
key_free(k); |
xfree(blob); |
xfree(blob); |
exit(0); |
exit(0); |
} |
} |
|
|
strstr(line, ": ") != NULL) { |
strstr(line, ": ") != NULL) { |
if (strstr(line, SSH_COM_PRIVATE_BEGIN) != NULL) |
if (strstr(line, SSH_COM_PRIVATE_BEGIN) != NULL) |
private = 1; |
private = 1; |
fprintf(stderr, "ignore: %s", line); |
/* fprintf(stderr, "ignore: %s", line); */ |
continue; |
continue; |
} |
} |
if (escaped) { |
if (escaped) { |
escaped--; |
escaped--; |
fprintf(stderr, "escaped: %s", line); |
/* fprintf(stderr, "escaped: %s", line); */ |
continue; |
continue; |
} |
} |
*p = '\0'; |
*p = '\0'; |
|
|
|
|
/* Save the file using the new passphrase. */ |
/* Save the file using the new passphrase. */ |
if (!key_save_private(private, identity_file, passphrase1, comment)) { |
if (!key_save_private(private, identity_file, passphrase1, comment)) { |
printf("Saving the key failed: %s: %s.\n", |
printf("Saving the key failed: %s.\n", identity_file); |
identity_file, strerror(errno)); |
|
memset(passphrase1, 0, strlen(passphrase1)); |
memset(passphrase1, 0, strlen(passphrase1)); |
xfree(passphrase1); |
xfree(passphrase1); |
key_free(private); |
key_free(private); |
|
|
|
|
/* Save the file using the new passphrase. */ |
/* Save the file using the new passphrase. */ |
if (!key_save_private(private, identity_file, passphrase, new_comment)) { |
if (!key_save_private(private, identity_file, passphrase, new_comment)) { |
printf("Saving the key failed: %s: %s.\n", |
printf("Saving the key failed: %s.\n", identity_file); |
identity_file, strerror(errno)); |
|
memset(passphrase, 0, strlen(passphrase)); |
memset(passphrase, 0, strlen(passphrase)); |
xfree(passphrase); |
xfree(passphrase); |
key_free(private); |
key_free(private); |
|
|
void |
void |
usage(void) |
usage(void) |
{ |
{ |
printf("Usage: %s [-lBpqxXyc] [-t type] [-b bits] [-f file] [-C comment] " |
printf("Usage: %s [-ceilpqyB] [-t type] [-b bits] [-f file] [-C comment] " |
"[-N new-pass] [-P pass]\n", __progname); |
"[-N new-pass] [-P pass]\n", __progname); |
exit(1); |
exit(1); |
} |
} |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
while ((opt = getopt(ac, av, "dqpclBRxXyb:f:t:P:N:C:")) != -1) { |
while ((opt = getopt(ac, av, "deiqpclBRxXyb:f:t:P:N:C:")) != -1) { |
switch (opt) { |
switch (opt) { |
case 'b': |
case 'b': |
bits = atoi(optarg); |
bits = atoi(optarg); |
|
|
exit(0); |
exit(0); |
break; |
break; |
|
|
|
case 'e': |
case 'x': |
case 'x': |
|
/* export key */ |
convert_to_ssh2 = 1; |
convert_to_ssh2 = 1; |
break; |
break; |
|
|
|
case 'i': |
case 'X': |
case 'X': |
|
/* import key */ |
convert_from_ssh2 = 1; |
convert_from_ssh2 = 1; |
break; |
break; |
|
|
|
|
|
|
/* Save the key with the given passphrase and comment. */ |
/* Save the key with the given passphrase and comment. */ |
if (!key_save_private(private, identity_file, passphrase1, comment)) { |
if (!key_save_private(private, identity_file, passphrase1, comment)) { |
printf("Saving the key failed: %s: %s.\n", |
printf("Saving the key failed: %s.\n", identity_file); |
identity_file, strerror(errno)); |
|
memset(passphrase1, 0, strlen(passphrase1)); |
memset(passphrase1, 0, strlen(passphrase1)); |
xfree(passphrase1); |
xfree(passphrase1); |
exit(1); |
exit(1); |