diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 54 |
1 files changed, 21 insertions, 33 deletions
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: ssh.c,v 1.166 2002/03/21 22:44:05 rees Exp $"); | 42 | RCSID("$OpenBSD: ssh.c,v 1.167 2002/03/25 17:34:27 markus Exp $"); |
43 | 43 | ||
44 | #include <openssl/evp.h> | 44 | #include <openssl/evp.h> |
45 | #include <openssl/err.h> | 45 | #include <openssl/err.h> |
@@ -70,7 +70,6 @@ RCSID("$OpenBSD: ssh.c,v 1.166 2002/03/21 22:44:05 rees Exp $"); | |||
70 | #include "sshtty.h" | 70 | #include "sshtty.h" |
71 | 71 | ||
72 | #ifdef SMARTCARD | 72 | #ifdef SMARTCARD |
73 | #include <openssl/engine.h> | ||
74 | #include "scard.h" | 73 | #include "scard.h" |
75 | #endif | 74 | #endif |
76 | 75 | ||
@@ -1187,40 +1186,29 @@ static void | |||
1187 | load_public_identity_files(void) | 1186 | load_public_identity_files(void) |
1188 | { | 1187 | { |
1189 | char *filename; | 1188 | char *filename; |
1190 | Key *public; | ||
1191 | int i = 0; | 1189 | int i = 0; |
1192 | 1190 | Key *public; | |
1193 | #ifdef SMARTCARD | 1191 | #ifdef SMARTCARD |
1192 | Key **keys; | ||
1193 | |||
1194 | if (options.smartcard_device != NULL && | 1194 | if (options.smartcard_device != NULL && |
1195 | options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES && | 1195 | options.num_identity_files < SSH_MAX_IDENTITY_FILES && |
1196 | (public = sc_get_key(options.smartcard_device, NULL)) != NULL ) { | 1196 | (keys = sc_get_keys(options.smartcard_device, NULL)) != NULL ) { |
1197 | Key *new; | 1197 | int count = 0; |
1198 | 1198 | for (i = 0; keys[i] != NULL; i++) { | |
1199 | if (options.num_identity_files + 2 > SSH_MAX_IDENTITY_FILES) | 1199 | count++; |
1200 | options.num_identity_files = SSH_MAX_IDENTITY_FILES - 2; | 1200 | if (options.num_identity_files + 1 > SSH_MAX_IDENTITY_FILES) |
1201 | memmove(&options.identity_files[2], &options.identity_files[0], | 1201 | options.num_identity_files = SSH_MAX_IDENTITY_FILES - 1; |
1202 | sizeof(char *) * options.num_identity_files); | 1202 | memmove(&options.identity_files[1], &options.identity_files[0], |
1203 | options.num_identity_files += 2; | 1203 | sizeof(char *) * (SSH_MAX_IDENTITY_FILES - 1)); |
1204 | i = 2; | 1204 | memmove(&options.identity_keys[1], &options.identity_keys[0], |
1205 | 1205 | sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1)); | |
1206 | /* XXX ssh1 vs ssh2 */ | 1206 | options.num_identity_files++; |
1207 | new = key_new(KEY_RSA); | 1207 | options.identity_keys[0] = keys[i]; |
1208 | new->flags = KEY_FLAG_EXT; | 1208 | options.identity_files[0] = xstrdup("smartcard key");; |
1209 | BN_copy(new->rsa->n, public->rsa->n); | 1209 | } |
1210 | BN_copy(new->rsa->e, public->rsa->e); | 1210 | i = count; |
1211 | RSA_set_method(new->rsa, sc_get_engine()); | 1211 | xfree(keys); |
1212 | options.identity_keys[0] = new; | ||
1213 | options.identity_files[0] = xstrdup("smartcard rsa key");; | ||
1214 | |||
1215 | new = key_new(KEY_RSA1); | ||
1216 | new->flags = KEY_FLAG_EXT; | ||
1217 | BN_copy(new->rsa->n, public->rsa->n); | ||
1218 | BN_copy(new->rsa->e, public->rsa->e); | ||
1219 | RSA_set_method(new->rsa, sc_get_engine()); | ||
1220 | options.identity_keys[1] = new; | ||
1221 | options.identity_files[1] = xstrdup("smartcard rsa1 key"); | ||
1222 | |||
1223 | key_free(public); | ||
1224 | } | 1212 | } |
1225 | #endif /* SMARTCARD */ | 1213 | #endif /* SMARTCARD */ |
1226 | for (; i < options.num_identity_files; i++) { | 1214 | for (; i < options.num_identity_files; i++) { |