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(const 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(const Key *key)
560
{
561
	return NULL;
562
}
563
557
#endif /* SMARTCARD && USE_SECTOK */
564
#endif /* SMARTCARD && USE_SECTOK */
(-)scard.h (+6 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
/* sc_get_key_label returns the label of the private key
40
 * (if existing) and NULL otherwise. In case of scard-opensc.c
41
 * this functions returns the content of the optional PKCS#15
42
 * label field of the CommonObjectAttributes.
43
 */
44
char    *sc_get_key_label(const Key *);
39
45
40
#endif
46
#endif
(-)ssh-agent.c (-1 / +5 lines)
Lines 602-608 Link Here
602
		if (lookup_identity(k, version) == NULL) {
602
		if (lookup_identity(k, version) == NULL) {
603
			id = xmalloc(sizeof(Identity));
603
			id = xmalloc(sizeof(Identity));
604
			id->key = k;
604
			id->key = k;
605
			id->comment = xstrdup("smartcard key");
605
			id->comment = sc_get_key_label(k);
606
			if (id->comment == NULL)
607
				/* no key label available, therefore use
608
				 * standard smartcard key label (comment) */
609
				id->comment = xstrdup("smartcard key");
606
			id->death = 0;
610
			id->death = 0;
607
			id->confirm = 0;
611
			id->confirm = 0;
608
			TAILQ_INSERT_TAIL(&tab->idlist, id, next);
612
			TAILQ_INSERT_TAIL(&tab->idlist, id, next);

Return to bug 591