key = (DSAPrivateKey *)PORT_ArenaAlloc(arena, sizeof(DSAPrivateKey));
key = (DSAPrivateKey *)PORT_ArenaZAlloc(arena, sizeof(DSAPrivateKey));
dsa_NewKey(PQGParams *params, DSAPrivateKey **privKey, unsigned char *xb){    unsigned int y_len;    mp_int p, g;    mp_int x, y;    mp_err err;    PRArenaPool *arena;    DSAPrivateKey *key;    /* Check args. */    if (!params || !privKey || *privKey) {	PORT_SetError(SEC_ERROR_INVALID_ARGS);	return SECFailure;    }    /* Initialize an arena for the DSA key. */    arena = PORT_NewArena(NSS_FREEBL_DSA_DEFAULT_CHUNKSIZE);    if (!arena) {	PORT_SetError(SEC_ERROR_NO_MEMORY);	return SECFailure;    }    key = (DSAPrivateKey *)PORT_ArenaAlloc(arena, sizeof(DSAPrivateKey));    if (!key) {	PORT_SetError(SEC_ERROR_NO_MEMORY);	PORT_FreeArena(arena, PR_TRUE);	return SECFailure;    }    key->params.arena = arena;    /* Initialize MPI integers. */    MP_DIGITS(&p) = 0;    MP_DIGITS(&g) = 0;    MP_DIGITS(&x) = 0;    MP_DIGITS(&y) = 0;    CHECKOK( mp_init(&p) );    CHECKOK( mp_init(&g) );    CHECKOK( mp_init(&x) );    CHECKOK( mp_init(&y) );    /* Copy over the PQG params */    CHECKOK( SECITEM_CopyItem(arena, &key->params.prime, &params->prime) );    CHECKOK( SECITEM_CopyItem(arena, &key->params.subPrime, &params->subPrime));    CHECKOK( SECITEM_CopyItem(arena, &key->params.base, &params->base) );    /* Convert stored p, g, and received x into MPI integers. */    SECITEM_TO_MPINT(params->prime, &p);    SECITEM_TO_MPINT(params->base,  &g);    CHECKOK( mp_read_unsigned_octets(&x, xb, DSA_SUBPRIME_LEN) );    /* Store x in private key */    SECITEM_AllocItem(arena, &key->privateValue, DSA_SUBPRIME_LEN);    memcpy(key->privateValue.data, xb, DSA_SUBPRIME_LEN);    /* Compute public key y = g**x mod p */    CHECKOK( mp_exptmod(&g, &x, &p, &y) );    /* Store y in public key */    y_len = mp_unsigned_octet_size(&y);    SECITEM_AllocItem(arena, &key->publicValue, y_len);    err = mp_to_unsigned_octets(&y, key->publicValue.data, y_len);    /*   mp_to_unsigned_octets returns bytes written (y_len) if okay */    if (err < 0) goto cleanup; else err = MP_OKAY;    *privKey = key;    key = NULL;cleanup:    mp_clear(&p);    mp_clear(&g);    mp_clear(&x);    mp_clear(&y);    if (key)	PORT_FreeArena(key->params.arena, PR_TRUE);    if (err) {	translate_mpi_error(err);	return SECFailure;    }    return SECSuccess;}