]> andersk Git - openssh.git/blobdiff - ssh.c
- markus@cvs.openbsd.org 2002/03/25 17:34:27
[openssh.git] / ssh.c
diff --git a/ssh.c b/ssh.c
index ae2e85480ff55be9dcf96b7f74f012b63467a404..dd926b7e7ac8870da807e5ef638597a276a608fd 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.166 2002/03/21 22:44:05 rees Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.167 2002/03/25 17:34:27 markus Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -70,7 +70,6 @@ RCSID("$OpenBSD: ssh.c,v 1.166 2002/03/21 22:44:05 rees Exp $");
 #include "sshtty.h"
 
 #ifdef SMARTCARD
-#include <openssl/engine.h>
 #include "scard.h"
 #endif
 
@@ -1187,40 +1186,29 @@ static void
 load_public_identity_files(void)
 {
        char *filename;
-       Key *public;
        int i = 0;
-
+       Key *public;
 #ifdef SMARTCARD
+       Key **keys;
+
        if (options.smartcard_device != NULL &&
-           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)
-                       options.num_identity_files = SSH_MAX_IDENTITY_FILES - 2;
-               memmove(&options.identity_files[2], &options.identity_files[0],
-                   sizeof(char *) * options.num_identity_files);
-               options.num_identity_files += 2;
-               i = 2;
-
-               /* XXX ssh1 vs ssh2 */
-               new = key_new(KEY_RSA);
-               new->flags = KEY_FLAG_EXT;
-               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[0] = new;
-               options.identity_files[0] = xstrdup("smartcard rsa key");;
-
-               new = key_new(KEY_RSA1);
-               new->flags = KEY_FLAG_EXT;
-               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);
+           options.num_identity_files < SSH_MAX_IDENTITY_FILES &&
+           (keys = sc_get_keys(options.smartcard_device, NULL)) != NULL ) {
+               int count = 0;
+               for (i = 0; keys[i] != NULL; i++) {
+                       count++;
+                       if (options.num_identity_files + 1 > SSH_MAX_IDENTITY_FILES)
+                               options.num_identity_files = SSH_MAX_IDENTITY_FILES - 1;
+                       memmove(&options.identity_files[1], &options.identity_files[0],
+                           sizeof(char *) * (SSH_MAX_IDENTITY_FILES - 1));
+                       memmove(&options.identity_keys[1], &options.identity_keys[0],
+                           sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1));
+                       options.num_identity_files++;
+                       options.identity_keys[0] = keys[i];
+                       options.identity_files[0] = xstrdup("smartcard key");;
+               }
+               i = count;
+               xfree(keys);
        }
 #endif /* SMARTCARD */
        for (; i < options.num_identity_files; i++) {
This page took 0.036624 seconds and 4 git commands to generate.