Fix error propagatation in BN_check_prime()
authorKazuki Yamaguchi <k@rhe.jp>
Fri, 30 Sep 2022 11:33:08 +0000 (20:33 +0900)
committerPauli <pauli@openssl.org>
Tue, 4 Oct 2022 08:06:11 +0000 (19:06 +1100)
commit9ab1c7612ccadba86949c5ebbf4ecc9f32432af7
tree2a5305299c2176dab35d3c09bb5880ef3d33ecc9
parent8447b5680c2211ad359346fb2f02a5830efc8c5e
Fix error propagatation in BN_check_prime()

BN_check_prime() is supposed to return 0 for a composite number and -1
on error. Properly translate the return value of the internal function
ossl_bn_miller_rabin_is_prime(), where 0 means an error.

The confusion prevented BN_GENCB callbacks from aborting the primality
test or key generation routines utilizing this.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19314)

(cherry picked from commit 0b3867634f74f6cb7b60b3a0adde396421207214)
crypto/bn/bn_prime.c