From 163b893348f7c93100c71a95de9b40574abcd1ec Mon Sep 17 00:00:00 2001 From: tb Date: Sun, 9 Jul 2023 18:35:52 +0000 Subject: [PATCH] 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 --- lib/libcrypto/bn/bn_print.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/libcrypto/bn/bn_print.c b/lib/libcrypto/bn/bn_print.c index 84b82039683..c76d077324d 100644 --- a/lib/libcrypto/bn/bn_print.c +++ b/lib/libcrypto/bn/bn_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_print.c,v 1.42 2023/07/07 07:04:24 tb Exp $ */ +/* $OpenBSD: bn_print.c,v 1.43 2023/07/09 18:35:52 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler @@ -26,6 +26,7 @@ #include #include +#include "bn_local.h" #include "bytestring.h" static int @@ -80,17 +81,14 @@ bn_print_bignum(BIO *bio, const BIGNUM *bn, int indent) if (indent < 0) indent = 0; - if ((hex = BN_bn2hex(bn)) == NULL) + if (!bn_bn2hex_nosign(bn, &hex, &hex_len)) goto err; - hex_len = strlen(hex); CBS_init(&cbs, hex, hex_len); if (BN_is_negative(bn)) { if (BIO_printf(bio, " (Negative)") <= 0) goto err; - if (!CBS_skip(&cbs, 1)) - goto err; } while (CBS_len(&cbs) > 0) { -- 2.20.1