CHECK_MPI_OK( mp_set_int(&tmp, addend) );
CHECK_MPI_OK( mp_set_ulong(&tmp, addend) );
addToSeedThenSHA(const SECItem * seed,                 unsigned long   addend,                 int             g,                 unsigned char * shaOutBuf){    SECItem str = { 0, 0, 0 };    mp_int s, sum, modulus, tmp;    mp_err    err = MP_OKAY;    SECStatus rv  = SECSuccess;    MP_DIGITS(&s)       = 0;    MP_DIGITS(&sum)     = 0;    MP_DIGITS(&modulus) = 0;    MP_DIGITS(&tmp)     = 0;    CHECK_MPI_OK( mp_init(&s) );    CHECK_MPI_OK( mp_init(&sum) );    CHECK_MPI_OK( mp_init(&modulus) );    SECITEM_TO_MPINT(*seed, &s); /* s = seed */    /* seed += addend */    if (addend < MP_DIGIT_MAX) {	CHECK_MPI_OK( mp_add_d(&s, (mp_digit)addend, &s) );    } else {	CHECK_MPI_OK( mp_init(&tmp) );	CHECK_MPI_OK( mp_set_int(&tmp, addend) ); /* XXX needs to be ulong! */	CHECK_MPI_OK( mp_add(&s, &tmp, &s) );    }    CHECK_MPI_OK( mp_div_2d(&s, (mp_digit)g, NULL, &sum) );/*sum = s mod 2**g */    MPINT_TO_SECITEM(&sum, &str, NULL);    rv = SHA1_HashBuf(shaOutBuf, str.data, str.len); /* SHA1 hash result */cleanup:    mp_clear(&s);    mp_clear(&sum);    mp_clear(&modulus);    mp_clear(&tmp);    if (str.data)	SECITEM_ZfreeItem(&str, PR_FALSE);    if (err) {	MP_TO_SEC_ERROR(err);	return SECFailure;    }    return rv;}