|
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 */ |