feat: use ossl_serial_number_print in X509_print_ex

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25428)
This commit is contained in:
Jonathan M. Wilbur 2024-09-12 11:07:04 +00:00 committed by Tomas Mraz
parent 935f6e63c9
commit c90451d89d
3 changed files with 6 additions and 33 deletions

View File

@ -88,37 +88,10 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
if (BIO_write(bp, " Serial Number:", 22) <= 0) if (BIO_write(bp, " Serial Number:", 22) <= 0)
goto err; goto err;
if (ossl_serial_number_print(bp, bs, 12) != 0)
if (bs->length <= (int)sizeof(long)) {
ERR_set_mark();
l = ASN1_INTEGER_get(bs);
ERR_pop_to_mark();
} else {
l = -1;
}
if (l != -1) {
unsigned long ul;
if (bs->type == V_ASN1_NEG_INTEGER) {
ul = 0 - (unsigned long)l;
neg = "-";
} else {
ul = l;
neg = "";
}
if (BIO_printf(bp, " %s%lu (%s0x%lx)\n", neg, ul, neg, ul) <= 0)
goto err; goto err;
} else { if (BIO_puts(bp, "\n") <= 0)
neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : "";
if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0)
goto err; goto err;
for (i = 0; i < bs->length; i++) {
if (BIO_printf(bp, "%02x%c", bs->data[i],
((i + 1 == bs->length) ? '\n' : ':')) <= 0)
goto err;
}
}
} }
if (!(cflag & X509_FLAG_NO_SIGNAME)) { if (!(cflag & X509_FLAG_NO_SIGNAME)) {