PK11SlotInfo *slot;
PK11_PubEncryptRaw(SECKEYPublicKey *key, unsigned char *enc,		unsigned char *data, unsigned dataLen, void *wincx){    PK11SlotInfo *slot;    CK_MECHANISM mech = {CKM_RSA_X_509, NULL, 0 };    CK_OBJECT_HANDLE id;    CK_ULONG out = dataLen;    PRBool owner = PR_TRUE;    CK_SESSION_HANDLE session;    CK_RV crv;    if (key->keyType != rsaKey) {	PORT_SetError( SEC_ERROR_BAD_KEY );	return SECFailure;    }    slot = PK11_GetBestSlot(mech.mechanism, wincx);    if (slot == NULL) {	PORT_SetError( SEC_ERROR_NO_MODULE );	return SECFailure;    }    id = PK11_ImportPublicKey(slot,key,PR_FALSE);    session = pk11_GetNewSession(slot,&owner);    if (!owner || !(slot->isThreadSafe)) PK11_EnterSlotMonitor(slot);    crv = PK11_GETTAB(slot)->C_EncryptInit(session,&mech,id);    if (crv != CKR_OK) {	if (!owner || !(slot->isThreadSafe)) PK11_ExitSlotMonitor(slot);	pk11_CloseSession(slot,session,owner);	PK11_FreeSlot(slot);	PORT_SetError( PK11_MapError(crv) );	return SECFailure;    }    crv = PK11_GETTAB(slot)->C_Encrypt(session,data,dataLen,enc,&out);    if (!owner || !(slot->isThreadSafe)) PK11_ExitSlotMonitor(slot);    pk11_CloseSession(slot,session,owner);    PK11_FreeSlot(slot);    if (crv != CKR_OK) {	PORT_SetError( PK11_MapError(crv) );	return SECFailure;    }    return SECSuccess;}