diff options
author | tb <> | 2023-07-09 18:35:52 +0000 |
---|---|---|
committer | tb <> | 2023-07-09 18:35:52 +0000 |
commit | 2465d485086b84028dd242e11c351bcee78e18a6 (patch) | |
tree | 81d282636c4dc4c5bd3c8ef12fcd47f4411f471a /src/lib | |
parent | 4f03cd23b792effd358f8c1b24b75a754656bb43 (diff) | |
download | openbsd-2465d485086b84028dd242e11c351bcee78e18a6.tar.gz openbsd-2465d485086b84028dd242e11c351bcee78e18a6.tar.bz2 openbsd-2465d485086b84028dd242e11c351bcee78e18a6.zip |
Simplify bn_print()
We no longer need to do weird things as taking the length of the hex
string and jumping over a sign we didn't need.
ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/bn/bn_print.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c index 84b8203968..c76d077324 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.42 2023/07/07 07:04:24 tb Exp $ */ | 1 | /* $OpenBSD: bn_print.c,v 1.43 2023/07/09 18:35:52 tb Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> |
@@ -26,6 +26,7 @@ | |||
26 | #include <openssl/bio.h> | 26 | #include <openssl/bio.h> |
27 | #include <openssl/bn.h> | 27 | #include <openssl/bn.h> |
28 | 28 | ||
29 | #include "bn_local.h" | ||
29 | #include "bytestring.h" | 30 | #include "bytestring.h" |
30 | 31 | ||
31 | static int | 32 | static int |
@@ -80,17 +81,14 @@ bn_print_bignum(BIO *bio, const BIGNUM *bn, int indent) | |||
80 | if (indent < 0) | 81 | if (indent < 0) |
81 | indent = 0; | 82 | indent = 0; |
82 | 83 | ||
83 | if ((hex = BN_bn2hex(bn)) == NULL) | 84 | if (!bn_bn2hex_nosign(bn, &hex, &hex_len)) |
84 | goto err; | 85 | goto err; |
85 | hex_len = strlen(hex); | ||
86 | 86 | ||
87 | CBS_init(&cbs, hex, hex_len); | 87 | CBS_init(&cbs, hex, hex_len); |
88 | 88 | ||
89 | if (BN_is_negative(bn)) { | 89 | if (BN_is_negative(bn)) { |
90 | if (BIO_printf(bio, " (Negative)") <= 0) | 90 | if (BIO_printf(bio, " (Negative)") <= 0) |
91 | goto err; | 91 | goto err; |
92 | if (!CBS_skip(&cbs, 1)) | ||
93 | goto err; | ||
94 | } | 92 | } |
95 | 93 | ||
96 | while (CBS_len(&cbs) > 0) { | 94 | while (CBS_len(&cbs) > 0) { |