summaryrefslogtreecommitdiff
path: root/scard-opensc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-06-28 18:02:47 +1000
committerDamien Miller <djm@mindrot.org>2003-06-28 18:02:47 +1000
commit4a8e2848556682541799118528fe3b56b901c5f7 (patch)
tree84a082af8c122a84b42d84eccedecfbbfb2fa558 /scard-opensc.c
parentf4f36f30f56b0dca3a31666ca4c61d6def427bf0 (diff)
- (djm) Bug #591: use PKCS#15 private key label as a comment in case
of OpenSC. Report and patch from larsch@trustcenter.de
Diffstat (limited to 'scard-opensc.c')
-rw-r--r--scard-opensc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/scard-opensc.c b/scard-opensc.c
index 9766d46cc..e8e12dd85 100644
--- a/scard-opensc.c
+++ b/scard-opensc.c
@@ -474,4 +474,30 @@ sc_put_key(Key *prv, const char *id)
474 return -1; 474 return -1;
475} 475}
476 476
477char *
478sc_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 /* internal error => return default label */
488 return xstrdup("smartcard key");
489 }
490 r = sc_pkcs15_find_prkey_by_id(p15card, &priv->cert_id, &key_obj);
491 if (r) {
492 logit("Unable to find private key from SmartCard: %s",
493 sc_strerror(r));
494 return xstrdup("smartcard key");
495 }
496 if (key_obj == NULL || key_obj->label == NULL)
497 /* the optional PKCS#15 label does not exists
498 * => return the default label */
499 return xstrdup("smartcard key");
500 return xstrdup(key_obj->label);
501}
502
477#endif /* SMARTCARD */ 503#endif /* SMARTCARD */