--- libtommath-0.41-orig/bn_mp_prime_next_prime.c 2007-03-11 08:45:11.000000000 +0900 +++ libtommath-0.41-orig/bn_mp_prime_next_prime.c 2010-07-15 22:46:54.000000000 +0900 @@ -143,7 +143,7 @@ /* is this prime? */ for (x = 0; x < t; x++) { - mp_set(&b, ltm_prime_tab[t]); + mp_set(&b, ltm_prime_tab[x]); if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) { goto LBL_ERR; }