*privKey =  PK11_MakePrivKey(*slotPtr, nullKey, PR_TRUE, keyHandle, wincx); if (*privKey == NULL) { PK11_FreeSlot(*slotPtr); *slotPtr = NULL; return NULL; } cert = PK11_MakeCertFromHandle(*slotPtr,certHandle,NULL); if (cert == NULL) { PK11_FreeSlot(*slotPtr); SECKEY_DestroyPrivateKey(*privKey); *slotPtr = NULL; *privKey = NULL; return NULL; }
PK11_FindCertAndKeyByRecipientList(PK11SlotInfo **slotPtr, 	SEC_PKCS7RecipientInfo **array, SEC_PKCS7RecipientInfo **rip,				SECKEYPrivateKey**privKey, void *wincx){    CK_OBJECT_HANDLE certHandle = CK_INVALID_HANDLE;    CK_OBJECT_HANDLE keyHandle = CK_INVALID_HANDLE;    CERTCertificate *cert = NULL;    SECStatus rv;    *privKey = NULL;    certHandle = pk11_AllFindCertObjectByRecipient(slotPtr,array,rip,wincx);    if (certHandle == CK_INVALID_HANDLE) {	return NULL;    }    rv = PK11_Authenticate(*slotPtr,PR_TRUE,wincx);    if (rv != SECSuccess) {	PK11_FreeSlot(*slotPtr);	*slotPtr = NULL;	return NULL;    }    keyHandle = PK11_MatchItem(*slotPtr,certHandle,CKO_PRIVATE_KEY);    if (keyHandle == CK_INVALID_HANDLE) { 	PK11_FreeSlot(*slotPtr);	*slotPtr = NULL;	return NULL;    }    *privKey =  PK11_MakePrivKey(*slotPtr, nullKey, PR_TRUE, keyHandle, wincx);    if (*privKey == NULL) {	PK11_FreeSlot(*slotPtr);	*slotPtr = NULL;	return NULL;    }    cert = PK11_MakeCertFromHandle(*slotPtr,certHandle,NULL);    if (cert == NULL) {	PK11_FreeSlot(*slotPtr);	SECKEY_DestroyPrivateKey(*privKey);	*slotPtr = NULL;	*privKey = NULL;	return NULL;    }    return cert;}