pbe_params = (CK_PBE_PARAMS *)pMechanism->pParameter;
nsc_SetupHMACKeyGen(CK_MECHANISM_PTR pMechanism, NSSPKCS5PBEParameter **pbe){    SECItem  salt;    CK_PBE_PARAMS *pbe_params = NULL;    NSSPKCS5PBEParameter *params;    PRArenaPool *arena = NULL;    SECStatus rv;    *pbe = NULL;    arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE);    if (arena == NULL) {	return CKR_HOST_MEMORY;    }    params = (NSSPKCS5PBEParameter *) PORT_ArenaZAlloc(arena,				sizeof(NSSPKCS5PBEParameter));    if (params == NULL) {	PORT_FreeArena(arena,PR_TRUE);	return CKR_HOST_MEMORY;    }    params->ivLen = 0;    params->pbeType = NSSPKCS5_PKCS12_V2;    params->hashType = HASH_AlgSHA1;    params->encAlg = SEC_OID_SHA1; /* any invalid value */    params->is2KeyDES = PR_FALSE;    params->keyID = pbeBitGenIntegrityKey;    params->iter = pbe_params->ulIteration;    pbe_params = (CK_PBE_PARAMS *)pMechanism->pParameter;    salt.data = (unsigned char *)pbe_params->pSalt;    salt.len = (unsigned int)pbe_params->ulSaltLen;    rv = SECITEM_CopyItem(arena,&params->salt,&salt);    if (rv != SECSuccess) {	PORT_FreeArena(arena,PR_TRUE);	return CKR_HOST_MEMORY;    }    switch (pMechanism->mechanism) {    case CKM_NETSCAPE_PBE_SHA1_HMAC_KEY_GEN:    case CKM_PBA_SHA1_WITH_SHA1_HMAC:	params->hashType = HASH_AlgSHA1; 	params->keyLen = 20;	break;    case CKM_NETSCAPE_PBE_MD5_HMAC_KEY_GEN:	params->hashType = HASH_AlgMD5; 	params->keyLen = 16;	break;    case CKM_NETSCAPE_PBE_MD2_HMAC_KEY_GEN:	params->hashType = HASH_AlgMD2; 	params->keyLen = 16;	break;    default:	PORT_FreeArena(arena,PR_TRUE);	return CKR_MECHANISM_INVALID;    }    *pbe = params;    return CKR_OK;}