- public = key_new(type);
- if (!load_public_key(filename, public, NULL)) {
- /* ok, so we will assume this is 'some' key */
- type = KEY_UNSPEC;
+#ifdef SMARTCARD
+ if (sc_reader_num != -1 &&
+ options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES &&
+ (public = sc_get_key(sc_reader_num)) != NULL ) {
+ Key *new;
+
+ /* 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());
+ i = options.num_identity_files++;
+ options.identity_keys[i] = new;
+ options.identity_files[i] = 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());
+ i = options.num_identity_files++;
+ options.identity_keys[i] = new;
+ options.identity_files[i] = xstrdup("smartcard rsa1 key");;
+
+ key_free(public);