/* Get a random prime of length 'size' bits. This function also guarantees that x-1 is not a multiple of 65537.  */
static void rand_prime(mpz_t x, int size)
/* Get a random prime of length 'size' bits. This function also guarantees that x-1 is not a multiple of 65537.  */
static void rand_prime(mpz_t x, int size)
{
	for (;;) {
		mpz_urandomb(x, RNG, size - 1);
		mpz_setbit(x, 0);
		mpz_setbit(x, size - 1);
		if (mpz_probab_prime_p(x, 50)) {
			mpz_sub_ui(x, x, 1);
			if (mpz_divisible_ui_p(x, 65537)) {
				continue;
			}
			mpz_add_ui(x, x, 1);
			return;
		}
	}
}