Bug 239827: Fix race condition in unwrap private key (if target key is symetric).

This commit is contained in:
relyea%netscape.com 2004-04-07 01:18:46 +00:00
parent dddea47d2b
commit 66be1e00e1

View File

@ -5370,9 +5370,12 @@ PK11_UnwrapPrivKey(PK11SlotInfo *slot, PK11SymKey *wrappingKey,
if (newKey) {
if (perm) {
/* Get RW Session will either lock the monitor if necessary,
* or return a thread safe session handle. */
rwsession = PK11_GetRWSession(slot);
} else {
rwsession = slot->session;
PK11_EnterSlotMonitor(slot);
}
crv = PK11_GETTAB(slot)->C_UnwrapKey(rwsession, &mechanism,
newKey->objectID,
@ -5380,7 +5383,11 @@ PK11_UnwrapPrivKey(PK11SlotInfo *slot, PK11SymKey *wrappingKey,
wrappedKey->len, keyTemplate,
templateCount, &privKeyID);
if (perm) PK11_RestoreROSession(slot, rwsession);
if (perm) {
PK11_RestoreROSession(slot, rwsession);
} else {
PK11_ExitSlotMonitor(slot);
}
PK11_FreeSymKey(newKey);
} else {
crv = CKR_FUNCTION_NOT_SUPPORTED;