diff options
author | tb <> | 2022-12-02 00:01:06 +0000 |
---|---|---|
committer | tb <> | 2022-12-02 00:01:06 +0000 |
commit | 111e23434b493cbedb35f015f5fc9868eca67bc4 (patch) | |
tree | 9b54bf6b00b30f2136dbc11fb331a5612788aea2 /src/regress/lib | |
parent | 37d11dcb75b993acde21106d7b7d11b4b2465b07 (diff) | |
download | openbsd-111e23434b493cbedb35f015f5fc9868eca67bc4.tar.gz openbsd-111e23434b493cbedb35f015f5fc9868eca67bc4.tar.bz2 openbsd-111e23434b493cbedb35f015f5fc9868eca67bc4.zip |
bn_add_sub: no need for a BIO to print to stderr
Diffstat (limited to 'src/regress/lib')
-rw-r--r-- | src/regress/lib/libcrypto/bn/bn_add_sub.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_add_sub.c b/src/regress/lib/libcrypto/bn/bn_add_sub.c index f13129a000..13af33fe9a 100644 --- a/src/regress/lib/libcrypto/bn/bn_add_sub.c +++ b/src/regress/lib/libcrypto/bn/bn_add_sub.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_add_sub.c,v 1.1 2022/12/01 20:50:10 tb Exp $ */ | 1 | /* $OpenBSD: bn_add_sub.c,v 1.2 2022/12/02 00:01:06 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
4 | * | 4 | * |
@@ -20,14 +20,11 @@ | |||
20 | #include <err.h> | 20 | #include <err.h> |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | 22 | ||
23 | #include <openssl/bio.h> | ||
24 | #include <openssl/bn.h> | 23 | #include <openssl/bn.h> |
25 | #include <openssl/err.h> | 24 | #include <openssl/err.h> |
26 | 25 | ||
27 | #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) | 26 | #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) |
28 | 27 | ||
29 | BIO *bio_err; | ||
30 | |||
31 | struct hexinput_st { | 28 | struct hexinput_st { |
32 | const char *a_hex; | 29 | const char *a_hex; |
33 | const char *b_hex; | 30 | const char *b_hex; |
@@ -152,16 +149,16 @@ void | |||
152 | print_failure_case(BIGNUM *a, BIGNUM *b, BIGNUM *e, BIGNUM *r, int i, | 149 | print_failure_case(BIGNUM *a, BIGNUM *b, BIGNUM *e, BIGNUM *r, int i, |
153 | const char *testname) | 150 | const char *testname) |
154 | { | 151 | { |
155 | BIO_printf(bio_err, "%s #%d failed:", testname, i); | 152 | fprintf(stderr, "%s #%d failed:", testname, i); |
156 | BIO_printf(bio_err, "\na = "); | 153 | fprintf(stderr, "\na = "); |
157 | BN_print(bio_err, a); | 154 | BN_print_fp(stderr, a); |
158 | BIO_printf(bio_err, "\nb = "); | 155 | fprintf(stderr, "\nb = "); |
159 | BN_print(bio_err, b); | 156 | BN_print_fp(stderr, b); |
160 | BIO_printf(bio_err, "\nexpected: e = "); | 157 | fprintf(stderr, "\nexpected: e = "); |
161 | BN_print(bio_err, e); | 158 | BN_print_fp(stderr, e); |
162 | BIO_printf(bio_err, "\nobtained: r = "); | 159 | fprintf(stderr, "\nobtained: r = "); |
163 | BN_print(bio_err, r); | 160 | BN_print_fp(stderr, r); |
164 | BIO_printf(bio_err, "\n"); | 161 | fprintf(stderr, "\n"); |
165 | } | 162 | } |
166 | 163 | ||
167 | int | 164 | int |
@@ -177,7 +174,7 @@ bn_op_test(int (*bn_op)(BIGNUM *, const BIGNUM *, const BIGNUM *), | |||
177 | ((e = BN_new()) == NULL) || | 174 | ((e = BN_new()) == NULL) || |
178 | ((r = BN_new()) == NULL)) { | 175 | ((r = BN_new()) == NULL)) { |
179 | failed = 1; | 176 | failed = 1; |
180 | ERR_print_errors(bio_err); | 177 | ERR_print_errors_fp(stderr); |
181 | goto err; | 178 | goto err; |
182 | } | 179 | } |
183 | 180 | ||
@@ -188,7 +185,7 @@ bn_op_test(int (*bn_op)(BIGNUM *, const BIGNUM *, const BIGNUM *), | |||
188 | !BN_hex2bn(&b, tests[i].b_hex) || | 185 | !BN_hex2bn(&b, tests[i].b_hex) || |
189 | !BN_hex2bn(&e, tests[i].e_hex)) { | 186 | !BN_hex2bn(&e, tests[i].e_hex)) { |
190 | print = 1; | 187 | print = 1; |
191 | ERR_print_errors(bio_err); | 188 | ERR_print_errors_fp(stderr); |
192 | } | 189 | } |
193 | 190 | ||
194 | if (tests[i].ret != bn_op(r, a, b)) | 191 | if (tests[i].ret != bn_op(r, a, b)) |
@@ -214,11 +211,6 @@ main(int argc, char *argv[]) | |||
214 | { | 211 | { |
215 | int failed = 0; | 212 | int failed = 0; |
216 | 213 | ||
217 | if ((bio_err = BIO_new_fp(stderr, BIO_NOCLOSE)) == NULL) { | ||
218 | fprintf(stderr, "bnaddsub: failed to initialize bio_err"); | ||
219 | return 1; | ||
220 | } | ||
221 | |||
222 | if (bn_op_test(BN_add, test_bn_add, nitems(test_bn_add), | 214 | if (bn_op_test(BN_add, test_bn_add, nitems(test_bn_add), |
223 | "BN_add with test_bn_add[]")) | 215 | "BN_add with test_bn_add[]")) |
224 | failed = 1; | 216 | failed = 1; |