Galois theory and primality testing