memset(&sha1cx, 0, sizeof(sha1cx));
alg_fips186_1_x3_1(RNGContext *rng,                   const unsigned char *XSEEDj, unsigned char *q){    /* SHA1 context for G(t, XVAL) function */    SHA1Context sha1cx;    /* input to hash function */    PRUint8 XVAL[BSIZE];    /* store a copy of the output to compare with the previous output */    PRUint8 x_j[BSIZE];    /* used by ADD_160BIT macros */    int i, carry;    unsigned int len;    if (!rng->isValid) {	/* RNG has alread entered an invalid state. */	PORT_SetError(SEC_ERROR_INVALID_ARGS);	return SECFailure;    }    /* initialize the SHA1 context */    memset(&sha1cx, 0, sizeof(sha1cx));    /*      * <Step 2> Initialize t, taken care of in SHA-1 (same initial values)      */    SHA1_Begin(&sha1cx);    /*      * <Step 3a> XSEEDj is optional user input     *      * <Step 3b> XVAL = (XKEY + XSEEDj) mod 2^b     *     :always reduced mod 2^b, since storing as 160-bit value     */    if (XSEEDj) {	/* XSEEDj > 0 */	ADD_160BIT_2(XVAL, rng->XKEY, XSEEDj);    } else {	/* XSEEDj == 0 */	memcpy(XVAL, rng->XKEY, BSIZE);    }    /*      * <Step 3c> Xj = G(t, XVAL) mod q     *     :In this code, (mod q) is only understood for DSA ops,      *     :not general RNG (what would q be in non-DSA uses?).     *     :If a q is specified, use it.     *     :FIPS 186-1 specifies a different padding than the SHA1 180-1     *     :specification, this function is implemented below.     */     RNG_UpdateAndEnd_FIPS186_1(&sha1cx, XVAL, BSIZE, x_j, &len, BSIZE);    if (q != NULL) {	dsa_reduce_mod_q(x_j, q);    }    /*     [FIPS 140-1] verify output does not match previous output */    if (memcmp(x_j, rng->Xj, BSIZE) == 0) {	/* failed FIPS 140-1 continuous RNG condition.  RNG now invalid. */	rng->isValid = PR_FALSE;	return SECFailure;    }    /* Xj is the output */    memcpy(rng->Xj, x_j, BSIZE);    /*      * <Step 3d> XKEY = (1 + XKEY + Xj) mod 2^b     *     :always reduced mod 2^b, since storing as 160-bit value      */    ADD_160BIT_PLUS_CARRY(rng->XKEY, rng->XKEY, x_j, 1);    /* Always have a full buffer after executing alg3_1() */    rng->avail = BSIZE;    /* housekeeping */    memset(x_j, 0, BSIZE);    memset(XVAL, 0, BSIZE);    return SECSuccess;}