summaryrefslogtreecommitdiff
path: root/scard-opensc.c
diff options
context:
space:
mode:
Diffstat (limited to 'scard-opensc.c')
-rw-r--r--scard-opensc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/scard-opensc.c b/scard-opensc.c
index c670428a1..9766d46cc 100644
--- a/scard-opensc.c
+++ b/scard-opensc.c
@@ -135,7 +135,11 @@ sc_prkey_op_init(RSA *rsa, struct sc_pkcs15_object **key_obj_out)
135 &pin_obj); 135 &pin_obj);
136 if (r == SC_ERROR_OBJECT_NOT_FOUND) { 136 if (r == SC_ERROR_OBJECT_NOT_FOUND) {
137 /* no pin required */ 137 /* no pin required */
138 sc_lock(card); 138 r = sc_lock(card);
139 if (r) {
140 error("Unable to lock smartcard: %s", sc_strerror(r));
141 goto err;
142 }
139 *key_obj_out = key_obj; 143 *key_obj_out = key_obj;
140 return 0; 144 return 0;
141 } else if (r) { 145 } else if (r) {
@@ -429,9 +433,14 @@ sc_get_keys(const char *id, const char *pin)
429 } 433 }
430 key_count = r; 434 key_count = r;
431 } 435 }
432 /* FIXME: only keep entries with a corresponding private key */
433 keys = xmalloc(sizeof(Key *) * (key_count*2+1)); 436 keys = xmalloc(sizeof(Key *) * (key_count*2+1));
434 for (i = 0; i < key_count; i++) { 437 for (i = 0; i < key_count; i++) {
438 sc_pkcs15_object_t *tmp_obj = NULL;
439 cert_id = ((sc_pkcs15_cert_info_t *)(certs[i]->data))->id;
440 if (sc_pkcs15_find_prkey_by_id(p15card, &cert_id, &tmp_obj))
441 /* skip the public key (certificate) if no
442 * corresponding private key is present */
443 continue;
435 k = key_new(KEY_RSA); 444 k = key_new(KEY_RSA);
436 if (k == NULL) 445 if (k == NULL)
437 break; 446 break;