memcpy(XVAL, rng->XKEY, BSIZE);
memcpy(XVAL, XKEY_old, BSIZE);
alg_fips186_2_cn_1(RNGContext *rng, const unsigned char *XSEEDj){    /* 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[2*GSIZE];    /* used by ADD_B_BIT macros */    int k, carry;    /* store the output of G(t, XVAL) in the rightmost GSIZE bytes */    PRUint8 w_i[BSIZE];    int i;    unsigned int len;    if (!rng->isValid) {	/* RNG has alread entered an invalid state. */	PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);	return SECFailure;    }#if GSIZE < BSIZE    /* zero the leftmost bytes so we can pass it to ADD_B_BIT_PLUS_CARRY */    memset(w_i, 0, BSIZE - GSIZE);#endif    /*      * <Step 2> Initialize t, taken care of in SHA-1 (same initial values)     *     * <Step 3.1> XSEEDj is optional user input     */     for (i = 0; i < 2; i++) {	/* 	 * <Step 3.2a> XVAL = (XKEY + XSEEDj) mod 2^b	 *     :always reduced mod 2^b, since storing as b-bit value	 */	if (XSEEDj) {	    /* XSEEDj > 0 */	    ADD_B_BIT_2(XVAL, rng->XKEY, XSEEDj);	} else {	    /* XSEEDj == 0 */	    memcpy(XVAL, rng->XKEY, BSIZE);	}	/* 	 * <Step 3.2b> Wi = G(t, XVAL)	 *     :FIPS 186-2 specifies a different padding than the SHA1 180-1	 *     :specification, this function is implemented in	 *     :RNG_UpdateAndEnd_FIPS186_2 below.	 */ 	SHA1_Begin(&sha1cx);	RNG_UpdateAndEnd_FIPS186_2(&sha1cx, XVAL, BSIZE,				   &w_i[BSIZE - GSIZE], &len, GSIZE);	/* 	 * <Step 3.2c> XKEY = (1 + XKEY + Wi) mod 2^b	 *     :always reduced mod 2^b, since storing as 160-bit value 	 */	ADD_B_BIT_PLUS_CARRY(rng->XKEY, rng->XKEY, w_i, 1);	/*	 * <Step 3.3> Xj = (W0 || W1)	 */	memcpy(&x_j[i*GSIZE], &w_i[BSIZE - GSIZE], GSIZE);    }    /*     [FIPS 140-2] verify output does not match previous output */    if (memcmp(x_j, rng->Xj, 2*GSIZE) == 0) {	/* failed FIPS 140-2 continuous RNG test.  RNG now invalid. */	rng->isValid = PR_FALSE;	PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);	return SECFailure;    }    /* Xj is the output */    memcpy(rng->Xj, x_j, 2*GSIZE);    /* Always have a full buffer after executing alg_cn_1() */    rng->avail = 2*GSIZE;    /* housekeeping */    memset(&w_i[BSIZE - GSIZE], 0, GSIZE);    memset(x_j, 0, 2*GSIZE);    memset(XVAL, 0, BSIZE);    return SECSuccess;}