Fix multiple wrong use of BN_check_prime

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25811)
This commit is contained in:
Peiwei Hu 2024-10-27 17:37:48 +08:00 committed by Tomas Mraz
parent 1273fae170
commit b2b995ec2d
2 changed files with 7 additions and 3 deletions

View File

@ -145,10 +145,14 @@ opthelp:
}
BN_print(bio_out, bn);
r = BN_check_prime(bn, NULL, NULL);
if (r < 0) {
BIO_printf(bio_err, "Error checking prime\n");
goto end;
}
BIO_printf(bio_out, " (%s) %s prime\n",
argv[0],
BN_check_prime(bn, NULL, NULL)
? "is" : "is not");
r == 1 ? "is" : "is not");
}
}

View File

@ -2703,7 +2703,7 @@ static int test_not_prime(int i)
for (trial = 0; trial <= 1; ++trial) {
if (!TEST_true(BN_set_word(r, not_primes[i]))
|| !TEST_false(BN_check_prime(r, ctx, NULL)))
|| !TEST_int_eq(BN_check_prime(r, ctx, NULL), 0))
goto err;
}