version 1.58, 2004/08/23 11:48:09 |
version 1.58.2.2, 2005/09/02 03:44:59 |
|
|
#include "log.h" |
#include "log.h" |
#include "authfile.h" |
#include "authfile.h" |
#include "rsa.h" |
#include "rsa.h" |
|
#include "misc.h" |
|
#include "atomicio.h" |
|
|
/* Version identification string for SSH v1 identity files. */ |
/* Version identification string for SSH v1 identity files. */ |
static const char authfile_id_string[] = |
static const char authfile_id_string[] = |
|
|
buffer_free(&encrypted); |
buffer_free(&encrypted); |
return 0; |
return 0; |
} |
} |
if (write(fd, buffer_ptr(&encrypted), buffer_len(&encrypted)) != |
if (atomicio(vwrite, fd, buffer_ptr(&encrypted), |
buffer_len(&encrypted)) { |
buffer_len(&encrypted)) != buffer_len(&encrypted)) { |
error("write to key file %s failed: %s", filename, |
error("write to key file %s failed: %s", filename, |
strerror(errno)); |
strerror(errno)); |
buffer_free(&encrypted); |
buffer_free(&encrypted); |
|
|
Key *pub; |
Key *pub; |
struct stat st; |
struct stat st; |
char *cp; |
char *cp; |
int i; |
u_int i; |
size_t len; |
size_t len; |
|
|
if (fstat(fd, &st) < 0) { |
if (fstat(fd, &st) < 0) { |
|
|
buffer_init(&buffer); |
buffer_init(&buffer); |
cp = buffer_append_space(&buffer, len); |
cp = buffer_append_space(&buffer, len); |
|
|
if (read(fd, cp, (size_t) len) != (size_t) len) { |
if (atomicio(read, fd, cp, len) != len) { |
debug("Read from key file %.200s failed: %.100s", filename, |
debug("Read from key file %.200s failed: %.100s", filename, |
strerror(errno)); |
strerror(errno)); |
buffer_free(&buffer); |
buffer_free(&buffer); |
|
|
key_load_private_rsa1(int fd, const char *filename, const char *passphrase, |
key_load_private_rsa1(int fd, const char *filename, const char *passphrase, |
char **commentp) |
char **commentp) |
{ |
{ |
int i, check1, check2, cipher_type; |
u_int i; |
|
int check1, check2, cipher_type; |
size_t len; |
size_t len; |
Buffer buffer, decrypted; |
Buffer buffer, decrypted; |
u_char *cp; |
u_char *cp; |
|
|
buffer_init(&buffer); |
buffer_init(&buffer); |
cp = buffer_append_space(&buffer, len); |
cp = buffer_append_space(&buffer, len); |
|
|
if (read(fd, cp, (size_t) len) != (size_t) len) { |
if (atomicio(read, fd, cp, len) != len) { |
debug("Read from key file %.200s failed: %.100s", filename, |
debug("Read from key file %.200s failed: %.100s", filename, |
strerror(errno)); |
strerror(errno)); |
buffer_free(&buffer); |
buffer_free(&buffer); |
|
|
key_try_load_public(Key *k, const char *filename, char **commentp) |
key_try_load_public(Key *k, const char *filename, char **commentp) |
{ |
{ |
FILE *f; |
FILE *f; |
char line[4096]; |
char line[SSH_MAX_PUBKEY_BYTES]; |
char *cp; |
char *cp; |
|
u_long linenum = 0; |
|
|
f = fopen(filename, "r"); |
f = fopen(filename, "r"); |
if (f != NULL) { |
if (f != NULL) { |
while (fgets(line, sizeof(line), f)) { |
while (read_keyfile_line(f, filename, line, sizeof(line), |
line[sizeof(line)-1] = '\0'; |
&linenum) != -1) { |
cp = line; |
cp = line; |
switch (*cp) { |
switch (*cp) { |
case '#': |
case '#': |