diff options
author | tb <> | 2024-05-03 02:52:00 +0000 |
---|---|---|
committer | tb <> | 2024-05-03 02:52:00 +0000 |
commit | e679c1b3b0f5cb90dcd621542a46d60836db83d5 (patch) | |
tree | 990bf6270fa19c34c30524f03c101d4c9daea4bd | |
parent | b7471a707d84ac22bacbbf9a540ce3d3cfa813c5 (diff) | |
download | openbsd-e679c1b3b0f5cb90dcd621542a46d60836db83d5.tar.gz openbsd-e679c1b3b0f5cb90dcd621542a46d60836db83d5.tar.bz2 openbsd-e679c1b3b0f5cb90dcd621542a46d60836db83d5.zip |
Align CRL and CSR version printing with certs
Only print specified 0-based versions and print them with the 1-based
human interpretation. Use a colon and error check the BIO_printf()
calls. (There's a lot more to clean up in here, but that's for another
day).
Notably, X509_CRL_print_ex() is missing... I guess that's better than
having one with signature and semantics differing from X509_print_ex()
und X509_REQ_print_ex().
ok beck
-rw-r--r-- | src/lib/libcrypto/asn1/t_crl.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/t_req.c | 18 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c index 39e04507ed..6449e7f199 100644 --- a/src/lib/libcrypto/asn1/t_crl.c +++ b/src/lib/libcrypto/asn1/t_crl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t_crl.c,v 1.25 2024/05/02 15:33:59 tb Exp $ */ | 1 | /* $OpenBSD: t_crl.c,v 1.26 2024/05/03 02:52:00 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -96,9 +96,15 @@ X509_CRL_print(BIO *out, X509_CRL *x) | |||
96 | 96 | ||
97 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); | 97 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); |
98 | l = X509_CRL_get_version(x); | 98 | l = X509_CRL_get_version(x); |
99 | if (l < 0 || l == LONG_MAX) | 99 | if (l >= 0 && l <= 1) { |
100 | goto err; | 100 | if (BIO_printf(out, "%8sVersion: %lu (0x%lx)\n", |
101 | BIO_printf(out, "%8sVersion %lu (0x%lx)\n", "", l + 1, l); | 101 | "", l + 1, l) <= 0) |
102 | goto err; | ||
103 | } else { | ||
104 | if (BIO_printf(out, "%8sVersion: unknown (%ld)\n", | ||
105 | "", l) <= 0) | ||
106 | goto err; | ||
107 | } | ||
102 | if (X509_signature_print(out, x->sig_alg, NULL) == 0) | 108 | if (X509_signature_print(out, x->sig_alg, NULL) == 0) |
103 | goto err; | 109 | goto err; |
104 | p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); | 110 | p = X509_NAME_oneline(X509_CRL_get_issuer(x), NULL, 0); |
diff --git a/src/lib/libcrypto/asn1/t_req.c b/src/lib/libcrypto/asn1/t_req.c index ac011705ef..1d4be9865d 100644 --- a/src/lib/libcrypto/asn1/t_req.c +++ b/src/lib/libcrypto/asn1/t_req.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t_req.c,v 1.27 2024/04/09 13:55:02 beck Exp $ */ | 1 | /* $OpenBSD: t_req.c,v 1.28 2024/05/03 02:52:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -99,7 +99,6 @@ X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, | |||
99 | { | 99 | { |
100 | unsigned long l; | 100 | unsigned long l; |
101 | int i; | 101 | int i; |
102 | const char *neg; | ||
103 | X509_REQ_INFO *ri; | 102 | X509_REQ_INFO *ri; |
104 | EVP_PKEY *pkey; | 103 | EVP_PKEY *pkey; |
105 | STACK_OF(X509_ATTRIBUTE) *sk; | 104 | STACK_OF(X509_ATTRIBUTE) *sk; |
@@ -124,15 +123,14 @@ X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, | |||
124 | goto err; | 123 | goto err; |
125 | } | 124 | } |
126 | if (!(cflag & X509_FLAG_NO_VERSION)) { | 125 | if (!(cflag & X509_FLAG_NO_VERSION)) { |
127 | neg = (ri->version->type == V_ASN1_NEG_INTEGER) ? "-" : ""; | 126 | if ((l = X509_REQ_get_version(x)) == 0) { |
128 | l = 0; | 127 | if (BIO_printf(bp, "%8sVersion: 1 (0x0)\n", "") <= 0) |
129 | for (i = 0; i < ri->version->length; i++) { | 128 | goto err; |
130 | l <<= 8; | 129 | } else { |
131 | l += ri->version->data[i]; | 130 | if (BIO_printf(bp, "%8sVersion: unknown (%ld)\n", |
131 | "", l) <= 0) | ||
132 | goto err; | ||
132 | } | 133 | } |
133 | if (BIO_printf(bp, "%8sVersion: %s%lu (%s0x%lx)\n", "", neg, | ||
134 | l, neg, l) <= 0) | ||
135 | goto err; | ||
136 | } | 134 | } |
137 | if (!(cflag & X509_FLAG_NO_SUBJECT)) { | 135 | if (!(cflag & X509_FLAG_NO_SUBJECT)) { |
138 | if (BIO_printf(bp, " Subject:%c", mlch) <= 0) | 136 | if (BIO_printf(bp, " Subject:%c", mlch) <= 0) |