avoid registering pkcs11 mechanisms multiple times

fixes #349
This commit is contained in:
Frank Morgner 2015-09-07 09:53:02 +02:00
parent 9456db90fc
commit d551f9a8e0
1 changed files with 9 additions and 4 deletions

View File

@ -282,10 +282,15 @@ pkcs15_bind(struct sc_pkcs11_card *p11card, struct sc_app_info *app_info)
return sc_to_cryptoki_error(rc, NULL);
}
ck_rv = register_mechanisms(p11card);
if (ck_rv != CKR_OK) {
sc_log(context, "cannot register mechanisms; CKR 0x%X", ck_rv);
return ck_rv;
/* Mechanisms are registered globally per card. Checking
* p11card->nmechanisms avoids registering the same mechanisms twice for a
* card with multiple slots. */
if (!p11card->nmechanisms) {
ck_rv = register_mechanisms(p11card);
if (ck_rv != CKR_OK) {
sc_log(context, "cannot register mechanisms; CKR 0x%X", ck_rv);
return ck_rv;
}
}
return CKR_OK;