DH key generation should not use a do ... while loop,