version 1.166, 2002/03/21 22:44:05 |
version 1.167, 2002/03/25 17:34:27 |
|
|
#include "sshtty.h" |
#include "sshtty.h" |
|
|
#ifdef SMARTCARD |
#ifdef SMARTCARD |
#include <openssl/engine.h> |
|
#include "scard.h" |
#include "scard.h" |
#endif |
#endif |
|
|
|
|
load_public_identity_files(void) |
load_public_identity_files(void) |
{ |
{ |
char *filename; |
char *filename; |
Key *public; |
|
int i = 0; |
int i = 0; |
|
Key *public; |
#ifdef SMARTCARD |
#ifdef SMARTCARD |
if (options.smartcard_device != NULL && |
Key **keys; |
options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES && |
|
(public = sc_get_key(options.smartcard_device, NULL)) != NULL ) { |
|
Key *new; |
|
|
|
if (options.num_identity_files + 2 > SSH_MAX_IDENTITY_FILES) |
if (options.smartcard_device != NULL && |
options.num_identity_files = SSH_MAX_IDENTITY_FILES - 2; |
options.num_identity_files < SSH_MAX_IDENTITY_FILES && |
memmove(&options.identity_files[2], &options.identity_files[0], |
(keys = sc_get_keys(options.smartcard_device, NULL)) != NULL ) { |
sizeof(char *) * options.num_identity_files); |
int count = 0; |
options.num_identity_files += 2; |
for (i = 0; keys[i] != NULL; i++) { |
i = 2; |
count++; |
|
if (options.num_identity_files + 1 > SSH_MAX_IDENTITY_FILES) |
/* XXX ssh1 vs ssh2 */ |
options.num_identity_files = SSH_MAX_IDENTITY_FILES - 1; |
new = key_new(KEY_RSA); |
memmove(&options.identity_files[1], &options.identity_files[0], |
new->flags = KEY_FLAG_EXT; |
sizeof(char *) * (SSH_MAX_IDENTITY_FILES - 1)); |
BN_copy(new->rsa->n, public->rsa->n); |
memmove(&options.identity_keys[1], &options.identity_keys[0], |
BN_copy(new->rsa->e, public->rsa->e); |
sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1)); |
RSA_set_method(new->rsa, sc_get_engine()); |
options.num_identity_files++; |
options.identity_keys[0] = new; |
options.identity_keys[0] = keys[i]; |
options.identity_files[0] = xstrdup("smartcard rsa key");; |
options.identity_files[0] = xstrdup("smartcard key");; |
|
} |
new = key_new(KEY_RSA1); |
i = count; |
new->flags = KEY_FLAG_EXT; |
xfree(keys); |
BN_copy(new->rsa->n, public->rsa->n); |
|
BN_copy(new->rsa->e, public->rsa->e); |
|
RSA_set_method(new->rsa, sc_get_engine()); |
|
options.identity_keys[1] = new; |
|
options.identity_files[1] = xstrdup("smartcard rsa1 key"); |
|
|
|
key_free(public); |
|
} |
} |
#endif /* SMARTCARD */ |
#endif /* SMARTCARD */ |
for (; i < options.num_identity_files; i++) { |
for (; i < options.num_identity_files; i++) { |