summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorJonathan M. Wilbur <jonathan@wilbur.space>2024-09-12 13:07:04 +0200
committerTomas Mraz <tomas@openssl.org>2024-09-16 22:56:02 +0200
commitc90451d89d55ba42f2be01065361030f26f3e852 (patch)
treedbc87693f66552a40e222b1e0dc21b30b5e65a52 /crypto
parentfeat: add ossl_serial_number_print (diff)
downloadopenssl-c90451d89d55ba42f2be01065361030f26f3e852.tar.xz
openssl-c90451d89d55ba42f2be01065361030f26f3e852.zip
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)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/x509/t_x509.c35
1 files changed, 4 insertions, 31 deletions
diff --git a/crypto/x509/t_x509.c b/crypto/x509/t_x509.c
index 4befbe25da..71f9e33c21 100644
--- a/crypto/x509/t_x509.c
+++ b/crypto/x509/t_x509.c
@@ -88,37 +88,10 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
if (BIO_write(bp, " Serial Number:", 22) <= 0)
goto err;
-
- 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;
- } else {
- neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : "";
- if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0)
- 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 (ossl_serial_number_print(bp, bs, 12) != 0)
+ goto err;
+ if (BIO_puts(bp, "\n") <= 0)
+ goto err;
}
if (!(cflag & X509_FLAG_NO_SIGNAME)) {