#define NUM_BITS (BN_BITS2 * 4)
-#define BN_print_var(v) bn_print_var(#v, v)
-
-static void bn_print_var(const char *var, const BIGNUM *bn)
-{
- fprintf(stderr, "%s (%3d) = ", var, BN_num_bits(bn));
- BN_print_fp(stderr, bn);
- fprintf(stderr, "\n");
-}
+#define BN_print_var(v) test_output_bignum(#v, v)
/*
* Test that r == 0 in test_exp_mod_zero(). Returns one on success,
const BIGNUM *a)
{
if (!BN_is_zero(r)) {
- fprintf(stderr, "%s failed:\n", method);
- fprintf(stderr, "a ** 0 mod 1 = r (should be 0)\n");
+ TEST_error("%s failed: a ** 0 mod 1 = r (should be 0)", method);
BN_print_var(a);
BN_print_var(r);
return 0;
if (!TEST_true(BN_mod_exp_mont_word(r, one_word, p, m, ctx, NULL)))
goto err;
- if (!TEST_true(BN_is_zero(r))) {
- fprintf(stderr, "BN_mod_exp_mont_word failed:\n");
- fprintf(stderr, "1 ** 0 mod 1 = r (should be 0)\n");
+ if (!TEST_BN_eq_zero(r)) {
+ TEST_error("BN_mod_exp_mont_word failed: "
+ "1 ** 0 mod 1 = r (should be 0)");
BN_print_var(r);
goto err;
}
|| !TEST_true(BN_mod_exp_mont_consttime(r_mont_const, a, b, m, ctx, NULL)))
goto err;
- if (TEST_int_eq(BN_cmp(r_simple, r_mont), 0)
- && TEST_int_eq(BN_cmp(r_simple, r_recp), 0)
- && TEST_int_eq(BN_cmp(r_simple, r_mont_const), 0)) {
- printf(".");
- fflush(stdout);
- } else {
+ if (!TEST_BN_eq(r_simple, r_mont)
+ || !TEST_BN_eq(r_simple, r_recp)
+ || !TEST_BN_eq(r_simple, r_mont_const)) {
if (BN_cmp(r_simple, r_mont) != 0)
- fprintf(stderr, "simple and mont results differ\n");
+ TEST_info("simple and mont results differ");
if (BN_cmp(r_simple, r_mont_const) != 0)
- fprintf(stderr, "simple and mont const time results differ\n");
+ TEST_info("simple and mont const time results differ");
if (BN_cmp(r_simple, r_recp) != 0)
- fprintf(stderr, "simple and recp results differ\n");
+ TEST_info("simple and recp results differ");
BN_print_var(a);
BN_print_var(b);