if (!PK11_HasAttributeSet(slot,key->pkcs11ID,CKA_PRIVATE)) {
if (SECKEY_HAS_ATTRIBUTE_SET(key,CKA_PRIVATE)) {
PK11_Sign(SECKEYPrivateKey *key, SECItem *sig, SECItem *hash){    PK11SlotInfo *slot = key->pkcs11Slot;    CK_MECHANISM mech = {0, NULL, 0 };    PRBool owner = PR_TRUE;    CK_SESSION_HANDLE session;    CK_ULONG len;    CK_RV crv;    mech.mechanism = pk11_mapSignKeyType(key->keyType);    if (!PK11_HasAttributeSet(slot,key->pkcs11ID,CKA_PRIVATE)) {	PK11_HandlePasswordCheck(slot, key->wincx);    }    session = pk11_GetNewSession(slot,&owner);    if (!owner || !(slot->isThreadSafe)) PK11_EnterSlotMonitor(slot);    crv = PK11_GETTAB(slot)->C_SignInit(session,&mech,key->pkcs11ID);    if (crv != CKR_OK) {	if (!owner || !(slot->isThreadSafe)) PK11_ExitSlotMonitor(slot);	pk11_CloseSession(slot,session,owner);	PORT_SetError( PK11_MapError(crv) );	return SECFailure;    }    len = sig->len;    crv = PK11_GETTAB(slot)->C_Sign(session,hash->data,					hash->len, sig->data, &len);    if (!owner || !(slot->isThreadSafe)) PK11_ExitSlotMonitor(slot);    pk11_CloseSession(slot,session,owner);    sig->len = len;    if (crv != CKR_OK) {	PORT_SetError( PK11_MapError(crv) );	return SECFailure;    }    return SECSuccess;}