View | Details | Raw Unified | Return to bug 591 | Differences between
and this patch

Collapse All | Expand All

(-)scard-opensc.c (+24 lines)
Lines 474-477 Link Here
474
	return -1;
474
	return -1;
475
}
475
}
476
476
477
char *
478
sc_get_key_label(Key *key)
479
{
480
	int r;
481
	const struct sc_priv_data *priv;
482
	struct sc_pkcs15_object *key_obj;
483
484
	priv = (const struct sc_priv_data *) RSA_get_app_data(key->rsa);
485
	if (priv == NULL || p15card == NULL) {
486
		logit("SmartCard key not loaded");
487
		return NULL;
488
	}
489
	r = sc_pkcs15_find_prkey_by_id(p15card, &priv->cert_id, &key_obj);
490
	if (r) {
491
		logit("Unable to find private key from SmartCard: %s",
492
		      sc_strerror(r));
493
		return NULL;
494
	}
495
	if (key_obj == NULL || key_obj->label == NULL)
496
		/* the optional PKCS#15 label does not exists */
497
		return NULL;
498
	return xstrdup(key_obj->label);
499
}
500
477
#endif /* SMARTCARD */
501
#endif /* SMARTCARD */
(-)scard.c (+7 lines)
Lines 554-557 Link Here
554
		sectok_close(fd);
554
		sectok_close(fd);
555
	return (status);
555
	return (status);
556
}
556
}
557
558
char *
559
sc_get_key_label(Key *key)
560
{
561
	return xstrdup("smartcard key");
562
}
563
557
#endif /* SMARTCARD && USE_SECTOK */
564
#endif /* SMARTCARD && USE_SECTOK */
(-)scard.h (+1 lines)
Lines 36-40 Link Here
36
Key	**sc_get_keys(const char *, const char *);
36
Key	**sc_get_keys(const char *, const char *);
37
void	 sc_close(void);
37
void	 sc_close(void);
38
int	 sc_put_key(Key *, const char *);
38
int	 sc_put_key(Key *, const char *);
39
char	*sc_get_key_label(Key *);
39
40
40
#endif
41
#endif
(-)ssh-agent.c (-1 / +1 lines)
Lines 618-624 Link Here
618
		if (lookup_identity(k, version) == NULL) {
618
		if (lookup_identity(k, version) == NULL) {
619
			id = xmalloc(sizeof(Identity));
619
			id = xmalloc(sizeof(Identity));
620
			id->key = k;
620
			id->key = k;
621
			id->comment = xstrdup("smartcard key");
621
			id->comment = sc_get_key_label(k);
622
			id->death = death;
622
			id->death = death;
623
			id->confirm = confirm;
623
			id->confirm = confirm;
624
			TAILQ_INSERT_TAIL(&tab->idlist, id, next);
624
			TAILQ_INSERT_TAIL(&tab->idlist, id, next);
(-)ssh.c (-1 / +1 lines)
Lines 1180-1186 Link Here
1180
			    sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1));
1180
			    sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1));
1181
			options.num_identity_files++;
1181
			options.num_identity_files++;
1182
			options.identity_keys[0] = keys[i];
1182
			options.identity_keys[0] = keys[i];
1183
			options.identity_files[0] = xstrdup("smartcard key");;
1183
			options.identity_files[0] = sc_get_key_label(keys[i]);
1184
		}
1184
		}
1185
		if (options.num_identity_files > SSH_MAX_IDENTITY_FILES)
1185
		if (options.num_identity_files > SSH_MAX_IDENTITY_FILES)
1186
			options.num_identity_files = SSH_MAX_IDENTITY_FILES;
1186
			options.num_identity_files = SSH_MAX_IDENTITY_FILES;

Return to bug 591