context->param = SECITEM_DupItem(param);
if (param) { if (param->len > 0) { context->param = SECITEM_DupItem(param); } else { context->param = (SECItem *)&pk11_null_params; } } else { context->param = NULL; }
static PK11Context *pk11_CreateNewContextInSlot(CK_MECHANISM_TYPE type,     PK11SlotInfo *slot, CK_ATTRIBUTE_TYPE operation, PK11SymKey *symKey,							     SECItem *param){    CK_MECHANISM mech_info;    PK11Context *context;    SECStatus rv;	    PORT_Assert(slot != NULL);    if (!slot) {	PORT_SetError(SEC_ERROR_INVALID_ARGS);	return NULL;    }    context = (PK11Context *) PORT_Alloc(sizeof(PK11Context));    if (context == NULL) {	return NULL;    }    /* now deal with the fortezza hack... the fortezza hack is an attempt     * to get around the issue of the card not allowing you to do a FORTEZZA     * LoadIV/Encrypt, which was added because such a combination could be     * use to circumvent the key escrow system. Unfortunately SSL needs to     * do this kind of operation, so in SSL we do a loadIV (to verify it),     * Then GenerateIV, and through away the first 8 bytes on either side     * of the connection.*/    context->fortezzaHack = PR_FALSE;    if (type == CKM_SKIPJACK_CBC64) {	if (symKey->origin == PK11_OriginFortezzaHack) {	    context->fortezzaHack = PR_TRUE;	}    }    /* initialize the critical fields of the context */    context->operation = operation;    context->key = symKey ? PK11_ReferenceSymKey(symKey) : NULL;    context->slot = PK11_ReferenceSlot(slot);    if (symKey && symKey->sessionOwner) {	/* The symkey owns a session.  Adopt that session. */	context->session = symKey->session;	context->ownSession = symKey->sessionOwner;	symKey->sessionOwner = PR_FALSE;    } else {	context->session = pk11_GetNewSession(slot, &context->ownSession);    }    context->cx = symKey ? symKey->cx : NULL;    /* get our session */    context->savedData = NULL;    /* save the parameters so that some digesting stuff can do multiple     * begins on a single context */    context->type = type;    context->param = SECITEM_DupItem(param);    context->init = PR_FALSE;    context->sessionLock = PZ_NewLock(nssILockPK11cxt);    if ((context->param == NULL) || (context->sessionLock == NULL)) {	PK11_DestroyContext(context,PR_TRUE);	return NULL;    }    mech_info.mechanism = type;    mech_info.pParameter = param->data;    mech_info.ulParameterLen = param->len;    PK11_EnterContextMonitor(context);    rv = pk11_context_init(context,&mech_info);    PK11_ExitContextMonitor(context);    if (rv != SECSuccess) {	PK11_DestroyContext(context,PR_TRUE);	return NULL;    }    context->init = PR_TRUE;    return context;}