From 3e9606d3676b918eec4f58130ce87818363373b2 Mon Sep 17 00:00:00 2001 From: tb <> Date: Fri, 7 Jul 2023 06:41:59 +0000 Subject: 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 --- src/lib/libcrypto/bn/bn_print.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c index 466aeb3d64..18984d7d4f 100644 --- a/src/lib/libcrypto/bn/bn_print.c +++ b/src/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) -- cgit v1.2.3-55-g6feb