Skip to content

Commit

Permalink
Traverse tokens like we do with OpenSSL for NSS
Browse files Browse the repository at this point in the history
When PKINIT is built with NSS, change how it traverses tokens to match
the way it's done when built using OpenSSL: ignore slot names (we used
to treat the token label as a possible slot label, too), and either only
look at the token with the specified label, or the first token if a no
token label was specified.
  • Loading branch information
nalind authored and greghudson committed May 10, 2013
1 parent b3efde6 commit 88fe4c4
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/plugins/preauth/pkinit/pkinit_crypto_nss.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ crypto_load_pkcs11(krb5_context context,
PK11SlotInfo *slot;
char *spec;
size_t spec_size;
const char *label, *id, *slotname, *tokenname;
const char *label, *id, *tokenname;
SECStatus status;
int i, j;

Expand Down Expand Up @@ -2166,28 +2166,27 @@ crypto_load_pkcs11(krb5_context context,
(i < module->module->slotCount) &&
((slot = module->module->slots[i]) != NULL);
i++) {
if (idopts->slotid != PK_NOSLOT) {
if (idopts->slotid != PK11_GetSlotID(slot))
continue;
}
tokenname = PK11_GetTokenName(slot);
if (tokenname == NULL || strlen(tokenname) == 0)
continue;
if (idopts->token_label != NULL) {
label = idopts->token_label;
slotname = PK11_GetSlotName(slot);
tokenname = PK11_GetTokenName(slot);
if ((slotname != NULL) && (tokenname != NULL)) {
if ((strcmp(label, slotname) != 0) &&
(strcmp(label, tokenname) != 0))
continue;
} else if (slotname != NULL) {
if (strcmp(label, slotname) != 0)
continue;
} else if (tokenname != NULL) {
if (strcmp(label, tokenname) != 0)
continue;
}
if (strcmp(idopts->cert_label, tokenname) != 0)
continue;
}
/* Load private keys and their certs from this slot. */
label = idopts->cert_label;
id = idopts->cert_id_string;
if (cert_load_certs_with_keys_from_slot(context, id_cryptoctx,
slot, label, id) == 0)
status = SECSuccess;
/* If no label was specified, then we've looked at a token, so we're
* done. */
if (idopts->token_label == NULL)
break;
}
return status;
}
Expand Down

0 comments on commit 88fe4c4

Please sign in to comment.