dsaparams = &default_pqg_params;
dsaparena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); if (dsaparena == NULL) return NULL; dsaparams = PORT_ArenaZAlloc(dsaparena, sizeof(PQGParams)); if (params == NULL) return NULL; dsaparams->arena = dsaparena; SECITEM_AllocItem(dsaparena, &dsaparams->prime, sizeof P); SECITEM_AllocItem(dsaparena, &dsaparams->subPrime, sizeof Q); SECITEM_AllocItem(dsaparena, &dsaparams->base, sizeof G); PORT_Memcpy(dsaparams->prime.data, P, dsaparams->prime.len); PORT_Memcpy(dsaparams->subPrime.data, Q, dsaparams->subPrime.len); PORT_Memcpy(dsaparams->base.data, G, dsaparams->base.len);
CERTUTIL_GeneratePrivateKey(KeyType keytype, PK11SlotInfo *slot, int size,			    int publicExponent, char *noise, 			    SECKEYPublicKey **pubkeyp, char *pqgFile,                            char *passFile){    CK_MECHANISM_TYPE mechanism;    SECOidTag algtag;    PK11RSAGenParams rsaparams;    PQGParams *dsaparams = NULL;    void *params;    secuPWData pwdata = { PW_NONE, 0 };    /*     * Do some random-number initialization.     */    RNG_SystemInfoForRNG();    if (noise) {    	RNG_FileForRNG(noise);    } else {	int rv = UpdateRNG();	if (rv) {	    PORT_SetError(PR_END_OF_FILE_ERROR);	    return NULL;	}    }    switch (keytype) {      case rsaKey:	rsaparams.keySizeInBits = size;	rsaparams.pe = publicExponent;	mechanism = CKM_RSA_PKCS_KEY_PAIR_GEN;	algtag = SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION;	params = &rsaparams;	break;      case dsaKey:	mechanism = CKM_DSA_KEY_PAIR_GEN;	algtag = SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST;	if (pqgFile) {	    dsaparams = getpqgfromfile(size, pqgFile);	} else {	    dsaparams = &default_pqg_params;	}	params = dsaparams;	break;      default:	return NULL;    }    if (slot == NULL)	return NULL;    if (passFile) {	pwdata.source = PW_FROMFILE;	pwdata.data = passFile;    }    if (PK11_Authenticate(slot, PR_TRUE, &pwdata) != SECSuccess)	return NULL;    fprintf(stderr, "\n\n");    fprintf(stderr, "Generating key.  This may take a few moments...\n\n");    return PK11_GenerateKeyPair(slot, mechanism, params, pubkeyp,				PR_TRUE /*isPerm*/, PR_TRUE /*isSensitive*/, 				&pwdata /*wincx*/);}