prime: Avoid rare assertion failure in gcry_prime_check.
authorWerner Koch <wk@gnupg.org>
Sat, 28 Apr 2018 16:30:53 +0000 (18:30 +0200)
committerWerner Koch <wk@gnupg.org>
Sat, 28 Apr 2018 16:32:26 +0000 (18:32 +0200)
commitf3362f10f6f671246c38115ed12b0047966c200e
treeafdb259b4dac591d7df25496bedc4b1edd313cf4
parente7ae0ae243c8978a67c802169183187d88557be8
prime: Avoid rare assertion failure in gcry_prime_check.

* cipher/primegen.c (is_prime): Don't fail on the assert X > 1.
--

When using gcry_prime_check the function is_prime can be called with
quite small candidates so there is a real chance that the random X
values is indeed 0 or 1.  This would trigger the assert.  To avoid
this we now retry in this case.

Reported-by: Heiko Stamer
Signed-off-by: Werner Koch <wk@gnupg.org>
cipher/primegen.c