Saying that q
divides p-1
is the same as saying that p ≡ 1 mod q.
The FIPS
method essentially shifts and adds successive hash outputs to build a pseudorandom chunk of the correct size, and then subtracts a remainder such that p ≡ 1 mod 2q
, and finally tests for primality. The only 'real' entropy in the process is the random seed.
Note also that the old FIPS-186
above is 'hardcoded' for 160 bit q
If you have plenty of entropy you can just as easily get a chunk of random from a good source, set the top and bottom bits to 1, subtract ((p mod q)-1)
then test that for primality.