From 9cd3ae5c54bdbe6751858443eb65ea9b5ab6dced Mon Sep 17 00:00:00 2001 From: tb Date: Sun, 26 Mar 2023 20:09:14 +0000 Subject: [PATCH] Align bn_mod_exp_zero_test() with bn_mod_exp_test() --- regress/lib/libcrypto/bn/bn_mod_exp.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/regress/lib/libcrypto/bn/bn_mod_exp.c b/regress/lib/libcrypto/bn/bn_mod_exp.c index 5e12c8bb744..f4a6274af2d 100644 --- a/regress/lib/libcrypto/bn/bn_mod_exp.c +++ b/regress/lib/libcrypto/bn/bn_mod_exp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mod_exp.c,v 1.22 2023/03/26 19:56:28 tb Exp $ */ +/* $OpenBSD: bn_mod_exp.c,v 1.23 2023/03/26 20:09:14 tb Exp $ */ /* * Copyright (c) 2022,2023 Theo Buehler @@ -87,6 +87,7 @@ bn_mod_exp_zero_test(const struct mod_exp_zero_test *test, BN_CTX *ctx, { const BIGNUM *one; BIGNUM *a, *p, *got; + int mod_exp_ret; int failed = 1; BN_CTX_start(ctx); @@ -108,17 +109,15 @@ bn_mod_exp_zero_test(const struct mod_exp_zero_test *test, BN_CTX *ctx, } if (test->mod_exp_fn != NULL) { - if (!test->mod_exp_fn(got, a, p, one, ctx)) { - fprintf(stderr, "%s failed\n", test->name); - ERR_print_errors_fp(stderr); - goto err; - } + mod_exp_ret = test->mod_exp_fn(got, a, p, one, ctx); } else { - if (!test->mod_exp_mont_fn(got, a, p, one, ctx, NULL)) { - fprintf(stderr, "%s failed\n", test->name); - ERR_print_errors_fp(stderr); - goto err; - } + mod_exp_ret = test->mod_exp_mont_fn(got, a, p, one, ctx, NULL); + } + + if (!mod_exp_ret) { + fprintf(stderr, "%s failed\n", test->name); + ERR_print_errors_fp(stderr); + goto err; } if (!BN_is_zero(got)) { @@ -542,6 +541,7 @@ bn_mod_exp2_test(int reduce, BIGNUM *want, BIGNUM *got, BIGNUM *a1, BIGNUM *p1, return failed; } + static int run_bn_mod_exp2_tests(void) { -- 2.20.1