From: tb Date: Fri, 7 Jul 2023 06:41:59 +0000 (+0000) Subject: Insert leading octet if high bit of first nibble is 1 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ceca8f99aabe920388df5b792cccc8114eb360fb;p=openbsd Insert leading octet if high bit of first nibble is 1 The reason the function this replaces is called ASN1_bn_print() is that it actually prints a representation of the ASN.1 encoding. ok jsing --- diff --git a/lib/libcrypto/bn/bn_print.c b/lib/libcrypto/bn/bn_print.c index 466aeb3d646..18984d7d4f1 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.40 2023/07/06 14:37:39 tb Exp $ */ +/* $OpenBSD: bn_print.c,v 1.41 2023/07/07 06:41:59 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler @@ -102,6 +102,12 @@ bn_print_bignum(BIO *bio, const BIGNUM *bn, int indent) if (BIO_printf(bio, "\n%*s", indent, "") <= 0) goto err; } + /* First nibble has the high bit set. Insert leading 0 octet. */ + if (octets == 1 && hi >= '8') { + if (BIO_printf(bio, "00:") <= 0) + goto err; + octets++; + } if (CBS_len(&cbs) == 0) sep = ""; if (BIO_printf(bio, "%c%c%s", tolower(hi), tolower(lo), sep) <= 0)