Update NSS to 3.48 while keeping vc2013 hackfix and no-sslkeylogfile intact.

This commit is contained in:
Roy Tam 2020-01-03 13:36:26 +08:00
commit 171849c8e5
351 changed files with 115185 additions and 57946 deletions

View file

@ -357,7 +357,9 @@ PK11_SymKeyFromHandle(PK11SlotInfo *slot, PK11SymKey *parent, PK11Origin origin,
}
/*
* turn key handle into an appropriate key object
* Restore a symmetric wrapping key that was saved using PK11_SetWrapKey.
*
* This function is provided for ABI compatibility; see PK11_SetWrapKey below.
*/
PK11SymKey *
PK11_GetWrapKey(PK11SlotInfo *slot, int wrap, CK_MECHANISM_TYPE type,
@ -365,33 +367,51 @@ PK11_GetWrapKey(PK11SlotInfo *slot, int wrap, CK_MECHANISM_TYPE type,
{
PK11SymKey *symKey = NULL;
if (slot->series != series)
PK11_EnterSlotMonitor(slot);
if (slot->series != series ||
slot->refKeys[wrap] == CK_INVALID_HANDLE) {
PK11_ExitSlotMonitor(slot);
return NULL;
if (slot->refKeys[wrap] == CK_INVALID_HANDLE)
return NULL;
if (type == CKM_INVALID_MECHANISM)
}
if (type == CKM_INVALID_MECHANISM) {
type = slot->wrapMechanism;
}
symKey = PK11_SymKeyFromHandle(slot, NULL, PK11_OriginDerive,
slot->wrapMechanism, slot->refKeys[wrap], PR_FALSE, wincx);
PK11_ExitSlotMonitor(slot);
return symKey;
}
/*
* This function is not thread-safe because it sets wrapKey->sessionOwner
* without using a lock or atomic routine. It can only be called when
* only one thread has a reference to wrapKey.
* This function sets an attribute on the current slot with a wrapping key. The
* data saved is ephemeral; it needs to be run every time the program is
* invoked.
*
* Since NSS 3.45, this function is marginally more thread safe. It uses the
* slot lock (if present) and fails silently if a value is already set. Use
* PK11_GetWrapKey() after calling this function to get the current wrapping key
* in case there was an update on another thread.
*
* Either way, using this function is inadvisable. It's provided for ABI
* compatibility only.
*/
void
PK11_SetWrapKey(PK11SlotInfo *slot, int wrap, PK11SymKey *wrapKey)
{
/* save the handle and mechanism for the wrapping key */
/* mark the key and session as not owned by us to they don't get freed
* when the key goes way... that lets us reuse the key later */
slot->refKeys[wrap] = wrapKey->objectID;
wrapKey->owner = PR_FALSE;
wrapKey->sessionOwner = PR_FALSE;
slot->wrapMechanism = wrapKey->type;
PK11_EnterSlotMonitor(slot);
if (wrap < PR_ARRAY_SIZE(slot->refKeys) &&
slot->refKeys[wrap] == CK_INVALID_HANDLE) {
/* save the handle and mechanism for the wrapping key */
/* mark the key and session as not owned by us so they don't get freed
* when the key goes way... that lets us reuse the key later */
slot->refKeys[wrap] = wrapKey->objectID;
wrapKey->owner = PR_FALSE;
wrapKey->sessionOwner = PR_FALSE;
slot->wrapMechanism = wrapKey->type;
}
PK11_ExitSlotMonitor(slot);
}
/*
@ -610,7 +630,7 @@ PK11_GetWindow(PK11SymKey *key)
}
/*
* extract a symetric key value. NOTE: if the key is sensitive, we will
* extract a symmetric key value. NOTE: if the key is sensitive, we will
* not be able to do this operation. This function is used to move
* keys from one token to another */
SECStatus
@ -618,6 +638,11 @@ PK11_ExtractKeyValue(PK11SymKey *symKey)
{
SECStatus rv;
if (symKey == NULL) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}
if (symKey->data.data != NULL) {
if (symKey->size == 0) {
symKey->size = symKey->data.len;