int bn_probable_prime_dh_retry(BIGNUM *rnd, int bits, BN_CTX *ctx)
	{
	int i;
	BIGNUM *t1;
	int ret = 0;

	BN_CTX_start(ctx);
	if ((t1 = BN_CTX_get(ctx)) == NULL) goto err;

loop:
	if (!BN_rand(rnd, bits, 0, 1)) goto err;

	/* we now have a random number 'rand' to test. */

	for (i = 1; i < NUMPRIMES; i++)
		{
		/* check that rnd is a prime */
		if (BN_mod_word(rnd, (BN_ULONG)primes[i]) <= 1)
			{
			/*if (!BN_add(rnd, rnd, add)) goto err;*/
			goto loop;
			}
		}
	ret=1;

err:
	BN_CTX_end(ctx);
	bn_check_top(rnd);
	return(ret);
	}