diff --git a/security/nss/lib/pk11wrap/pk11load.c b/security/nss/lib/pk11wrap/pk11load.c index f1855058621e..d0d305eb4ddc 100644 --- a/security/nss/lib/pk11wrap/pk11load.c +++ b/security/nss/lib/pk11wrap/pk11load.c @@ -336,6 +336,7 @@ SECMOD_LoadPKCS11Module(SECMODModule *mod) { mod->isThreadSafe = PR_FALSE; } } + mod->cryptokiVersion = info.cryptokiVersion; /* If we don't have a common name, get it from the PKCS 11 module */ if ((mod->commonName == NULL) || (mod->commonName[0] == 0)) { diff --git a/security/nss/lib/pk11wrap/pk11util.c b/security/nss/lib/pk11wrap/pk11util.c index 8c017ac86d38..3e1377c581b2 100644 --- a/security/nss/lib/pk11wrap/pk11util.c +++ b/security/nss/lib/pk11wrap/pk11util.c @@ -859,7 +859,7 @@ SECMOD_UpdateSlotList(SECMODModule *mod) { CK_RV crv; CK_ULONG count; - int i, oldCount; + CK_ULONG i, oldCount; PRBool freeRef = PR_FALSE; void *mark = NULL; CK_ULONG *slotIDs = NULL; @@ -882,7 +882,7 @@ SECMOD_UpdateSlotList(SECMODModule *mod) PZ_Unlock(mod->refLock); return SECSuccess; } - if (count < mod->slotCount) { + if (count < (CK_ULONG)mod->slotCount) { /* shouldn't happen with a properly functioning PKCS #11 module */ PORT_SetError( SEC_ERROR_INCOMPATIBLE_PKCS11 ); goto loser; @@ -1060,9 +1060,13 @@ SECMOD_WaitForAnyTokenEvent(SECMODModule *mod, unsigned long flags, CK_RV crv; PK11SlotInfo *slot; - if (!pk11_getFinalizeModulesOption()) { + if (!pk11_getFinalizeModulesOption() || + ((mod->cryptokiVersion.major == 2) && + (mod->cryptokiVersion.minor < 1))) { /* if we are sharing the module with other software in our - * address space, we can't reliably use C_WaitForSlotEvent() */ + * address space, we can't reliably use C_WaitForSlotEvent(), + * and if the module is version 2.0, C_WaitForSlotEvent() doesn't + * exist */ return secmod_HandleWaitForSlotEvent(mod, flags, latency); } /* first the the PKCS #11 call */ diff --git a/security/nss/lib/pk11wrap/secmodt.h b/security/nss/lib/pk11wrap/secmodt.h index 73d14f726d8f..9114ce1f8e5b 100644 --- a/security/nss/lib/pk11wrap/secmodt.h +++ b/security/nss/lib/pk11wrap/secmodt.h @@ -40,6 +40,7 @@ #include "nssilckt.h" #include "secoid.h" #include "secasn1.h" +#include "pkcs11t.h" /* find a better home for these... */ extern const SEC_ASN1Template SECKEY_PointerToEncryptedPrivateKeyInfoTemplate[]; @@ -97,6 +98,7 @@ struct SECMODModuleStr { int cipherOrder; /* order for cipher operations */ unsigned long evControlMask; /* control the running and shutdown of slot * events (SECMOD_WaitForAnyTokenEvent) */ + CK_VERSION cryptokiVersion; /* version of this library */ }; /* evControlMask flags */