include/openssl/x509v3.h: restore previous stack definition arrangement
authorRichard Levitte <levitte@openssl.org>
Mon, 27 Apr 2020 06:36:53 +0000 (08:36 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 29 Apr 2020 04:37:10 +0000 (06:37 +0200)
It turned out that configuration options may affect the definition and
use of diverse stacks and how they relate to the underlying types.
For example, the configuration option 'no-rfc3779' results in a build
error around STACK_OF(IPAddressFamily) and related stacks.

Previously, STACK_OF definitions were located near the definition of
the underlying type, which are also affected by configuration options,
which made this easier to maintain.  We relocate the new stack
definitions back to those locations for that reason.

We apply the same type of relocation in other header files as well, following
the general rule that it's better to use DEFINE_OR_DECLARE_STACK_OF after the
type it defines a stack for has been defined.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11655)

12 files changed:
crypto/x509/x_x509.c
include/openssl/asn1.h
include/openssl/cmp.h
include/openssl/conf.h
include/openssl/crmf.h
include/openssl/ess.h
include/openssl/ocsp.h
include/openssl/pkcs12.h
include/openssl/srp.h
include/openssl/ssl.h
include/openssl/x509.h
include/openssl/x509v3.h

index 8cfdbc9fe67065c5c4b0a91e4111fc1a8d5f335d..8a216c49cf75b603caca9dd616e85f65a040d6a8 100644 (file)
@@ -15,7 +15,9 @@
 #include <openssl/x509v3.h>
 #include "crypto/x509.h"
 
+#ifndef OPENSSL_NO_RFC3779
 DEFINE_STACK_OF(IPAddressFamily)
+#endif
 
 ASN1_SEQUENCE_enc(X509_CINF, enc, 0) = {
         ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0),
index a5b14152a9620cf05b49825c46955d3f8f169797..c9917492d5f6351d346553ae43a6c086b4214e72 100644 (file)
@@ -120,13 +120,8 @@ extern "C" {
 # define SMIME_CRLFEOL           0x800
 # define SMIME_STREAM            0x1000
 
-DEFINE_OR_DECLARE_STACK_OF(ASN1_GENERALSTRING)
-DEFINE_OR_DECLARE_STACK_OF(ASN1_INTEGER)
-DEFINE_OR_DECLARE_STACK_OF(ASN1_OBJECT)
-DEFINE_OR_DECLARE_STACK_OF(ASN1_STRING_TABLE)
-DEFINE_OR_DECLARE_STACK_OF(ASN1_UTF8STRING)
+/* Stacks for types not otherwise defined in this header */
 DEFINE_OR_DECLARE_STACK_OF(X509_ALGOR)
-DEFINE_OR_DECLARE_STACK_OF(ASN1_TYPE)
 
 # define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */
 /*
@@ -201,6 +196,7 @@ struct asn1_string_table_st {
     unsigned long flags;
 };
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_STRING_TABLE)
 
 /* size limits: this stuff is taken straight from RFC2459 */
 
@@ -456,6 +452,7 @@ struct asn1_type_st {
     } value;
 };
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_TYPE)
 
 typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
 
@@ -509,6 +506,8 @@ int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
 ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);
 void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_OBJECT)
+
 DECLARE_ASN1_FUNCTIONS(ASN1_OBJECT)
 
 ASN1_STRING *ASN1_STRING_new(void);
@@ -543,6 +542,8 @@ int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);
 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,
                             BIT_STRING_BITNAME *tbl);
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_INTEGER)
+
 DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
                                 long length);
@@ -576,6 +577,8 @@ int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
 int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
                           int len);
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_UTF8STRING)
+
 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
 DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
@@ -585,6 +588,8 @@ DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
 int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
 int UTF8_putc(unsigned char *str, int len, unsigned long value);
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_GENERALSTRING)
+
 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
 
 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
index 76ba0e3bf14848e859803bf2ab547740d08e2417..66e3f408607ab5e780a5f6d36e350e54642d84bd 100644 (file)
@@ -202,12 +202,6 @@ DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS)
 #  define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0
 #  define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1
 
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_CERTSTATUS)
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_ITAV)
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_PKISI)
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_CERTREPMESSAGE)
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_CERTRESPONSE)
-
 /* data type declarations */
 typedef struct ossl_cmp_ctx_st OSSL_CMP_CTX;
 typedef struct ossl_cmp_pkiheader_st OSSL_CMP_PKIHEADER;
@@ -216,16 +210,21 @@ typedef struct ossl_cmp_msg_st OSSL_CMP_MSG;
 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG)
 DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG)
 typedef struct ossl_cmp_certstatus_st OSSL_CMP_CERTSTATUS;
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_CERTSTATUS)
 typedef struct ossl_cmp_itav_st OSSL_CMP_ITAV;
 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV)
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_ITAV)
 typedef struct ossl_cmp_revrepcontent_st OSSL_CMP_REVREPCONTENT;
 typedef struct ossl_cmp_pkisi_st OSSL_CMP_PKISI;
 DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI)
 DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI)
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_PKISI)
 typedef struct ossl_cmp_certrepmessage_st OSSL_CMP_CERTREPMESSAGE;
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_CERTREPMESSAGE)
 typedef struct ossl_cmp_pollrep_st OSSL_CMP_POLLREP;
 typedef STACK_OF(OSSL_CMP_POLLREP) OSSL_CMP_POLLREPCONTENT;
 typedef struct ossl_cmp_certresponse_st OSSL_CMP_CERTRESPONSE;
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CMP_CERTRESPONSE)
 typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT;
 
 /*
index 6a36a85b0f2237c641301d0dd212f447e3fc97c2..24cdcbb1cfbf3fa0e7cef93f51a7d8742c606259 100644 (file)
@@ -34,7 +34,6 @@ typedef struct {
 } CONF_VALUE;
 
 DEFINE_OR_DECLARE_STACK_OF(CONF_VALUE)
-DEFINE_OR_DECLARE_STACK_OF(CONF_MODULE)
 
 DEFINE_LHASH_OF(CONF_VALUE);
 
@@ -60,6 +59,7 @@ struct conf_method_st {
 typedef struct conf_imodule_st CONF_IMODULE;
 typedef struct conf_module_st CONF_MODULE;
 
+STACK_OF(CONF_MODULE);
 STACK_OF(CONF_IMODULE);
 
 /* DSO module function typedefs */
index 4908ebd563649b55e54a098ba46feedf1bd84f53..28eb68258f57aefd9f8b9049627657a4ea27c307 100644 (file)
@@ -30,9 +30,6 @@
 extern "C" {
 #  endif
 
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CRMF_MSG)
-DEFINE_OR_DECLARE_STACK_OF(OSSL_CRMF_CERTID)
-
 #  define OSSL_CRMF_POPOPRIVKEY_THISMESSAGE          0
 #  define OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE    1
 #  define OSSL_CRMF_POPOPRIVKEY_DHMAC                2
@@ -46,6 +43,7 @@ typedef struct ossl_crmf_encryptedvalue_st OSSL_CRMF_ENCRYPTEDVALUE;
 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE)
 typedef struct ossl_crmf_msg_st OSSL_CRMF_MSG;
 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSG)
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CRMF_MSG)
 typedef struct ossl_crmf_attributetypeandvalue_st OSSL_CRMF_ATTRIBUTETYPEANDVALUE;
 typedef struct ossl_crmf_pbmparameter_st OSSL_CRMF_PBMPARAMETER;
 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER)
@@ -53,6 +51,7 @@ typedef struct ossl_crmf_poposigningkey_st OSSL_CRMF_POPOSIGNINGKEY;
 typedef struct ossl_crmf_certrequest_st OSSL_CRMF_CERTREQUEST;
 typedef struct ossl_crmf_certid_st OSSL_CRMF_CERTID;
 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTID)
+DEFINE_OR_DECLARE_STACK_OF(OSSL_CRMF_CERTID)
 
 typedef struct ossl_crmf_pkipublicationinfo_st OSSL_CRMF_PKIPUBLICATIONINFO;
 DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKIPUBLICATIONINFO)
index 5a31f678c1848d8db98065bf9bb4ddd3ca7bc050..91e1d32e63e84db95f3c567d095e6e858c46c0e0 100644 (file)
@@ -19,16 +19,17 @@ extern "C" {
 # include <openssl/x509.h>
 # include <openssl/esserr.h>
 
-DEFINE_OR_DECLARE_STACK_OF(ESS_CERT_ID)
-DEFINE_OR_DECLARE_STACK_OF(ESS_CERT_ID_V2)
 
 typedef struct ESS_issuer_serial ESS_ISSUER_SERIAL;
 typedef struct ESS_cert_id ESS_CERT_ID;
 typedef struct ESS_signing_cert ESS_SIGNING_CERT;
 
+DEFINE_OR_DECLARE_STACK_OF(ESS_CERT_ID)
+
 typedef struct ESS_signing_cert_v2_st ESS_SIGNING_CERT_V2;
 typedef struct ESS_cert_id_v2_st ESS_CERT_ID_V2;
 
+DEFINE_OR_DECLARE_STACK_OF(ESS_CERT_ID_V2)
 
 DECLARE_ASN1_ALLOC_FUNCTIONS(ESS_ISSUER_SERIAL)
 DECLARE_ASN1_ENCODE_FUNCTIONS_only(ESS_ISSUER_SERIAL, ESS_ISSUER_SERIAL)
index d40e843e8f75fd62b205d5e08c28bd20e0cb5bff..d5ccff0e8bc41b0e8e97e91a7673f29084c5bbe2 100644 (file)
@@ -102,17 +102,15 @@ extern "C" {
 #  define OCSP_RESPID_KEY                 0x400
 #  define OCSP_NOTIME                     0x800
 
-DEFINE_OR_DECLARE_STACK_OF(OCSP_CERTID)
-DEFINE_OR_DECLARE_STACK_OF(OCSP_ONEREQ)
-DEFINE_OR_DECLARE_STACK_OF(OCSP_RESPID)
-DEFINE_OR_DECLARE_STACK_OF(OCSP_SINGLERESP)
-
 typedef struct ocsp_cert_id_st OCSP_CERTID;
 typedef struct ocsp_one_request_st OCSP_ONEREQ;
 typedef struct ocsp_req_info_st OCSP_REQINFO;
 typedef struct ocsp_signature_st OCSP_SIGNATURE;
 typedef struct ocsp_request_st OCSP_REQUEST;
 
+DEFINE_OR_DECLARE_STACK_OF(OCSP_CERTID)
+DEFINE_OR_DECLARE_STACK_OF(OCSP_ONEREQ)
+
 #  define OCSP_RESPONSE_STATUS_SUCCESSFUL           0
 #  define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1
 #  define OCSP_RESPONSE_STATUS_INTERNALERROR        2
@@ -125,6 +123,7 @@ typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES;
 #  define V_OCSP_RESPID_NAME 0
 #  define V_OCSP_RESPID_KEY  1
 
+DEFINE_OR_DECLARE_STACK_OF(OCSP_RESPID)
 
 typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO;
 
@@ -135,6 +134,7 @@ typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO;
 typedef struct ocsp_cert_status_st OCSP_CERTSTATUS;
 typedef struct ocsp_single_response_st OCSP_SINGLERESP;
 
+DEFINE_OR_DECLARE_STACK_OF(OCSP_SINGLERESP)
 
 typedef struct ocsp_response_data_st OCSP_RESPDATA;
 
index 474992e479fb48f21578b127a7ac7217bf75da7d..72a2dc643bad10d74fdb41e54cfb92340830cb8b 100644 (file)
@@ -46,14 +46,14 @@ extern "C" {
 # define KEY_EX  0x10
 # define KEY_SIG 0x80
 
-DEFINE_OR_DECLARE_STACK_OF(PKCS12_SAFEBAG)
-
 typedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA;
 
 typedef struct PKCS12_st PKCS12;
 
 typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG;
 
+DEFINE_OR_DECLARE_STACK_OF(PKCS12_SAFEBAG)
+
 typedef struct pkcs12_bag_st PKCS12_BAGS;
 
 # define PKCS12_ERROR    0
index dc7bce935e40469d705f5f722244f97552be69ab..5c8f5368f88a9a7bc3cbebe12a705ce42e092733 100644 (file)
 extern "C" {
 # endif
 
-DEFINE_OR_DECLARE_STACK_OF(SRP_gN_cache)
-DEFINE_OR_DECLARE_STACK_OF(SRP_user_pwd)
-DEFINE_OR_DECLARE_STACK_OF(SRP_gN)
-
 typedef struct SRP_gN_cache_st {
     char *b64_bn;
     BIGNUM *bn;
 } SRP_gN_cache;
+DEFINE_OR_DECLARE_STACK_OF(SRP_gN_cache)
 
 typedef struct SRP_user_pwd_st {
     /* Owned by us. */
@@ -53,6 +50,7 @@ typedef struct SRP_user_pwd_st {
     /* Owned by us. */
     char *info;
 } SRP_user_pwd;
+DEFINE_OR_DECLARE_STACK_OF(SRP_user_pwd)
 
 SRP_user_pwd *SRP_user_pwd_new(void);
 void SRP_user_pwd_free(SRP_user_pwd *user_pwd);
@@ -61,7 +59,6 @@ void SRP_user_pwd_set_gN(SRP_user_pwd *user_pwd, const BIGNUM *g, const BIGNUM *
 int SRP_user_pwd_set1_ids(SRP_user_pwd *user_pwd, const char *id, const char *info);
 int SRP_user_pwd_set0_sv(SRP_user_pwd *user_pwd, BIGNUM *s, BIGNUM *v);
 
-
 typedef struct SRP_VBASE_st {
     STACK_OF(SRP_user_pwd) *users_pwd;
     STACK_OF(SRP_gN_cache) *gN_cache;
@@ -79,7 +76,7 @@ typedef struct SRP_gN_st {
     const BIGNUM *g;
     const BIGNUM *N;
 } SRP_gN;
-
+DEFINE_OR_DECLARE_STACK_OF(SRP_gN)
 
 SRP_VBASE *SRP_VBASE_new(char *seed_key);
 void SRP_VBASE_free(SRP_VBASE *vb);
index 551ba400467ea6bbd6819fb39f02ab8492347a24..5c2affb690797cde94c25e7574c1e64d6aa2a731 100644 (file)
@@ -230,16 +230,15 @@ typedef struct tls_sigalgs_st TLS_SIGALGS;
 typedef struct ssl_conf_ctx_st SSL_CONF_CTX;
 typedef struct ssl_comp_st SSL_COMP;
 
-DEFINE_OR_DECLARE_STACK_OF(SSL_CIPHER)
-DEFINE_OR_DECLARE_STACK_OF(SSL_COMP)
-DEFINE_OR_DECLARE_STACK_OF(SRTP_PROTECTION_PROFILE)
-DEFINE_OR_DECLARE_STACK_OF(SSL_COMP)
+STACK_OF(SSL_CIPHER);
+STACK_OF(SSL_COMP);
 
 /* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/
 typedef struct srtp_protection_profile_st {
     const char *name;
     unsigned long id;
 } SRTP_PROTECTION_PROFILE;
+DEFINE_OR_DECLARE_STACK_OF(SRTP_PROTECTION_PROFILE)
 
 
 typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data,
@@ -980,6 +979,8 @@ extern "C" {
  * These need to be after the above set of includes due to a compiler bug
  * in VisualStudio 2015
  */
+DEFINE_OR_DECLARE_STACK_OF(SSL_CIPHER)
+DEFINE_OR_DECLARE_STACK_OF(SSL_COMP)
 
 /* compatibility */
 # define SSL_set_app_data(s,arg)         (SSL_set_ex_data(s,0,(char *)(arg)))
index 310980299e513f26cb4caa1bc237db12d94033cf..d709c53cedd35abb5e21b6b429148edd8852fe8b 100644 (file)
 extern "C" {
 #endif
 
+/* Needed stacks for types defined in other headers */
+DEFINE_OR_DECLARE_STACK_OF(X509_NAME)
+DEFINE_OR_DECLARE_STACK_OF(X509)
+DEFINE_OR_DECLARE_STACK_OF(X509_REVOKED)
+DEFINE_OR_DECLARE_STACK_OF(X509_CRL)
 
 /* Flags for X509_get_signature_info() */
 /* Signature info is valid */
@@ -77,12 +82,8 @@ typedef struct X509_val_st {
 typedef struct X509_sig_st X509_SIG;
 
 typedef struct X509_name_entry_st X509_NAME_ENTRY;
-
 DEFINE_OR_DECLARE_STACK_OF(X509_NAME_ENTRY)
-DEFINE_OR_DECLARE_STACK_OF(X509_NAME)
-DEFINE_OR_DECLARE_STACK_OF(X509)
-DEFINE_OR_DECLARE_STACK_OF(X509_REVOKED)
-DEFINE_OR_DECLARE_STACK_OF(X509_CRL)
+
 
 # define X509_EX_V_NETSCAPE_HACK         0x8000
 # define X509_EX_V_INIT                  0x0001
index e4f09adfce8ba2562c93d6fec9b8458f381ee619..e7d36638b209bcc0205369d2fece182d8e082ea2 100644 (file)
 extern "C" {
 #endif
 
-DEFINE_OR_DECLARE_STACK_OF(GENERAL_NAME)
-DEFINE_OR_DECLARE_STACK_OF(X509V3_EXT_METHOD)
-DEFINE_OR_DECLARE_STACK_OF(GENERAL_NAMES)
-DEFINE_OR_DECLARE_STACK_OF(ACCESS_DESCRIPTION)
-DEFINE_OR_DECLARE_STACK_OF(DIST_POINT)
-DEFINE_OR_DECLARE_STACK_OF(SXNETID)
-DEFINE_OR_DECLARE_STACK_OF(POLICYQUALINFO)
-DEFINE_OR_DECLARE_STACK_OF(POLICYINFO)
-DEFINE_OR_DECLARE_STACK_OF(POLICY_MAPPING)
-DEFINE_OR_DECLARE_STACK_OF(GENERAL_SUBTREE)
-DEFINE_OR_DECLARE_STACK_OF(X509_PURPOSE)
-DEFINE_OR_DECLARE_STACK_OF(X509_POLICY_NODE)
-DEFINE_OR_DECLARE_STACK_OF(ASIdOrRange)
-DEFINE_OR_DECLARE_STACK_OF(IPAddressOrRange)
-DEFINE_OR_DECLARE_STACK_OF(IPAddressFamily)
-DEFINE_OR_DECLARE_STACK_OF(ASN1_STRING)
-DEFINE_OR_DECLARE_STACK_OF(ADMISSIONS)
-DEFINE_OR_DECLARE_STACK_OF(PROFESSION_INFO)
-
 /* Forward reference */
 struct v3_ext_method;
 struct v3_ext_ctx;
@@ -116,6 +97,8 @@ struct v3_ext_ctx {
 
 typedef struct v3_ext_method X509V3_EXT_METHOD;
 
+DEFINE_OR_DECLARE_STACK_OF(X509V3_EXT_METHOD)
+
 /* ext_flags values */
 # define X509V3_EXT_DYNAMIC      0x1
 # define X509V3_EXT_CTX_DEP      0x2
@@ -180,14 +163,16 @@ typedef struct ACCESS_DESCRIPTION_st {
     GENERAL_NAME *location;
 } ACCESS_DESCRIPTION;
 
-typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
+DEFINE_OR_DECLARE_STACK_OF(ACCESS_DESCRIPTION)
+DEFINE_OR_DECLARE_STACK_OF(GENERAL_NAME)
 
+typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
 typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
-
 typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE;
-
 typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
 
+DEFINE_OR_DECLARE_STACK_OF(GENERAL_NAMES)
+
 typedef struct DIST_POINT_NAME_st {
     int type;
     union {
@@ -219,6 +204,8 @@ struct DIST_POINT_st {
     int dp_reasons;
 };
 
+DEFINE_OR_DECLARE_STACK_OF(DIST_POINT)
+
 typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
 
 struct AUTHORITY_KEYID_st {
@@ -234,6 +221,8 @@ typedef struct SXNET_ID_st {
     ASN1_OCTET_STRING *user;
 } SXNETID;
 
+DEFINE_OR_DECLARE_STACK_OF(SXNETID)
+
 typedef struct SXNET_st {
     ASN1_INTEGER *version;
     STACK_OF(SXNETID) *ids;
@@ -265,11 +254,15 @@ typedef struct POLICYQUALINFO_st {
     } d;
 } POLICYQUALINFO;
 
+DEFINE_OR_DECLARE_STACK_OF(POLICYQUALINFO)
+
 typedef struct POLICYINFO_st {
     ASN1_OBJECT *policyid;
     STACK_OF(POLICYQUALINFO) *qualifiers;
 } POLICYINFO;
 
+DEFINE_OR_DECLARE_STACK_OF(POLICYINFO)
+
 typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
 
 typedef struct POLICY_MAPPING_st {
@@ -277,6 +270,8 @@ typedef struct POLICY_MAPPING_st {
     ASN1_OBJECT *subjectDomainPolicy;
 } POLICY_MAPPING;
 
+DEFINE_OR_DECLARE_STACK_OF(POLICY_MAPPING)
+
 typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;
 
 typedef struct GENERAL_SUBTREE_st {
@@ -285,6 +280,8 @@ typedef struct GENERAL_SUBTREE_st {
     ASN1_INTEGER *maximum;
 } GENERAL_SUBTREE;
 
+DEFINE_OR_DECLARE_STACK_OF(GENERAL_SUBTREE)
+
 struct NAME_CONSTRAINTS_st {
     STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
     STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
@@ -423,6 +420,8 @@ typedef struct x509_purpose_st {
     void *usr_data;
 } X509_PURPOSE;
 
+DEFINE_OR_DECLARE_STACK_OF(X509_PURPOSE)
+
 # define X509_PURPOSE_SSL_CLIENT         1
 # define X509_PURPOSE_SSL_SERVER         2
 # define X509_PURPOSE_NS_SSL_SERVER      3
@@ -735,6 +734,7 @@ int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,
                              unsigned long chtype);
 
 void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);
+DEFINE_OR_DECLARE_STACK_OF(X509_POLICY_NODE)
 
 #ifndef OPENSSL_NO_RFC3779
 typedef struct ASRange_st {
@@ -752,6 +752,8 @@ typedef struct ASIdOrRange_st {
     } u;
 } ASIdOrRange;
 
+DEFINE_OR_DECLARE_STACK_OF(ASIdOrRange)
+
 typedef STACK_OF(ASIdOrRange) ASIdOrRanges;
 
 # define ASIdentifierChoice_inherit              0
@@ -789,6 +791,8 @@ typedef struct IPAddressOrRange_st {
     } u;
 } IPAddressOrRange;
 
+DEFINE_OR_DECLARE_STACK_OF(IPAddressOrRange)
+
 typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;
 
 # define IPAddressChoice_inherit                 0
@@ -807,6 +811,8 @@ typedef struct IPAddressFamily_st {
     IPAddressChoice *ipAddressChoice;
 } IPAddressFamily;
 
+DEFINE_OR_DECLARE_STACK_OF(IPAddressFamily)
+
 typedef STACK_OF(IPAddressFamily) IPAddrBlocks;
 
 DECLARE_ASN1_FUNCTIONS(IPAddressRange)
@@ -879,6 +885,7 @@ int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain,
 
 #endif                         /* OPENSSL_NO_RFC3779 */
 
+DEFINE_OR_DECLARE_STACK_OF(ASN1_STRING)
 
 /*
  * Admission Syntax
@@ -891,6 +898,8 @@ DECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY)
 DECLARE_ASN1_FUNCTIONS(PROFESSION_INFO)
 DECLARE_ASN1_FUNCTIONS(ADMISSIONS)
 DECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX)
+DEFINE_OR_DECLARE_STACK_OF(PROFESSION_INFO)
+DEFINE_OR_DECLARE_STACK_OF(ADMISSIONS)
 typedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS;
 
 const ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId(