diff options
author | tb <> | 2024-11-14 10:18:00 +0000 |
---|---|---|
committer | tb <> | 2024-11-14 10:18:00 +0000 |
commit | 34feb8ce45dfd14d621768a6831a51fe5748a704 (patch) | |
tree | cabb4b7b21e56570dd3625ff9c65e2c44f5eb2ad | |
parent | c59a06db65032250ef7e451eab8a86ba86a80b48 (diff) | |
download | openbsd-34feb8ce45dfd14d621768a6831a51fe5748a704.tar.gz openbsd-34feb8ce45dfd14d621768a6831a51fe5748a704.tar.bz2 openbsd-34feb8ce45dfd14d621768a6831a51fe5748a704.zip |
eck_prn: consistently use bio for a BIO rather than b and bp randomly
-rw-r--r-- | src/lib/libcrypto/ec/eck_prn.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c index 7fa828293e..2ae917dbbc 100644 --- a/src/lib/libcrypto/ec/eck_prn.c +++ b/src/lib/libcrypto/ec/eck_prn.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eck_prn.c,v 1.33 2024/11/14 10:16:02 tb Exp $ */ | 1 | /* $OpenBSD: eck_prn.c,v 1.34 2024/11/14 10:18:00 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -72,7 +72,7 @@ | |||
72 | #include "ec_local.h" | 72 | #include "ec_local.h" |
73 | 73 | ||
74 | int | 74 | int |
75 | EC_KEY_print(BIO *bp, const EC_KEY *x, int off) | 75 | EC_KEY_print(BIO *bio, const EC_KEY *x, int off) |
76 | { | 76 | { |
77 | EVP_PKEY *pk; | 77 | EVP_PKEY *pk; |
78 | int ret = 0; | 78 | int ret = 0; |
@@ -83,7 +83,7 @@ EC_KEY_print(BIO *bp, const EC_KEY *x, int off) | |||
83 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | 83 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) |
84 | goto err; | 84 | goto err; |
85 | 85 | ||
86 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); | 86 | ret = EVP_PKEY_print_private(bio, pk, off, NULL); |
87 | 87 | ||
88 | err: | 88 | err: |
89 | EVP_PKEY_free(pk); | 89 | EVP_PKEY_free(pk); |
@@ -95,26 +95,26 @@ LCRYPTO_ALIAS(EC_KEY_print); | |||
95 | int | 95 | int |
96 | EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) | 96 | EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) |
97 | { | 97 | { |
98 | BIO *b; | 98 | BIO *bio; |
99 | int ret; | 99 | int ret; |
100 | 100 | ||
101 | if ((b = BIO_new(BIO_s_file())) == NULL) { | 101 | if ((bio = BIO_new(BIO_s_file())) == NULL) { |
102 | ECerror(ERR_R_BIO_LIB); | 102 | ECerror(ERR_R_BIO_LIB); |
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | BIO_set_fp(b, fp, BIO_NOCLOSE); | 106 | BIO_set_fp(bio, fp, BIO_NOCLOSE); |
107 | 107 | ||
108 | ret = EC_KEY_print(b, x, off); | 108 | ret = EC_KEY_print(bio, x, off); |
109 | 109 | ||
110 | BIO_free(b); | 110 | BIO_free(bio); |
111 | 111 | ||
112 | return ret; | 112 | return ret; |
113 | } | 113 | } |
114 | LCRYPTO_ALIAS(EC_KEY_print_fp); | 114 | LCRYPTO_ALIAS(EC_KEY_print_fp); |
115 | 115 | ||
116 | int | 116 | int |
117 | ECParameters_print(BIO *bp, const EC_KEY *x) | 117 | ECParameters_print(BIO *bio, const EC_KEY *x) |
118 | { | 118 | { |
119 | EVP_PKEY *pk; | 119 | EVP_PKEY *pk; |
120 | int ret = 0; | 120 | int ret = 0; |
@@ -125,7 +125,7 @@ ECParameters_print(BIO *bp, const EC_KEY *x) | |||
125 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | 125 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) |
126 | goto err; | 126 | goto err; |
127 | 127 | ||
128 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); | 128 | ret = EVP_PKEY_print_params(bio, pk, 4, NULL); |
129 | 129 | ||
130 | err: | 130 | err: |
131 | EVP_PKEY_free(pk); | 131 | EVP_PKEY_free(pk); |
@@ -137,32 +137,32 @@ LCRYPTO_ALIAS(ECParameters_print); | |||
137 | int | 137 | int |
138 | ECParameters_print_fp(FILE *fp, const EC_KEY *x) | 138 | ECParameters_print_fp(FILE *fp, const EC_KEY *x) |
139 | { | 139 | { |
140 | BIO *b; | 140 | BIO *bio; |
141 | int ret; | 141 | int ret; |
142 | 142 | ||
143 | if ((b = BIO_new(BIO_s_file())) == NULL) { | 143 | if ((bio = BIO_new(BIO_s_file())) == NULL) { |
144 | ECerror(ERR_R_BIO_LIB); | 144 | ECerror(ERR_R_BIO_LIB); |
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | BIO_set_fp(b, fp, BIO_NOCLOSE); | 148 | BIO_set_fp(bio, fp, BIO_NOCLOSE); |
149 | 149 | ||
150 | ret = ECParameters_print(b, x); | 150 | ret = ECParameters_print(bio, x); |
151 | 151 | ||
152 | BIO_free(b); | 152 | BIO_free(bio); |
153 | 153 | ||
154 | return ret; | 154 | return ret; |
155 | } | 155 | } |
156 | LCRYPTO_ALIAS(ECParameters_print_fp); | 156 | LCRYPTO_ALIAS(ECParameters_print_fp); |
157 | 157 | ||
158 | static int | 158 | static int |
159 | ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off) | 159 | ecpk_print_asn1_parameters(BIO *bio, const EC_GROUP *group, int off) |
160 | { | 160 | { |
161 | const char *nist_name; | 161 | const char *nist_name; |
162 | int nid; | 162 | int nid; |
163 | int ret = 0; | 163 | int ret = 0; |
164 | 164 | ||
165 | if (!BIO_indent(bp, off, 128)) { | 165 | if (!BIO_indent(bio, off, 128)) { |
166 | ECerror(ERR_R_BIO_LIB); | 166 | ECerror(ERR_R_BIO_LIB); |
167 | goto err; | 167 | goto err; |
168 | } | 168 | } |
@@ -172,17 +172,17 @@ ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off) | |||
172 | goto err; | 172 | goto err; |
173 | } | 173 | } |
174 | 174 | ||
175 | if (BIO_printf(bp, "ASN1 OID: %s\n", OBJ_nid2sn(nid)) <= 0) { | 175 | if (BIO_printf(bio, "ASN1 OID: %s\n", OBJ_nid2sn(nid)) <= 0) { |
176 | ECerror(ERR_R_BIO_LIB); | 176 | ECerror(ERR_R_BIO_LIB); |
177 | goto err; | 177 | goto err; |
178 | } | 178 | } |
179 | 179 | ||
180 | if ((nist_name = EC_curve_nid2nist(nid)) != NULL) { | 180 | if ((nist_name = EC_curve_nid2nist(nid)) != NULL) { |
181 | if (!BIO_indent(bp, off, 128)) { | 181 | if (!BIO_indent(bio, off, 128)) { |
182 | ECerror(ERR_R_BIO_LIB); | 182 | ECerror(ERR_R_BIO_LIB); |
183 | goto err; | 183 | goto err; |
184 | } | 184 | } |
185 | if (BIO_printf(bp, "NIST CURVE: %s\n", nist_name) <= 0) { | 185 | if (BIO_printf(bio, "NIST CURVE: %s\n", nist_name) <= 0) { |
186 | ECerror(ERR_R_BIO_LIB); | 186 | ECerror(ERR_R_BIO_LIB); |
187 | goto err; | 187 | goto err; |
188 | } | 188 | } |
@@ -195,7 +195,7 @@ ecpk_print_asn1_parameters(BIO *bp, const EC_GROUP *group, int off) | |||
195 | } | 195 | } |
196 | 196 | ||
197 | static int | 197 | static int |
198 | ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off) | 198 | ecpk_print_explicit_parameters(BIO *bio, const EC_GROUP *group, int off) |
199 | { | 199 | { |
200 | BN_CTX *ctx = NULL; | 200 | BN_CTX *ctx = NULL; |
201 | const BIGNUM *order; | 201 | const BIGNUM *order; |
@@ -250,18 +250,18 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off) | |||
250 | goto err; | 250 | goto err; |
251 | } | 251 | } |
252 | 252 | ||
253 | if (!BIO_indent(bp, off, 128)) | 253 | if (!BIO_indent(bio, off, 128)) |
254 | goto err; | 254 | goto err; |
255 | 255 | ||
256 | nid = ec_group_get_field_type(group); | 256 | nid = ec_group_get_field_type(group); |
257 | if (BIO_printf(bp, "Field Type: %s\n", OBJ_nid2sn(nid)) <= 0) | 257 | if (BIO_printf(bio, "Field Type: %s\n", OBJ_nid2sn(nid)) <= 0) |
258 | goto err; | 258 | goto err; |
259 | 259 | ||
260 | if (!bn_printf(bp, p, off, "Prime:")) | 260 | if (!bn_printf(bio, p, off, "Prime:")) |
261 | goto err; | 261 | goto err; |
262 | if (!bn_printf(bp, a, off, "A: ")) | 262 | if (!bn_printf(bio, a, off, "A: ")) |
263 | goto err; | 263 | goto err; |
264 | if (!bn_printf(bp, b, off, "B: ")) | 264 | if (!bn_printf(bio, b, off, "B: ")) |
265 | goto err; | 265 | goto err; |
266 | 266 | ||
267 | if (form == POINT_CONVERSION_COMPRESSED) | 267 | if (form == POINT_CONVERSION_COMPRESSED) |
@@ -272,12 +272,12 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off) | |||
272 | conversion_form = "hybrid"; | 272 | conversion_form = "hybrid"; |
273 | else | 273 | else |
274 | conversion_form = "unknown"; | 274 | conversion_form = "unknown"; |
275 | if (!bn_printf(bp, gen, off, "Generator (%s):", conversion_form)) | 275 | if (!bn_printf(bio, gen, off, "Generator (%s):", conversion_form)) |
276 | goto err; | 276 | goto err; |
277 | 277 | ||
278 | if (!bn_printf(bp, order, off, "Order: ")) | 278 | if (!bn_printf(bio, order, off, "Order: ")) |
279 | goto err; | 279 | goto err; |
280 | if (!bn_printf(bp, cofactor, off, "Cofactor: ")) | 280 | if (!bn_printf(bio, cofactor, off, "Cofactor: ")) |
281 | goto err; | 281 | goto err; |
282 | if ((seed = EC_GROUP_get0_seed(group)) != NULL) { | 282 | if ((seed = EC_GROUP_get0_seed(group)) != NULL) { |
283 | size_t i; | 283 | size_t i; |
@@ -285,28 +285,28 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off) | |||
285 | seed_len = EC_GROUP_get_seed_len(group); | 285 | seed_len = EC_GROUP_get_seed_len(group); |
286 | 286 | ||
287 | /* XXX - ecx_buf_print() has a CBS version of this - dedup. */ | 287 | /* XXX - ecx_buf_print() has a CBS version of this - dedup. */ |
288 | if (!BIO_indent(bp, off, 128)) | 288 | if (!BIO_indent(bio, off, 128)) |
289 | goto err; | 289 | goto err; |
290 | if (BIO_printf(bp, "Seed:") <= 0) | 290 | if (BIO_printf(bio, "Seed:") <= 0) |
291 | goto err; | 291 | goto err; |
292 | 292 | ||
293 | for (i = 0; i < seed_len; i++) { | 293 | for (i = 0; i < seed_len; i++) { |
294 | const char *sep = ":"; | 294 | const char *sep = ":"; |
295 | 295 | ||
296 | if (i % 15 == 0) { | 296 | if (i % 15 == 0) { |
297 | if (BIO_printf(bp, "\n") <= 0) | 297 | if (BIO_printf(bio, "\n") <= 0) |
298 | goto err; | 298 | goto err; |
299 | if (!BIO_indent(bp, off + 4, 128)) | 299 | if (!BIO_indent(bio, off + 4, 128)) |
300 | goto err; | 300 | goto err; |
301 | } | 301 | } |
302 | 302 | ||
303 | if (i + 1 == seed_len) | 303 | if (i + 1 == seed_len) |
304 | sep = ""; | 304 | sep = ""; |
305 | if (BIO_printf(bp, "%02x%s", seed[i], sep) <= 0) | 305 | if (BIO_printf(bio, "%02x%s", seed[i], sep) <= 0) |
306 | goto err; | 306 | goto err; |
307 | } | 307 | } |
308 | 308 | ||
309 | if (BIO_printf(bp, "\n") <= 0) | 309 | if (BIO_printf(bio, "\n") <= 0) |
310 | goto err; | 310 | goto err; |
311 | } | 311 | } |
312 | 312 | ||
@@ -319,7 +319,7 @@ ecpk_print_explicit_parameters(BIO *bp, const EC_GROUP *group, int off) | |||
319 | } | 319 | } |
320 | 320 | ||
321 | int | 321 | int |
322 | ECPKParameters_print(BIO *bp, const EC_GROUP *group, int off) | 322 | ECPKParameters_print(BIO *bio, const EC_GROUP *group, int off) |
323 | { | 323 | { |
324 | if (group == NULL) { | 324 | if (group == NULL) { |
325 | ECerror(ERR_R_PASSED_NULL_PARAMETER); | 325 | ECerror(ERR_R_PASSED_NULL_PARAMETER); |
@@ -327,28 +327,28 @@ ECPKParameters_print(BIO *bp, const EC_GROUP *group, int off) | |||
327 | } | 327 | } |
328 | 328 | ||
329 | if (EC_GROUP_get_asn1_flag(group)) | 329 | if (EC_GROUP_get_asn1_flag(group)) |
330 | return ecpk_print_asn1_parameters(bp, group, off); | 330 | return ecpk_print_asn1_parameters(bio, group, off); |
331 | 331 | ||
332 | return ecpk_print_explicit_parameters(bp, group, off); | 332 | return ecpk_print_explicit_parameters(bio, group, off); |
333 | } | 333 | } |
334 | LCRYPTO_ALIAS(ECPKParameters_print); | 334 | LCRYPTO_ALIAS(ECPKParameters_print); |
335 | 335 | ||
336 | int | 336 | int |
337 | ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) | 337 | ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) |
338 | { | 338 | { |
339 | BIO *b; | 339 | BIO *bio; |
340 | int ret; | 340 | int ret; |
341 | 341 | ||
342 | if ((b = BIO_new(BIO_s_file())) == NULL) { | 342 | if ((bio = BIO_new(BIO_s_file())) == NULL) { |
343 | ECerror(ERR_R_BUF_LIB); | 343 | ECerror(ERR_R_BUF_LIB); |
344 | return 0; | 344 | return 0; |
345 | } | 345 | } |
346 | 346 | ||
347 | BIO_set_fp(b, fp, BIO_NOCLOSE); | 347 | BIO_set_fp(bio, fp, BIO_NOCLOSE); |
348 | 348 | ||
349 | ret = ECPKParameters_print(b, x, off); | 349 | ret = ECPKParameters_print(bio, x, off); |
350 | 350 | ||
351 | BIO_free(b); | 351 | BIO_free(bio); |
352 | 352 | ||
353 | return ret; | 353 | return ret; |
354 | } | 354 | } |