-/* $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 <tb@openbsd.org>
{
const BIGNUM *one;
BIGNUM *a, *p, *got;
+ int mod_exp_ret;
int failed = 1;
BN_CTX_start(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)) {
return failed;
}
+
static int
run_bn_mod_exp2_tests(void)
{