Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:37

0001 /*
0002  * WARNING: do not edit!
0003  * Generated by Makefile from include/openssl/asn1.h.in
0004  *
0005  * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
0006  *
0007  * Licensed under the Apache License 2.0 (the "License").  You may not use
0008  * this file except in compliance with the License.  You can obtain a copy
0009  * in the file LICENSE in the source distribution or at
0010  * https://www.openssl.org/source/license.html
0011  */
0012 
0013 
0014 
0015 #ifndef OPENSSL_ASN1_H
0016 # define OPENSSL_ASN1_H
0017 # pragma once
0018 
0019 # include <openssl/macros.h>
0020 # ifndef OPENSSL_NO_DEPRECATED_3_0
0021 #  define HEADER_ASN1_H
0022 # endif
0023 
0024 # ifndef OPENSSL_NO_STDIO
0025 #  include <stdio.h>
0026 # endif
0027 # include <time.h>
0028 # include <openssl/e_os2.h>
0029 # include <openssl/opensslconf.h>
0030 # include <openssl/bio.h>
0031 # include <openssl/safestack.h>
0032 # include <openssl/asn1err.h>
0033 # include <openssl/symhacks.h>
0034 
0035 # include <openssl/types.h>
0036 # include <openssl/bn.h>
0037 
0038 # ifdef OPENSSL_BUILD_SHLIBCRYPTO
0039 #  undef OPENSSL_EXTERN
0040 #  define OPENSSL_EXTERN OPENSSL_EXPORT
0041 # endif
0042 
0043 #ifdef  __cplusplus
0044 extern "C" {
0045 #endif
0046 
0047 # define V_ASN1_UNIVERSAL                0x00
0048 # define V_ASN1_APPLICATION              0x40
0049 # define V_ASN1_CONTEXT_SPECIFIC         0x80
0050 # define V_ASN1_PRIVATE                  0xc0
0051 
0052 # define V_ASN1_CONSTRUCTED              0x20
0053 # define V_ASN1_PRIMITIVE_TAG            0x1f
0054 # define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG
0055 
0056 # define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */
0057 # define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */
0058 # define V_ASN1_ANY                      -4/* used in ASN1 template code */
0059 
0060 # define V_ASN1_UNDEF                    -1
0061 /* ASN.1 tag values */
0062 # define V_ASN1_EOC                      0
0063 # define V_ASN1_BOOLEAN                  1 /**/
0064 # define V_ASN1_INTEGER                  2
0065 # define V_ASN1_BIT_STRING               3
0066 # define V_ASN1_OCTET_STRING             4
0067 # define V_ASN1_NULL                     5
0068 # define V_ASN1_OBJECT                   6
0069 # define V_ASN1_OBJECT_DESCRIPTOR        7
0070 # define V_ASN1_EXTERNAL                 8
0071 # define V_ASN1_REAL                     9
0072 # define V_ASN1_ENUMERATED               10
0073 # define V_ASN1_UTF8STRING               12
0074 # define V_ASN1_SEQUENCE                 16
0075 # define V_ASN1_SET                      17
0076 # define V_ASN1_NUMERICSTRING            18 /**/
0077 # define V_ASN1_PRINTABLESTRING          19
0078 # define V_ASN1_T61STRING                20
0079 # define V_ASN1_TELETEXSTRING            20/* alias */
0080 # define V_ASN1_VIDEOTEXSTRING           21 /**/
0081 # define V_ASN1_IA5STRING                22
0082 # define V_ASN1_UTCTIME                  23
0083 # define V_ASN1_GENERALIZEDTIME          24 /**/
0084 # define V_ASN1_GRAPHICSTRING            25 /**/
0085 # define V_ASN1_ISO64STRING              26 /**/
0086 # define V_ASN1_VISIBLESTRING            26/* alias */
0087 # define V_ASN1_GENERALSTRING            27 /**/
0088 # define V_ASN1_UNIVERSALSTRING          28 /**/
0089 # define V_ASN1_BMPSTRING                30
0090 
0091 /*
0092  * NB the constants below are used internally by ASN1_INTEGER
0093  * and ASN1_ENUMERATED to indicate the sign. They are *not* on
0094  * the wire tag values.
0095  */
0096 
0097 # define V_ASN1_NEG                      0x100
0098 # define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)
0099 # define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)
0100 
0101 /* For use with d2i_ASN1_type_bytes() */
0102 # define B_ASN1_NUMERICSTRING    0x0001
0103 # define B_ASN1_PRINTABLESTRING  0x0002
0104 # define B_ASN1_T61STRING        0x0004
0105 # define B_ASN1_TELETEXSTRING    0x0004
0106 # define B_ASN1_VIDEOTEXSTRING   0x0008
0107 # define B_ASN1_IA5STRING        0x0010
0108 # define B_ASN1_GRAPHICSTRING    0x0020
0109 # define B_ASN1_ISO64STRING      0x0040
0110 # define B_ASN1_VISIBLESTRING    0x0040
0111 # define B_ASN1_GENERALSTRING    0x0080
0112 # define B_ASN1_UNIVERSALSTRING  0x0100
0113 # define B_ASN1_OCTET_STRING     0x0200
0114 # define B_ASN1_BIT_STRING       0x0400
0115 # define B_ASN1_BMPSTRING        0x0800
0116 # define B_ASN1_UNKNOWN          0x1000
0117 # define B_ASN1_UTF8STRING       0x2000
0118 # define B_ASN1_UTCTIME          0x4000
0119 # define B_ASN1_GENERALIZEDTIME  0x8000
0120 # define B_ASN1_SEQUENCE         0x10000
0121 /* For use with ASN1_mbstring_copy() */
0122 # define MBSTRING_FLAG           0x1000
0123 # define MBSTRING_UTF8           (MBSTRING_FLAG)
0124 # define MBSTRING_ASC            (MBSTRING_FLAG|1)
0125 # define MBSTRING_BMP            (MBSTRING_FLAG|2)
0126 # define MBSTRING_UNIV           (MBSTRING_FLAG|4)
0127 # define SMIME_OLDMIME           0x400
0128 # define SMIME_CRLFEOL           0x800
0129 # define SMIME_STREAM            0x1000
0130 
0131 /* Stacks for types not otherwise defined in this header */
0132 SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR)
0133 #define sk_X509_ALGOR_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_type(sk))
0134 #define sk_X509_ALGOR_value(sk, idx) ((X509_ALGOR *)OPENSSL_sk_value(ossl_check_const_X509_ALGOR_sk_type(sk), (idx)))
0135 #define sk_X509_ALGOR_new(cmp) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new(ossl_check_X509_ALGOR_compfunc_type(cmp)))
0136 #define sk_X509_ALGOR_new_null() ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_null())
0137 #define sk_X509_ALGOR_new_reserve(cmp, n) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_reserve(ossl_check_X509_ALGOR_compfunc_type(cmp), (n)))
0138 #define sk_X509_ALGOR_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ALGOR_sk_type(sk), (n))
0139 #define sk_X509_ALGOR_free(sk) OPENSSL_sk_free(ossl_check_X509_ALGOR_sk_type(sk))
0140 #define sk_X509_ALGOR_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ALGOR_sk_type(sk))
0141 #define sk_X509_ALGOR_delete(sk, i) ((X509_ALGOR *)OPENSSL_sk_delete(ossl_check_X509_ALGOR_sk_type(sk), (i)))
0142 #define sk_X509_ALGOR_delete_ptr(sk, ptr) ((X509_ALGOR *)OPENSSL_sk_delete_ptr(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)))
0143 #define sk_X509_ALGOR_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
0144 #define sk_X509_ALGOR_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
0145 #define sk_X509_ALGOR_pop(sk) ((X509_ALGOR *)OPENSSL_sk_pop(ossl_check_X509_ALGOR_sk_type(sk)))
0146 #define sk_X509_ALGOR_shift(sk) ((X509_ALGOR *)OPENSSL_sk_shift(ossl_check_X509_ALGOR_sk_type(sk)))
0147 #define sk_X509_ALGOR_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_X509_ALGOR_sk_type(sk),ossl_check_X509_ALGOR_freefunc_type(freefunc))
0148 #define sk_X509_ALGOR_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr), (idx))
0149 #define sk_X509_ALGOR_set(sk, idx, ptr) ((X509_ALGOR *)OPENSSL_sk_set(ossl_check_X509_ALGOR_sk_type(sk), (idx), ossl_check_X509_ALGOR_type(ptr)))
0150 #define sk_X509_ALGOR_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
0151 #define sk_X509_ALGOR_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
0152 #define sk_X509_ALGOR_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr), pnum)
0153 #define sk_X509_ALGOR_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ALGOR_sk_type(sk))
0154 #define sk_X509_ALGOR_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ALGOR_sk_type(sk))
0155 #define sk_X509_ALGOR_dup(sk) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_dup(ossl_check_const_X509_ALGOR_sk_type(sk)))
0156 #define sk_X509_ALGOR_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_deep_copy(ossl_check_const_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_copyfunc_type(copyfunc), ossl_check_X509_ALGOR_freefunc_type(freefunc)))
0157 #define sk_X509_ALGOR_set_cmp_func(sk, cmp) ((sk_X509_ALGOR_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_compfunc_type(cmp)))
0158 
0159 
0160 
0161 # define ASN1_STRING_FLAG_BITS_LEFT 0x08 /* Set if 0x07 has bits left value */
0162 /*
0163  * This indicates that the ASN1_STRING is not a real value but just a place
0164  * holder for the location where indefinite length constructed data should be
0165  * inserted in the memory buffer
0166  */
0167 # define ASN1_STRING_FLAG_NDEF 0x010
0168 
0169 /*
0170  * This flag is used by the CMS code to indicate that a string is not
0171  * complete and is a place holder for content when it had all been accessed.
0172  * The flag will be reset when content has been written to it.
0173  */
0174 
0175 # define ASN1_STRING_FLAG_CONT 0x020
0176 /*
0177  * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
0178  * type.
0179  */
0180 # define ASN1_STRING_FLAG_MSTRING 0x040
0181 /* String is embedded and only content should be freed */
0182 # define ASN1_STRING_FLAG_EMBED 0x080
0183 /* String should be parsed in RFC 5280's time format */
0184 # define ASN1_STRING_FLAG_X509_TIME 0x100
0185 /* This is the base type that holds just about everything :-) */
0186 struct asn1_string_st {
0187     int length;
0188     int type;
0189     unsigned char *data;
0190     /*
0191      * The value of the following field depends on the type being held.  It
0192      * is mostly being used for BIT_STRING so if the input data has a
0193      * non-zero 'unused bits' value, it will be handled correctly
0194      */
0195     long flags;
0196 };
0197 
0198 /*
0199  * ASN1_ENCODING structure: this is used to save the received encoding of an
0200  * ASN1 type. This is useful to get round problems with invalid encodings
0201  * which can break signatures.
0202  */
0203 
0204 typedef struct ASN1_ENCODING_st {
0205     unsigned char *enc;         /* DER encoding */
0206     long len;                   /* Length of encoding */
0207     int modified;               /* set to 1 if 'enc' is invalid */
0208 } ASN1_ENCODING;
0209 
0210 /* Used with ASN1 LONG type: if a long is set to this it is omitted */
0211 # define ASN1_LONG_UNDEF 0x7fffffffL
0212 
0213 # define STABLE_FLAGS_MALLOC     0x01
0214 /*
0215  * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted
0216  * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting
0217  * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias
0218  * STABLE_FLAGS_CLEAR to reflect this.
0219  */
0220 # define STABLE_FLAGS_CLEAR      STABLE_FLAGS_MALLOC
0221 # define STABLE_NO_MASK          0x02
0222 # define DIRSTRING_TYPE  \
0223  (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
0224 # define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
0225 
0226 struct asn1_string_table_st {
0227     int nid;
0228     long minsize;
0229     long maxsize;
0230     unsigned long mask;
0231     unsigned long flags;
0232 };
0233 
0234 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING_TABLE, ASN1_STRING_TABLE, ASN1_STRING_TABLE)
0235 #define sk_ASN1_STRING_TABLE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))
0236 #define sk_ASN1_STRING_TABLE_value(sk, idx) ((ASN1_STRING_TABLE *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), (idx)))
0237 #define sk_ASN1_STRING_TABLE_new(cmp) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp)))
0238 #define sk_ASN1_STRING_TABLE_new_null() ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_null())
0239 #define sk_ASN1_STRING_TABLE_new_reserve(cmp, n) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp), (n)))
0240 #define sk_ASN1_STRING_TABLE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (n))
0241 #define sk_ASN1_STRING_TABLE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk))
0242 #define sk_ASN1_STRING_TABLE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_TABLE_sk_type(sk))
0243 #define sk_ASN1_STRING_TABLE_delete(sk, i) ((ASN1_STRING_TABLE *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (i)))
0244 #define sk_ASN1_STRING_TABLE_delete_ptr(sk, ptr) ((ASN1_STRING_TABLE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr)))
0245 #define sk_ASN1_STRING_TABLE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr))
0246 #define sk_ASN1_STRING_TABLE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr))
0247 #define sk_ASN1_STRING_TABLE_pop(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_TABLE_sk_type(sk)))
0248 #define sk_ASN1_STRING_TABLE_shift(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_TABLE_sk_type(sk)))
0249 #define sk_ASN1_STRING_TABLE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk),ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc))
0250 #define sk_ASN1_STRING_TABLE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr), (idx))
0251 #define sk_ASN1_STRING_TABLE_set(sk, idx, ptr) ((ASN1_STRING_TABLE *)OPENSSL_sk_set(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (idx), ossl_check_ASN1_STRING_TABLE_type(ptr)))
0252 #define sk_ASN1_STRING_TABLE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr))
0253 #define sk_ASN1_STRING_TABLE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr))
0254 #define sk_ASN1_STRING_TABLE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_type(ptr), pnum)
0255 #define sk_ASN1_STRING_TABLE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_TABLE_sk_type(sk))
0256 #define sk_ASN1_STRING_TABLE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))
0257 #define sk_ASN1_STRING_TABLE_dup(sk) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)))
0258 #define sk_ASN1_STRING_TABLE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_copyfunc_type(copyfunc), ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc)))
0259 #define sk_ASN1_STRING_TABLE_set_cmp_func(sk, cmp) ((sk_ASN1_STRING_TABLE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_STRING_TABLE_sk_type(sk), ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp)))
0260 
0261 
0262 /* size limits: this stuff is taken straight from RFC2459 */
0263 
0264 # define ub_name                         32768
0265 # define ub_common_name                  64
0266 # define ub_locality_name                128
0267 # define ub_state_name                   128
0268 # define ub_organization_name            64
0269 # define ub_organization_unit_name       64
0270 # define ub_title                        64
0271 # define ub_email_address                128
0272 
0273 /*
0274  * Declarations for template structures: for full definitions see asn1t.h
0275  */
0276 typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
0277 typedef struct ASN1_TLC_st ASN1_TLC;
0278 /* This is just an opaque pointer */
0279 typedef struct ASN1_VALUE_st ASN1_VALUE;
0280 
0281 /* Declare ASN1 functions: the implement macro in in asn1t.h */
0282 
0283 /*
0284  * The mysterious 'extern' that's passed to some macros is innocuous,
0285  * and is there to quiet pre-C99 compilers that may complain about empty
0286  * arguments in macro calls.
0287  */
0288 
0289 # define DECLARE_ASN1_FUNCTIONS_attr(attr, type)                            \
0290     DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, type)
0291 # define DECLARE_ASN1_FUNCTIONS(type)                                       \
0292     DECLARE_ASN1_FUNCTIONS_attr(extern, type)
0293 
0294 # define DECLARE_ASN1_ALLOC_FUNCTIONS_attr(attr, type)                      \
0295     DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, type)
0296 # define DECLARE_ASN1_ALLOC_FUNCTIONS(type)                                 \
0297     DECLARE_ASN1_ALLOC_FUNCTIONS_attr(extern, type)
0298 
0299 # define DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, name)                 \
0300     DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name)                \
0301     DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name)
0302 # define DECLARE_ASN1_FUNCTIONS_name(type, name)                            \
0303     DECLARE_ASN1_FUNCTIONS_name_attr(extern, type, name)
0304 
0305 # define DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, itname, name)       \
0306     DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name)               \
0307     DECLARE_ASN1_ITEM_attr(attr, itname)
0308 # define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)                  \
0309     DECLARE_ASN1_ENCODE_FUNCTIONS_attr(extern, type, itname, name)
0310 
0311 # define DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name)          \
0312     DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, name, name)
0313 # define DECLARE_ASN1_ENCODE_FUNCTIONS_name(type, name) \
0314     DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, type, name)
0315 
0316 # define DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name)          \
0317     attr type *d2i_##name(type **a, const unsigned char **in, long len);    \
0318     attr int i2d_##name(const type *a, unsigned char **out);
0319 # define DECLARE_ASN1_ENCODE_FUNCTIONS_only(type, name)                     \
0320     DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(extern, type, name)
0321 
0322 # define DECLARE_ASN1_NDEF_FUNCTION_attr(attr, name)                        \
0323     attr int i2d_##name##_NDEF(const name *a, unsigned char **out);
0324 # define DECLARE_ASN1_NDEF_FUNCTION(name)                                   \
0325     DECLARE_ASN1_NDEF_FUNCTION_attr(extern, name)
0326 
0327 # define DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name)           \
0328     attr type *name##_new(void);                                            \
0329     attr void name##_free(type *a);
0330 # define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name)                      \
0331     DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(extern, type, name)
0332 
0333 # define DECLARE_ASN1_DUP_FUNCTION_attr(attr, type)                         \
0334     DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, type)
0335 # define DECLARE_ASN1_DUP_FUNCTION(type)                                    \
0336     DECLARE_ASN1_DUP_FUNCTION_attr(extern, type)
0337 
0338 # define DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, name)              \
0339     attr type *name##_dup(const type *a);
0340 # define DECLARE_ASN1_DUP_FUNCTION_name(type, name)                         \
0341     DECLARE_ASN1_DUP_FUNCTION_name_attr(extern, type, name)
0342 
0343 # define DECLARE_ASN1_PRINT_FUNCTION_attr(attr, stname)                     \
0344     DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, stname)
0345 # define DECLARE_ASN1_PRINT_FUNCTION(stname)                                \
0346     DECLARE_ASN1_PRINT_FUNCTION_attr(extern, stname)
0347 
0348 # define DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, fname)        \
0349     attr int fname##_print_ctx(BIO *out, const stname *x, int indent,       \
0350                                const ASN1_PCTX *pctx);
0351 # define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname)                   \
0352     DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname)
0353 
0354 # define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
0355 # define I2D_OF(type) int (*)(const type *,unsigned char **)
0356 
0357 # define CHECKED_D2I_OF(type, d2i) \
0358     ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))
0359 # define CHECKED_I2D_OF(type, i2d) \
0360     ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))
0361 # define CHECKED_NEW_OF(type, xnew) \
0362     ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))
0363 # define CHECKED_PTR_OF(type, p) \
0364     ((void*) (1 ? p : (type*)0))
0365 # define CHECKED_PPTR_OF(type, p) \
0366     ((void**) (1 ? p : (type**)0))
0367 
0368 # define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
0369 # define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *,unsigned char **)
0370 # define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
0371 
0372 typedef void *d2i_of_void(void **, const unsigned char **, long);
0373 typedef int i2d_of_void(const void *, unsigned char **);
0374 
0375 /*-
0376  * The following macros and typedefs allow an ASN1_ITEM
0377  * to be embedded in a structure and referenced. Since
0378  * the ASN1_ITEM pointers need to be globally accessible
0379  * (possibly from shared libraries) they may exist in
0380  * different forms. On platforms that support it the
0381  * ASN1_ITEM structure itself will be globally exported.
0382  * Other platforms will export a function that returns
0383  * an ASN1_ITEM pointer.
0384  *
0385  * To handle both cases transparently the macros below
0386  * should be used instead of hard coding an ASN1_ITEM
0387  * pointer in a structure.
0388  *
0389  * The structure will look like this:
0390  *
0391  * typedef struct SOMETHING_st {
0392  *      ...
0393  *      ASN1_ITEM_EXP *iptr;
0394  *      ...
0395  * } SOMETHING;
0396  *
0397  * It would be initialised as e.g.:
0398  *
0399  * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
0400  *
0401  * and the actual pointer extracted with:
0402  *
0403  * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
0404  *
0405  * Finally an ASN1_ITEM pointer can be extracted from an
0406  * appropriate reference with: ASN1_ITEM_rptr(X509). This
0407  * would be used when a function takes an ASN1_ITEM * argument.
0408  *
0409  */
0410 
0411 
0412 /*
0413  * Platforms that can't easily handle shared global variables are declared as
0414  * functions returning ASN1_ITEM pointers.
0415  */
0416 
0417 /* ASN1_ITEM pointer exported type */
0418 typedef const ASN1_ITEM *ASN1_ITEM_EXP (void);
0419 
0420 /* Macro to obtain ASN1_ITEM pointer from exported type */
0421 # define ASN1_ITEM_ptr(iptr) (iptr())
0422 
0423 /* Macro to include ASN1_ITEM pointer from base type */
0424 # define ASN1_ITEM_ref(iptr) (iptr##_it)
0425 
0426 # define ASN1_ITEM_rptr(ref) (ref##_it())
0427 
0428 # define DECLARE_ASN1_ITEM_attr(attr, name)                                 \
0429     attr const ASN1_ITEM * name##_it(void);
0430 # define DECLARE_ASN1_ITEM(name)                                            \
0431     DECLARE_ASN1_ITEM_attr(extern, name)
0432 
0433 /* Parameters used by ASN1_STRING_print_ex() */
0434 
0435 /*
0436  * These determine which characters to escape: RFC2253 special characters,
0437  * control characters and MSB set characters
0438  */
0439 
0440 # define ASN1_STRFLGS_ESC_2253           1
0441 # define ASN1_STRFLGS_ESC_CTRL           2
0442 # define ASN1_STRFLGS_ESC_MSB            4
0443 
0444 /* Lower 8 bits are reserved as an output type specifier */
0445 # define ASN1_DTFLGS_TYPE_MASK    0x0FUL
0446 # define ASN1_DTFLGS_RFC822       0x00UL
0447 # define ASN1_DTFLGS_ISO8601      0x01UL
0448 
0449 /*
0450  * This flag determines how we do escaping: normally RC2253 backslash only,
0451  * set this to use backslash and quote.
0452  */
0453 
0454 # define ASN1_STRFLGS_ESC_QUOTE          8
0455 
0456 /* These three flags are internal use only. */
0457 
0458 /* Character is a valid PrintableString character */
0459 # define CHARTYPE_PRINTABLESTRING        0x10
0460 /* Character needs escaping if it is the first character */
0461 # define CHARTYPE_FIRST_ESC_2253         0x20
0462 /* Character needs escaping if it is the last character */
0463 # define CHARTYPE_LAST_ESC_2253          0x40
0464 
0465 /*
0466  * NB the internal flags are safely reused below by flags handled at the top
0467  * level.
0468  */
0469 
0470 /*
0471  * If this is set we convert all character strings to UTF8 first
0472  */
0473 
0474 # define ASN1_STRFLGS_UTF8_CONVERT       0x10
0475 
0476 /*
0477  * If this is set we don't attempt to interpret content: just assume all
0478  * strings are 1 byte per character. This will produce some pretty odd
0479  * looking output!
0480  */
0481 
0482 # define ASN1_STRFLGS_IGNORE_TYPE        0x20
0483 
0484 /* If this is set we include the string type in the output */
0485 # define ASN1_STRFLGS_SHOW_TYPE          0x40
0486 
0487 /*
0488  * This determines which strings to display and which to 'dump' (hex dump of
0489  * content octets or DER encoding). We can only dump non character strings or
0490  * everything. If we don't dump 'unknown' they are interpreted as character
0491  * strings with 1 octet per character and are subject to the usual escaping
0492  * options.
0493  */
0494 
0495 # define ASN1_STRFLGS_DUMP_ALL           0x80
0496 # define ASN1_STRFLGS_DUMP_UNKNOWN       0x100
0497 
0498 /*
0499  * These determine what 'dumping' does, we can dump the content octets or the
0500  * DER encoding: both use the RFC2253 #XXXXX notation.
0501  */
0502 
0503 # define ASN1_STRFLGS_DUMP_DER           0x200
0504 
0505 /*
0506  * This flag specifies that RC2254 escaping shall be performed.
0507  */
0508 #define ASN1_STRFLGS_ESC_2254           0x400
0509 
0510 /*
0511  * All the string flags consistent with RFC2253, escaping control characters
0512  * isn't essential in RFC2253 but it is advisable anyway.
0513  */
0514 
0515 # define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \
0516                                 ASN1_STRFLGS_ESC_CTRL | \
0517                                 ASN1_STRFLGS_ESC_MSB | \
0518                                 ASN1_STRFLGS_UTF8_CONVERT | \
0519                                 ASN1_STRFLGS_DUMP_UNKNOWN | \
0520                                 ASN1_STRFLGS_DUMP_DER)
0521 
0522 
0523 struct asn1_type_st {
0524     int type;
0525     union {
0526         char *ptr;
0527         ASN1_BOOLEAN boolean;
0528         ASN1_STRING *asn1_string;
0529         ASN1_OBJECT *object;
0530         ASN1_INTEGER *integer;
0531         ASN1_ENUMERATED *enumerated;
0532         ASN1_BIT_STRING *bit_string;
0533         ASN1_OCTET_STRING *octet_string;
0534         ASN1_PRINTABLESTRING *printablestring;
0535         ASN1_T61STRING *t61string;
0536         ASN1_IA5STRING *ia5string;
0537         ASN1_GENERALSTRING *generalstring;
0538         ASN1_BMPSTRING *bmpstring;
0539         ASN1_UNIVERSALSTRING *universalstring;
0540         ASN1_UTCTIME *utctime;
0541         ASN1_GENERALIZEDTIME *generalizedtime;
0542         ASN1_VISIBLESTRING *visiblestring;
0543         ASN1_UTF8STRING *utf8string;
0544         /*
0545          * set and sequence are left complete and still contain the set or
0546          * sequence bytes
0547          */
0548         ASN1_STRING *set;
0549         ASN1_STRING *sequence;
0550         ASN1_VALUE *asn1_value;
0551     } value;
0552 };
0553 
0554 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_TYPE, ASN1_TYPE, ASN1_TYPE)
0555 #define sk_ASN1_TYPE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_TYPE_sk_type(sk))
0556 #define sk_ASN1_TYPE_value(sk, idx) ((ASN1_TYPE *)OPENSSL_sk_value(ossl_check_const_ASN1_TYPE_sk_type(sk), (idx)))
0557 #define sk_ASN1_TYPE_new(cmp) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new(ossl_check_ASN1_TYPE_compfunc_type(cmp)))
0558 #define sk_ASN1_TYPE_new_null() ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_null())
0559 #define sk_ASN1_TYPE_new_reserve(cmp, n) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_TYPE_compfunc_type(cmp), (n)))
0560 #define sk_ASN1_TYPE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_TYPE_sk_type(sk), (n))
0561 #define sk_ASN1_TYPE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_TYPE_sk_type(sk))
0562 #define sk_ASN1_TYPE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_TYPE_sk_type(sk))
0563 #define sk_ASN1_TYPE_delete(sk, i) ((ASN1_TYPE *)OPENSSL_sk_delete(ossl_check_ASN1_TYPE_sk_type(sk), (i)))
0564 #define sk_ASN1_TYPE_delete_ptr(sk, ptr) ((ASN1_TYPE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)))
0565 #define sk_ASN1_TYPE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
0566 #define sk_ASN1_TYPE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
0567 #define sk_ASN1_TYPE_pop(sk) ((ASN1_TYPE *)OPENSSL_sk_pop(ossl_check_ASN1_TYPE_sk_type(sk)))
0568 #define sk_ASN1_TYPE_shift(sk) ((ASN1_TYPE *)OPENSSL_sk_shift(ossl_check_ASN1_TYPE_sk_type(sk)))
0569 #define sk_ASN1_TYPE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_TYPE_sk_type(sk),ossl_check_ASN1_TYPE_freefunc_type(freefunc))
0570 #define sk_ASN1_TYPE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr), (idx))
0571 #define sk_ASN1_TYPE_set(sk, idx, ptr) ((ASN1_TYPE *)OPENSSL_sk_set(ossl_check_ASN1_TYPE_sk_type(sk), (idx), ossl_check_ASN1_TYPE_type(ptr)))
0572 #define sk_ASN1_TYPE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
0573 #define sk_ASN1_TYPE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
0574 #define sk_ASN1_TYPE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr), pnum)
0575 #define sk_ASN1_TYPE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_TYPE_sk_type(sk))
0576 #define sk_ASN1_TYPE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_TYPE_sk_type(sk))
0577 #define sk_ASN1_TYPE_dup(sk) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_TYPE_sk_type(sk)))
0578 #define sk_ASN1_TYPE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_copyfunc_type(copyfunc), ossl_check_ASN1_TYPE_freefunc_type(freefunc)))
0579 #define sk_ASN1_TYPE_set_cmp_func(sk, cmp) ((sk_ASN1_TYPE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_compfunc_type(cmp)))
0580 
0581 
0582 typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
0583 
0584 DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
0585 DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)
0586 
0587 /* This is used to contain a list of bit names */
0588 typedef struct BIT_STRING_BITNAME_st {
0589     int bitnum;
0590     const char *lname;
0591     const char *sname;
0592 } BIT_STRING_BITNAME;
0593 
0594 # define B_ASN1_TIME \
0595                         B_ASN1_UTCTIME | \
0596                         B_ASN1_GENERALIZEDTIME
0597 
0598 # define B_ASN1_PRINTABLE \
0599                         B_ASN1_NUMERICSTRING| \
0600                         B_ASN1_PRINTABLESTRING| \
0601                         B_ASN1_T61STRING| \
0602                         B_ASN1_IA5STRING| \
0603                         B_ASN1_BIT_STRING| \
0604                         B_ASN1_UNIVERSALSTRING|\
0605                         B_ASN1_BMPSTRING|\
0606                         B_ASN1_UTF8STRING|\
0607                         B_ASN1_SEQUENCE|\
0608                         B_ASN1_UNKNOWN
0609 
0610 # define B_ASN1_DIRECTORYSTRING \
0611                         B_ASN1_PRINTABLESTRING| \
0612                         B_ASN1_TELETEXSTRING|\
0613                         B_ASN1_BMPSTRING|\
0614                         B_ASN1_UNIVERSALSTRING|\
0615                         B_ASN1_UTF8STRING
0616 
0617 # define B_ASN1_DISPLAYTEXT \
0618                         B_ASN1_IA5STRING| \
0619                         B_ASN1_VISIBLESTRING| \
0620                         B_ASN1_BMPSTRING|\
0621                         B_ASN1_UTF8STRING
0622 
0623 DECLARE_ASN1_ALLOC_FUNCTIONS_name(ASN1_TYPE, ASN1_TYPE)
0624 DECLARE_ASN1_ENCODE_FUNCTIONS(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
0625 
0626 int ASN1_TYPE_get(const ASN1_TYPE *a);
0627 void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
0628 int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
0629 int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
0630 
0631 ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);
0632 void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
0633 
0634 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_OBJECT, ASN1_OBJECT, ASN1_OBJECT)
0635 #define sk_ASN1_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_OBJECT_sk_type(sk))
0636 #define sk_ASN1_OBJECT_value(sk, idx) ((ASN1_OBJECT *)OPENSSL_sk_value(ossl_check_const_ASN1_OBJECT_sk_type(sk), (idx)))
0637 #define sk_ASN1_OBJECT_new(cmp) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new(ossl_check_ASN1_OBJECT_compfunc_type(cmp)))
0638 #define sk_ASN1_OBJECT_new_null() ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_null())
0639 #define sk_ASN1_OBJECT_new_reserve(cmp, n) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_OBJECT_compfunc_type(cmp), (n)))
0640 #define sk_ASN1_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_OBJECT_sk_type(sk), (n))
0641 #define sk_ASN1_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_ASN1_OBJECT_sk_type(sk))
0642 #define sk_ASN1_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_OBJECT_sk_type(sk))
0643 #define sk_ASN1_OBJECT_delete(sk, i) ((ASN1_OBJECT *)OPENSSL_sk_delete(ossl_check_ASN1_OBJECT_sk_type(sk), (i)))
0644 #define sk_ASN1_OBJECT_delete_ptr(sk, ptr) ((ASN1_OBJECT *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)))
0645 #define sk_ASN1_OBJECT_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
0646 #define sk_ASN1_OBJECT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
0647 #define sk_ASN1_OBJECT_pop(sk) ((ASN1_OBJECT *)OPENSSL_sk_pop(ossl_check_ASN1_OBJECT_sk_type(sk)))
0648 #define sk_ASN1_OBJECT_shift(sk) ((ASN1_OBJECT *)OPENSSL_sk_shift(ossl_check_ASN1_OBJECT_sk_type(sk)))
0649 #define sk_ASN1_OBJECT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_OBJECT_sk_type(sk),ossl_check_ASN1_OBJECT_freefunc_type(freefunc))
0650 #define sk_ASN1_OBJECT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr), (idx))
0651 #define sk_ASN1_OBJECT_set(sk, idx, ptr) ((ASN1_OBJECT *)OPENSSL_sk_set(ossl_check_ASN1_OBJECT_sk_type(sk), (idx), ossl_check_ASN1_OBJECT_type(ptr)))
0652 #define sk_ASN1_OBJECT_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
0653 #define sk_ASN1_OBJECT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
0654 #define sk_ASN1_OBJECT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr), pnum)
0655 #define sk_ASN1_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_OBJECT_sk_type(sk))
0656 #define sk_ASN1_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_OBJECT_sk_type(sk))
0657 #define sk_ASN1_OBJECT_dup(sk) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_ASN1_OBJECT_sk_type(sk)))
0658 #define sk_ASN1_OBJECT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_copyfunc_type(copyfunc), ossl_check_ASN1_OBJECT_freefunc_type(freefunc)))
0659 #define sk_ASN1_OBJECT_set_cmp_func(sk, cmp) ((sk_ASN1_OBJECT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_compfunc_type(cmp)))
0660 
0661 
0662 DECLARE_ASN1_FUNCTIONS(ASN1_OBJECT)
0663 
0664 ASN1_STRING *ASN1_STRING_new(void);
0665 void ASN1_STRING_free(ASN1_STRING *a);
0666 void ASN1_STRING_clear_free(ASN1_STRING *a);
0667 int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
0668 DECLARE_ASN1_DUP_FUNCTION(ASN1_STRING)
0669 ASN1_STRING *ASN1_STRING_type_new(int type);
0670 int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
0671   /*
0672    * Since this is used to store all sorts of things, via macros, for now,
0673    * make its data void *
0674    */
0675 int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
0676 void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
0677 int ASN1_STRING_length(const ASN1_STRING *x);
0678 # ifndef OPENSSL_NO_DEPRECATED_3_0
0679 OSSL_DEPRECATEDIN_3_0 void ASN1_STRING_length_set(ASN1_STRING *x, int n);
0680 # endif
0681 int ASN1_STRING_type(const ASN1_STRING *x);
0682 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0683 OSSL_DEPRECATEDIN_1_1_0 unsigned char *ASN1_STRING_data(ASN1_STRING *x);
0684 # endif
0685 const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);
0686 
0687 DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
0688 int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);
0689 int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
0690 int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);
0691 int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,
0692                           const unsigned char *flags, int flags_len);
0693 
0694 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
0695                                BIT_STRING_BITNAME *tbl, int indent);
0696 int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);
0697 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,
0698                             BIT_STRING_BITNAME *tbl);
0699 
0700 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_INTEGER, ASN1_INTEGER, ASN1_INTEGER)
0701 #define sk_ASN1_INTEGER_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk))
0702 #define sk_ASN1_INTEGER_value(sk, idx) ((ASN1_INTEGER *)OPENSSL_sk_value(ossl_check_const_ASN1_INTEGER_sk_type(sk), (idx)))
0703 #define sk_ASN1_INTEGER_new(cmp) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new(ossl_check_ASN1_INTEGER_compfunc_type(cmp)))
0704 #define sk_ASN1_INTEGER_new_null() ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_null())
0705 #define sk_ASN1_INTEGER_new_reserve(cmp, n) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_INTEGER_compfunc_type(cmp), (n)))
0706 #define sk_ASN1_INTEGER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_INTEGER_sk_type(sk), (n))
0707 #define sk_ASN1_INTEGER_free(sk) OPENSSL_sk_free(ossl_check_ASN1_INTEGER_sk_type(sk))
0708 #define sk_ASN1_INTEGER_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_INTEGER_sk_type(sk))
0709 #define sk_ASN1_INTEGER_delete(sk, i) ((ASN1_INTEGER *)OPENSSL_sk_delete(ossl_check_ASN1_INTEGER_sk_type(sk), (i)))
0710 #define sk_ASN1_INTEGER_delete_ptr(sk, ptr) ((ASN1_INTEGER *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)))
0711 #define sk_ASN1_INTEGER_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
0712 #define sk_ASN1_INTEGER_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
0713 #define sk_ASN1_INTEGER_pop(sk) ((ASN1_INTEGER *)OPENSSL_sk_pop(ossl_check_ASN1_INTEGER_sk_type(sk)))
0714 #define sk_ASN1_INTEGER_shift(sk) ((ASN1_INTEGER *)OPENSSL_sk_shift(ossl_check_ASN1_INTEGER_sk_type(sk)))
0715 #define sk_ASN1_INTEGER_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_INTEGER_sk_type(sk),ossl_check_ASN1_INTEGER_freefunc_type(freefunc))
0716 #define sk_ASN1_INTEGER_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr), (idx))
0717 #define sk_ASN1_INTEGER_set(sk, idx, ptr) ((ASN1_INTEGER *)OPENSSL_sk_set(ossl_check_ASN1_INTEGER_sk_type(sk), (idx), ossl_check_ASN1_INTEGER_type(ptr)))
0718 #define sk_ASN1_INTEGER_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
0719 #define sk_ASN1_INTEGER_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
0720 #define sk_ASN1_INTEGER_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr), pnum)
0721 #define sk_ASN1_INTEGER_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_INTEGER_sk_type(sk))
0722 #define sk_ASN1_INTEGER_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_INTEGER_sk_type(sk))
0723 #define sk_ASN1_INTEGER_dup(sk) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_dup(ossl_check_const_ASN1_INTEGER_sk_type(sk)))
0724 #define sk_ASN1_INTEGER_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_copyfunc_type(copyfunc), ossl_check_ASN1_INTEGER_freefunc_type(freefunc)))
0725 #define sk_ASN1_INTEGER_set_cmp_func(sk, cmp) ((sk_ASN1_INTEGER_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_compfunc_type(cmp)))
0726 
0727 
0728 
0729 DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
0730 ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
0731                                 long length);
0732 DECLARE_ASN1_DUP_FUNCTION(ASN1_INTEGER)
0733 int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
0734 
0735 DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
0736 
0737 int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
0738 ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);
0739 ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
0740                                int offset_day, long offset_sec);
0741 int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
0742 int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
0743 
0744 int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
0745 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
0746                                                time_t t);
0747 ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
0748                                                time_t t, int offset_day,
0749                                                long offset_sec);
0750 int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
0751 
0752 int ASN1_TIME_diff(int *pday, int *psec,
0753                    const ASN1_TIME *from, const ASN1_TIME *to);
0754 
0755 DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
0756 DECLARE_ASN1_DUP_FUNCTION(ASN1_OCTET_STRING)
0757 int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
0758                           const ASN1_OCTET_STRING *b);
0759 int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
0760                           int len);
0761 
0762 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_UTF8STRING, ASN1_UTF8STRING, ASN1_UTF8STRING)
0763 #define sk_ASN1_UTF8STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_UTF8STRING_sk_type(sk))
0764 #define sk_ASN1_UTF8STRING_value(sk, idx) ((ASN1_UTF8STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), (idx)))
0765 #define sk_ASN1_UTF8STRING_new(cmp) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp)))
0766 #define sk_ASN1_UTF8STRING_new_null() ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_null())
0767 #define sk_ASN1_UTF8STRING_new_reserve(cmp, n) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp), (n)))
0768 #define sk_ASN1_UTF8STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_UTF8STRING_sk_type(sk), (n))
0769 #define sk_ASN1_UTF8STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_UTF8STRING_sk_type(sk))
0770 #define sk_ASN1_UTF8STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_UTF8STRING_sk_type(sk))
0771 #define sk_ASN1_UTF8STRING_delete(sk, i) ((ASN1_UTF8STRING *)OPENSSL_sk_delete(ossl_check_ASN1_UTF8STRING_sk_type(sk), (i)))
0772 #define sk_ASN1_UTF8STRING_delete_ptr(sk, ptr) ((ASN1_UTF8STRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)))
0773 #define sk_ASN1_UTF8STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
0774 #define sk_ASN1_UTF8STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
0775 #define sk_ASN1_UTF8STRING_pop(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_pop(ossl_check_ASN1_UTF8STRING_sk_type(sk)))
0776 #define sk_ASN1_UTF8STRING_shift(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_shift(ossl_check_ASN1_UTF8STRING_sk_type(sk)))
0777 #define sk_ASN1_UTF8STRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_UTF8STRING_sk_type(sk),ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc))
0778 #define sk_ASN1_UTF8STRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr), (idx))
0779 #define sk_ASN1_UTF8STRING_set(sk, idx, ptr) ((ASN1_UTF8STRING *)OPENSSL_sk_set(ossl_check_ASN1_UTF8STRING_sk_type(sk), (idx), ossl_check_ASN1_UTF8STRING_type(ptr)))
0780 #define sk_ASN1_UTF8STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
0781 #define sk_ASN1_UTF8STRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
0782 #define sk_ASN1_UTF8STRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr), pnum)
0783 #define sk_ASN1_UTF8STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_UTF8STRING_sk_type(sk))
0784 #define sk_ASN1_UTF8STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_UTF8STRING_sk_type(sk))
0785 #define sk_ASN1_UTF8STRING_dup(sk) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)))
0786 #define sk_ASN1_UTF8STRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_copyfunc_type(copyfunc), ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc)))
0787 #define sk_ASN1_UTF8STRING_set_cmp_func(sk, cmp) ((sk_ASN1_UTF8STRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_compfunc_type(cmp)))
0788 
0789 
0790 DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
0791 DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
0792 DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
0793 DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
0794 DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
0795 
0796 int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
0797 int UTF8_putc(unsigned char *str, int len, unsigned long value);
0798 
0799 SKM_DEFINE_STACK_OF_INTERNAL(ASN1_GENERALSTRING, ASN1_GENERALSTRING, ASN1_GENERALSTRING)
0800 #define sk_ASN1_GENERALSTRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))
0801 #define sk_ASN1_GENERALSTRING_value(sk, idx) ((ASN1_GENERALSTRING *)OPENSSL_sk_value(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), (idx)))
0802 #define sk_ASN1_GENERALSTRING_new(cmp) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp)))
0803 #define sk_ASN1_GENERALSTRING_new_null() ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_null())
0804 #define sk_ASN1_GENERALSTRING_new_reserve(cmp, n) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp), (n)))
0805 #define sk_ASN1_GENERALSTRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (n))
0806 #define sk_ASN1_GENERALSTRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk))
0807 #define sk_ASN1_GENERALSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_GENERALSTRING_sk_type(sk))
0808 #define sk_ASN1_GENERALSTRING_delete(sk, i) ((ASN1_GENERALSTRING *)OPENSSL_sk_delete(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (i)))
0809 #define sk_ASN1_GENERALSTRING_delete_ptr(sk, ptr) ((ASN1_GENERALSTRING *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)))
0810 #define sk_ASN1_GENERALSTRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
0811 #define sk_ASN1_GENERALSTRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
0812 #define sk_ASN1_GENERALSTRING_pop(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_pop(ossl_check_ASN1_GENERALSTRING_sk_type(sk)))
0813 #define sk_ASN1_GENERALSTRING_shift(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_shift(ossl_check_ASN1_GENERALSTRING_sk_type(sk)))
0814 #define sk_ASN1_GENERALSTRING_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk),ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc))
0815 #define sk_ASN1_GENERALSTRING_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr), (idx))
0816 #define sk_ASN1_GENERALSTRING_set(sk, idx, ptr) ((ASN1_GENERALSTRING *)OPENSSL_sk_set(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (idx), ossl_check_ASN1_GENERALSTRING_type(ptr)))
0817 #define sk_ASN1_GENERALSTRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
0818 #define sk_ASN1_GENERALSTRING_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
0819 #define sk_ASN1_GENERALSTRING_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr), pnum)
0820 #define sk_ASN1_GENERALSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_GENERALSTRING_sk_type(sk))
0821 #define sk_ASN1_GENERALSTRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))
0822 #define sk_ASN1_GENERALSTRING_dup(sk) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)))
0823 #define sk_ASN1_GENERALSTRING_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_copyfunc_type(copyfunc), ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc)))
0824 #define sk_ASN1_GENERALSTRING_set_cmp_func(sk, cmp) ((sk_ASN1_GENERALSTRING_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp)))
0825 
0826 
0827 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
0828 
0829 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
0830 DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
0831 DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
0832 DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
0833 DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
0834 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
0835 DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
0836 DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
0837 DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
0838 
0839 DECLARE_ASN1_DUP_FUNCTION(ASN1_TIME)
0840 DECLARE_ASN1_DUP_FUNCTION(ASN1_UTCTIME)
0841 DECLARE_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME)
0842 
0843 DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
0844 
0845 ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
0846 ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
0847                          int offset_day, long offset_sec);
0848 int ASN1_TIME_check(const ASN1_TIME *t);
0849 ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
0850                                                    ASN1_GENERALIZEDTIME **out);
0851 int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
0852 int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str);
0853 int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);
0854 int ASN1_TIME_normalize(ASN1_TIME *s);
0855 int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t);
0856 int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b);
0857 
0858 int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a);
0859 int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);
0860 int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a);
0861 int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);
0862 int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a);
0863 int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);
0864 int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);
0865 int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);
0866 
0867 int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);
0868 ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
0869                                 const char *sn, const char *ln);
0870 
0871 int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);
0872 int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
0873 int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
0874 int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
0875 
0876 int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
0877 long ASN1_INTEGER_get(const ASN1_INTEGER *a);
0878 ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
0879 BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
0880 
0881 int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);
0882 int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);
0883 
0884 
0885 int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
0886 long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
0887 ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);
0888 BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);
0889 
0890 /* General */
0891 /* given a string, return the correct type, max is the maximum length */
0892 int ASN1_PRINTABLE_type(const unsigned char *s, int max);
0893 
0894 unsigned long ASN1_tag2bit(int tag);
0895 
0896 /* SPECIALS */
0897 int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
0898                     int *pclass, long omax);
0899 int ASN1_check_infinite_end(unsigned char **p, long len);
0900 int ASN1_const_check_infinite_end(const unsigned char **p, long len);
0901 void ASN1_put_object(unsigned char **pp, int constructed, int length,
0902                      int tag, int xclass);
0903 int ASN1_put_eoc(unsigned char **pp);
0904 int ASN1_object_size(int constructed, int length, int tag);
0905 
0906 /* Used to implement other functions */
0907 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x);
0908 
0909 # define ASN1_dup_of(type,i2d,d2i,x) \
0910     ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
0911                      CHECKED_D2I_OF(type, d2i), \
0912                      CHECKED_PTR_OF(const type, x)))
0913 
0914 void *ASN1_item_dup(const ASN1_ITEM *it, const void *x);
0915 int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1,
0916                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
0917                       const void *data, const ASN1_OCTET_STRING *id,
0918                       EVP_PKEY *pkey, const EVP_MD *md, OSSL_LIB_CTX *libctx,
0919                       const char *propq);
0920 int ASN1_item_verify_ex(const ASN1_ITEM *it, const X509_ALGOR *alg,
0921                         const ASN1_BIT_STRING *signature, const void *data,
0922                         const ASN1_OCTET_STRING *id, EVP_PKEY *pkey,
0923                         OSSL_LIB_CTX *libctx, const char *propq);
0924 
0925 /* ASN1 alloc/free macros for when a type is only used internally */
0926 
0927 # define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))
0928 # define M_ASN1_free_of(x, type) \
0929                 ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))
0930 
0931 # ifndef OPENSSL_NO_STDIO
0932 void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);
0933 
0934 #  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
0935     ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \
0936                         CHECKED_D2I_OF(type, d2i), \
0937                         in, \
0938                         CHECKED_PPTR_OF(type, x)))
0939 
0940 void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x,
0941                           OSSL_LIB_CTX *libctx, const char *propq);
0942 void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
0943 int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x);
0944 
0945 #  define ASN1_i2d_fp_of(type,i2d,out,x) \
0946     (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \
0947                  out, \
0948                  CHECKED_PTR_OF(const type, x)))
0949 
0950 int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x);
0951 int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);
0952 # endif
0953 
0954 int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);
0955 
0956 void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);
0957 
0958 #  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
0959     ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \
0960                           CHECKED_D2I_OF(type, d2i), \
0961                           in, \
0962                           CHECKED_PPTR_OF(type, x)))
0963 
0964 void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *pval,
0965                            OSSL_LIB_CTX *libctx, const char *propq);
0966 void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *pval);
0967 int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x);
0968 
0969 #  define ASN1_i2d_bio_of(type,i2d,out,x) \
0970     (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \
0971                   out, \
0972                   CHECKED_PTR_OF(const type, x)))
0973 
0974 int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x);
0975 BIO *ASN1_item_i2d_mem_bio(const ASN1_ITEM *it, const ASN1_VALUE *val);
0976 int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
0977 int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
0978 int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm);
0979 int ASN1_TIME_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags);
0980 int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
0981 int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);
0982 int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off);
0983 int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
0984                   unsigned char *buf, int off);
0985 int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);
0986 int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,
0987                     int dump);
0988 const char *ASN1_tag2str(int tag);
0989 
0990 /* Used to load and write Netscape format cert */
0991 
0992 int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
0993 
0994 int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);
0995 int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len);
0996 int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
0997                                   unsigned char *data, int len);
0998 int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num,
0999                                   unsigned char *data, int max_len);
1000 
1001 void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it);
1002 void *ASN1_item_unpack_ex(const ASN1_STRING *oct, const ASN1_ITEM *it,
1003                           OSSL_LIB_CTX *libctx, const char *propq);
1004 
1005 ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,
1006                             ASN1_OCTET_STRING **oct);
1007 
1008 void ASN1_STRING_set_default_mask(unsigned long mask);
1009 int ASN1_STRING_set_default_mask_asc(const char *p);
1010 unsigned long ASN1_STRING_get_default_mask(void);
1011 int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
1012                        int inform, unsigned long mask);
1013 int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
1014                         int inform, unsigned long mask,
1015                         long minsize, long maxsize);
1016 
1017 ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
1018                                     const unsigned char *in, int inlen,
1019                                     int inform, int nid);
1020 ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
1021 int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
1022 void ASN1_STRING_TABLE_cleanup(void);
1023 
1024 /* ASN1 template functions */
1025 
1026 /* Old API compatible functions */
1027 ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
1028 ASN1_VALUE *ASN1_item_new_ex(const ASN1_ITEM *it, OSSL_LIB_CTX *libctx,
1029                              const char *propq);
1030 void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
1031 ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **val, const unsigned char **in,
1032                              long len, const ASN1_ITEM *it,
1033                              OSSL_LIB_CTX *libctx, const char *propq);
1034 ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,
1035                           long len, const ASN1_ITEM *it);
1036 int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
1037 int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out,
1038                        const ASN1_ITEM *it);
1039 
1040 void ASN1_add_oid_module(void);
1041 void ASN1_add_stable_module(void);
1042 
1043 ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf);
1044 ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf);
1045 int ASN1_str2mask(const char *str, unsigned long *pmask);
1046 
1047 /* ASN1 Print flags */
1048 
1049 /* Indicate missing OPTIONAL fields */
1050 # define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001
1051 /* Mark start and end of SEQUENCE */
1052 # define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002
1053 /* Mark start and end of SEQUENCE/SET OF */
1054 # define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004
1055 /* Show the ASN1 type of primitives */
1056 # define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008
1057 /* Don't show ASN1 type of ANY */
1058 # define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010
1059 /* Don't show ASN1 type of MSTRINGs */
1060 # define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020
1061 /* Don't show field names in SEQUENCE */
1062 # define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040
1063 /* Show structure names of each SEQUENCE field */
1064 # define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080
1065 /* Don't show structure name even at top level */
1066 # define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100
1067 
1068 int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent,
1069                     const ASN1_ITEM *it, const ASN1_PCTX *pctx);
1070 ASN1_PCTX *ASN1_PCTX_new(void);
1071 void ASN1_PCTX_free(ASN1_PCTX *p);
1072 unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p);
1073 void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
1074 unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p);
1075 void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
1076 unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p);
1077 void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
1078 unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p);
1079 void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
1080 unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p);
1081 void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
1082 
1083 ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx));
1084 void ASN1_SCTX_free(ASN1_SCTX *p);
1085 const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p);
1086 const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p);
1087 unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p);
1088 void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data);
1089 void *ASN1_SCTX_get_app_data(ASN1_SCTX *p);
1090 
1091 const BIO_METHOD *BIO_f_asn1(void);
1092 
1093 /* cannot constify val because of CMS_stream() */
1094 BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
1095 
1096 int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
1097                         const ASN1_ITEM *it);
1098 int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
1099                               const char *hdr, const ASN1_ITEM *it);
1100 /* cannot constify val because of CMS_dataFinal() */
1101 int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
1102                      int ctype_nid, int econt_nid,
1103                      STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);
1104 int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
1105                         int ctype_nid, int econt_nid,
1106                         STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it,
1107                         OSSL_LIB_CTX *libctx, const char *propq);
1108 ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
1109 ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, int flags, BIO **bcont,
1110                                const ASN1_ITEM *it, ASN1_VALUE **x,
1111                                OSSL_LIB_CTX *libctx, const char *propq);
1112 int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
1113 int SMIME_text(BIO *in, BIO *out);
1114 
1115 const ASN1_ITEM *ASN1_ITEM_lookup(const char *name);
1116 const ASN1_ITEM *ASN1_ITEM_get(size_t i);
1117 
1118 /* Legacy compatibility */
1119 # define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
1120          DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
1121          DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
1122 # define DECLARE_ASN1_FUNCTIONS_const(type) DECLARE_ASN1_FUNCTIONS(type)
1123 # define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
1124          DECLARE_ASN1_ENCODE_FUNCTIONS(type, name)
1125 # define I2D_OF_const(type) I2D_OF(type)
1126 # define ASN1_dup_of_const(type,i2d,d2i,x) ASN1_dup_of(type,i2d,d2i,x)
1127 # define ASN1_i2d_fp_of_const(type,i2d,out,x) ASN1_i2d_fp_of(type,i2d,out,x)
1128 # define ASN1_i2d_bio_of_const(type,i2d,out,x) ASN1_i2d_bio_of(type,i2d,out,x)
1129 
1130 # ifdef  __cplusplus
1131 }
1132 # endif
1133 #endif