diff options
Diffstat (limited to 'src/lib/libcrypto/bn/bn_print.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_print.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c index c76d077324..666bbf4332 100644 --- a/src/lib/libcrypto/bn/bn_print.c +++ b/src/lib/libcrypto/bn/bn_print.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_print.c,v 1.43 2023/07/09 18:35:52 tb Exp $ */ | 1 | /* $OpenBSD: bn_print.c,v 1.44 2023/07/09 18:37:58 tb Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> |
@@ -19,6 +19,7 @@ | |||
19 | #include <ctype.h> | 19 | #include <ctype.h> |
20 | #include <limits.h> | 20 | #include <limits.h> |
21 | #include <stdarg.h> | 21 | #include <stdarg.h> |
22 | #include <stdio.h> | ||
22 | #include <stdint.h> | 23 | #include <stdint.h> |
23 | #include <stdlib.h> | 24 | #include <stdlib.h> |
24 | #include <string.h> | 25 | #include <string.h> |
@@ -149,3 +150,45 @@ bn_printf(BIO *bio, const BIGNUM *bn, int indent, const char *fmt, ...) | |||
149 | 150 | ||
150 | return bn_print_bignum(bio, bn, indent); | 151 | return bn_print_bignum(bio, bn, indent); |
151 | } | 152 | } |
153 | |||
154 | int | ||
155 | BN_print(BIO *bio, const BIGNUM *bn) | ||
156 | { | ||
157 | char *hex = NULL; | ||
158 | size_t hex_len = 0; | ||
159 | int ret = 0; | ||
160 | |||
161 | if (!bn_bn2hex_nibbles(bn, &hex, &hex_len)) | ||
162 | goto err; | ||
163 | if (BIO_printf(bio, "%s", hex) <= 0) | ||
164 | goto err; | ||
165 | |||
166 | ret = 1; | ||
167 | |||
168 | err: | ||
169 | freezero(hex, hex_len); | ||
170 | |||
171 | return ret; | ||
172 | } | ||
173 | LCRYPTO_ALIAS(BN_print); | ||
174 | |||
175 | int | ||
176 | BN_print_fp(FILE *fp, const BIGNUM *bn) | ||
177 | { | ||
178 | char *hex = NULL; | ||
179 | size_t hex_len = 0; | ||
180 | int ret = 0; | ||
181 | |||
182 | if (!bn_bn2hex_nibbles(bn, &hex, &hex_len)) | ||
183 | goto err; | ||
184 | if (fprintf(fp, "%s", hex) < 0) | ||
185 | goto err; | ||
186 | |||
187 | ret = 1; | ||
188 | |||
189 | err: | ||
190 | freezero(hex, hex_len); | ||
191 | |||
192 | return ret; | ||
193 | } | ||
194 | LCRYPTO_ALIAS(BN_print_fp); | ||