summaryrefslogtreecommitdiffstats
path: root/scard-opensc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-06-28 10:02:47 +0200
committerDamien Miller <djm@mindrot.org>2003-06-28 10:02:47 +0200
commit4a8e2848556682541799118528fe3b56b901c5f7 (patch)
tree84a082af8c122a84b42d84eccedecfbbfb2fa558 /scard-opensc.c
parentAdd Roumen Petrov (diff)
downloadopenssh-4a8e2848556682541799118528fe3b56b901c5f7.tar.xz
openssh-4a8e2848556682541799118528fe3b56b901c5f7.zip
- (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)
return -1;
}
+char *
+sc_get_key_label(Key *key)
+{
+ int r;
+ const struct sc_priv_data *priv;
+ struct sc_pkcs15_object *key_obj;
+
+ priv = (const struct sc_priv_data *) RSA_get_app_data(key->rsa);
+ if (priv == NULL || p15card == NULL) {
+ logit("SmartCard key not loaded");
+ /* internal error => return default label */
+ return xstrdup("smartcard key");
+ }
+ r = sc_pkcs15_find_prkey_by_id(p15card, &priv->cert_id, &key_obj);
+ if (r) {
+ logit("Unable to find private key from SmartCard: %s",
+ sc_strerror(r));
+ return xstrdup("smartcard key");
+ }
+ if (key_obj == NULL || key_obj->label == NULL)
+ /* the optional PKCS#15 label does not exists
+ * => return the default label */
+ return xstrdup("smartcard key");
+ return xstrdup(key_obj->label);
+}
+
#endif /* SMARTCARD */