From: tb Date: Sat, 2 Mar 2024 10:43:52 +0000 (+0000) Subject: const correct X509_PURPOSE_get0{,_{,s}name}() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b9dfbe762cd1956009f74f794c2a1f3f698e12ce;p=openbsd const correct X509_PURPOSE_get0{,_{,s}name}() Unfortunately, PHP and rust-openssl still need this API. At least we can make the table read-only now since we disabled its extensibility. ok jsing --- diff --git a/lib/libcrypto/x509/x509_purp.c b/lib/libcrypto/x509/x509_purp.c index d887d4c355a..53f4f2f9675 100644 --- a/lib/libcrypto/x509/x509_purp.c +++ b/lib/libcrypto/x509/x509_purp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_purp.c,v 1.38 2024/03/02 10:41:46 tb Exp $ */ +/* $OpenBSD: x509_purp.c,v 1.39 2024/03/02 10:43:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -105,7 +105,7 @@ static int check_purpose_timestamp_sign(const X509_PURPOSE *xp, const X509 *x, static int no_check(const X509_PURPOSE *xp, const X509 *x, int ca); static int ocsp_helper(const X509_PURPOSE *xp, const X509 *x, int ca); -static X509_PURPOSE xstandard[] = { +static const X509_PURPOSE xstandard[] = { { .purpose = X509_PURPOSE_SSL_CLIENT, .trust = X509_TRUST_SSL_CLIENT, @@ -204,7 +204,7 @@ X509_PURPOSE_get_count(void) } LCRYPTO_ALIAS(X509_PURPOSE_get_count); -X509_PURPOSE * +const X509_PURPOSE * X509_PURPOSE_get0(int idx) { if (idx < 0 || (size_t)idx >= X509_PURPOSE_COUNT) @@ -218,7 +218,7 @@ int X509_PURPOSE_get_by_sname(const char *sname) { int i; - X509_PURPOSE *xptmp; + const X509_PURPOSE *xptmp; for (i = 0; i < X509_PURPOSE_get_count(); i++) { xptmp = X509_PURPOSE_get0(i); @@ -249,14 +249,14 @@ X509_PURPOSE_get_id(const X509_PURPOSE *xp) } LCRYPTO_ALIAS(X509_PURPOSE_get_id); -char * +const char * X509_PURPOSE_get0_name(const X509_PURPOSE *xp) { return xp->name; } LCRYPTO_ALIAS(X509_PURPOSE_get0_name); -char * +const char * X509_PURPOSE_get0_sname(const X509_PURPOSE *xp) { return xp->sname; diff --git a/lib/libcrypto/x509/x509v3.h b/lib/libcrypto/x509/x509v3.h index 6b7dc80bf3f..1004f6f15b3 100644 --- a/lib/libcrypto/x509/x509v3.h +++ b/lib/libcrypto/x509/x509v3.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509v3.h,v 1.28 2024/03/02 10:41:46 tb Exp $ */ +/* $OpenBSD: x509v3.h,v 1.29 2024/03/02 10:43:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -713,11 +713,12 @@ int X509_check_purpose(X509 *x, int id, int ca); int X509_supported_extension(X509_EXTENSION *ex); int X509_check_issued(X509 *issuer, X509 *subject); int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); + int X509_PURPOSE_get_count(void); -X509_PURPOSE *X509_PURPOSE_get0(int idx); +const X509_PURPOSE *X509_PURPOSE_get0(int idx); int X509_PURPOSE_get_by_sname(const char *sname); -char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); -char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); +const char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); +const char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); int X509_PURPOSE_get_id(const X509_PURPOSE *); uint32_t X509_get_extension_flags(X509 *x); uint32_t X509_get_key_usage(X509 *x);