version 1.16.2.2, 2000/11/08 21:31:19 |
version 1.16.2.3, 2001/03/12 15:44:15 |
|
|
RCSID("$OpenBSD$"); |
RCSID("$OpenBSD$"); |
|
|
#include <openssl/evp.h> |
#include <openssl/evp.h> |
#include <openssl/rsa.h> |
|
#include <openssl/dsa.h> |
|
|
|
#include "rsa.h" |
|
#include "ssh.h" |
#include "ssh.h" |
|
#include "rsa.h" |
|
#include "log.h" |
#include "xmalloc.h" |
#include "xmalloc.h" |
#include "key.h" |
#include "key.h" |
#include "authfd.h" |
#include "authfd.h" |
#include "authfile.h" |
#include "authfile.h" |
|
#include "pathnames.h" |
|
#include "readpass.h" |
|
|
void |
void |
delete_file(AuthenticationConnection *ac, const char *filename) |
delete_file(AuthenticationConnection *ac, const char *filename) |
|
|
Key *public; |
Key *public; |
char *comment; |
char *comment; |
|
|
public = key_new(KEY_RSA); |
public = key_new(KEY_RSA1); |
if (!load_public_key(filename, public, &comment)) { |
if (!load_public_key(filename, public, &comment)) { |
key_free(public); |
key_free(public); |
public = key_new(KEY_DSA); |
public = key_new(KEY_UNSPEC); |
if (!try_load_public_key(filename, public, &comment)) { |
if (!try_load_public_key(filename, public, &comment)) { |
printf("Bad key file %s\n", filename); |
printf("Bad key file %s\n", filename); |
return; |
return; |
|
|
if (success) |
if (success) |
fprintf(stderr, "All identities removed.\n"); |
fprintf(stderr, "All identities removed.\n"); |
else |
else |
fprintf(stderr, "Failed to remove all identitities.\n"); |
fprintf(stderr, "Failed to remove all identities.\n"); |
} |
} |
|
|
char * |
char * |
|
|
int p[2], status; |
int p[2], status; |
char buf[1024]; |
char buf[1024]; |
|
|
|
if (fflush(stdout) != 0) |
|
error("ssh_askpass: fflush: %s", strerror(errno)); |
if (askpass == NULL) |
if (askpass == NULL) |
fatal("internal error: askpass undefined"); |
fatal("internal error: askpass undefined"); |
if (pipe(p) < 0) |
if (pipe(p) < 0) |
|
|
char buf[1024], msg[1024]; |
char buf[1024], msg[1024]; |
int success; |
int success; |
int interactive = isatty(STDIN_FILENO); |
int interactive = isatty(STDIN_FILENO); |
int type = KEY_RSA; |
int type = KEY_RSA1; |
|
|
if (stat(filename, &st) < 0) { |
if (stat(filename, &st) < 0) { |
perror(filename); |
perror(filename); |
|
|
* try to load the public key. right now this only works for RSA, |
* try to load the public key. right now this only works for RSA, |
* since DSA keys are fully encrypted |
* since DSA keys are fully encrypted |
*/ |
*/ |
public = key_new(KEY_RSA); |
public = key_new(KEY_RSA1); |
if (!load_public_key(filename, public, &saved_comment)) { |
if (!load_public_key(filename, public, &saved_comment)) { |
/* ok, so we will asume this is a DSA key */ |
/* ok, so we will assume this is 'some' key */ |
type = KEY_DSA; |
type = KEY_UNSPEC; |
saved_comment = xstrdup(filename); |
saved_comment = xstrdup(filename); |
} |
} |
key_free(public); |
key_free(public); |
|
|
if (getenv(SSH_ASKPASS_ENV)) |
if (getenv(SSH_ASKPASS_ENV)) |
askpass = getenv(SSH_ASKPASS_ENV); |
askpass = getenv(SSH_ASKPASS_ENV); |
else |
else |
askpass = SSH_ASKPASS_DEFAULT; |
askpass = _PATH_SSH_ASKPASS_DEFAULT; |
} |
} |
|
|
/* At first, try empty passphrase */ |
/* At first, try empty passphrase */ |
|
|
key = ssh_get_next_identity(ac, &comment, version)) { |
key = ssh_get_next_identity(ac, &comment, version)) { |
had_identities = 1; |
had_identities = 1; |
if (fp) { |
if (fp) { |
printf("%d %s %s\n", |
printf("%d %s %s (%s)\n", |
key_size(key), key_fingerprint(key), comment); |
key_size(key), key_fingerprint(key), |
|
comment, key_type(key)); |
} else { |
} else { |
if (!key_write(key, stdout)) |
if (!key_write(key, stdout)) |
fprintf(stderr, "key_write failed"); |
fprintf(stderr, "key_write failed"); |
|
|
int i; |
int i; |
int deleting = 0; |
int deleting = 0; |
|
|
/* check if RSA support exists */ |
SSLeay_add_all_algorithms(); |
if (rsa_alive() == 0) { |
|
extern char *__progname; |
|
|
|
fprintf(stderr, |
|
"%s: no RSA support in libssl and libcrypto. See ssl(8).\n", |
|
__progname); |
|
exit(1); |
|
} |
|
SSLeay_add_all_algorithms(); |
|
|
|
/* At first, get a connection to the authentication agent. */ |
/* At first, get a connection to the authentication agent. */ |
ac = ssh_get_authentication_connection(); |
ac = ssh_get_authentication_connection(); |
if (ac == NULL) { |
if (ac == NULL) { |
|
|
ssh_close_authentication_connection(ac); |
ssh_close_authentication_connection(ac); |
exit(1); |
exit(1); |
} |
} |
snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY); |
snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, _PATH_SSH_CLIENT_IDENTITY); |
if (deleting) |
if (deleting) |
delete_file(ac, buf); |
delete_file(ac, buf); |
else |
else |