| 1 | /* |
| 2 | * WARNING: do not edit! |
| 3 | * Generated by Makefile from include/openssl/asn1.h.in |
| 4 | * |
| 5 | * Copyright 1995-2026 The OpenSSL Project Authors. All Rights Reserved. |
| 6 | * |
| 7 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
| 8 | * this file except in compliance with the License. You can obtain a copy |
| 9 | * in the file LICENSE in the source distribution or at |
| 10 | * https://www.openssl.org/source/license.html |
| 11 | */ |
| 12 | |
| 13 | /* clang-format off */ |
| 14 | |
| 15 | /* clang-format on */ |
| 16 | |
| 17 | #ifndef OPENSSL_ASN1_H |
| 18 | #define OPENSSL_ASN1_H |
| 19 | #pragma once |
| 20 | |
| 21 | #include <openssl/macros.h> |
| 22 | #ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 23 | #define |
| 24 | #endif |
| 25 | |
| 26 | #ifndef OPENSSL_NO_STDIO |
| 27 | #include <stdio.h> |
| 28 | #endif |
| 29 | #include <time.h> |
| 30 | #include <openssl/e_os2.h> |
| 31 | #include <openssl/opensslconf.h> |
| 32 | #include <openssl/bio.h> |
| 33 | #include <openssl/safestack.h> |
| 34 | #include <openssl/asn1err.h> |
| 35 | #include <openssl/symhacks.h> |
| 36 | |
| 37 | #include <openssl/types.h> |
| 38 | #include <openssl/bn.h> |
| 39 | |
| 40 | #ifdef OPENSSL_BUILD_SHLIBCRYPTO |
| 41 | #undef OPENSSL_EXTERN |
| 42 | #define OPENSSL_EXTERN OPENSSL_EXPORT |
| 43 | #endif |
| 44 | |
| 45 | #ifdef __cplusplus |
| 46 | extern "C" { |
| 47 | #endif |
| 48 | |
| 49 | #define V_ASN1_UNIVERSAL 0x00 |
| 50 | #define V_ASN1_APPLICATION 0x40 |
| 51 | #define V_ASN1_CONTEXT_SPECIFIC 0x80 |
| 52 | #define V_ASN1_PRIVATE 0xc0 |
| 53 | |
| 54 | #define V_ASN1_CONSTRUCTED 0x20 |
| 55 | #define V_ASN1_PRIMITIVE_TAG 0x1f |
| 56 | #define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG |
| 57 | |
| 58 | #define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ |
| 59 | #define V_ASN1_OTHER -3 /* used in ASN1_TYPE */ |
| 60 | #define V_ASN1_ANY -4 /* used in ASN1 template code */ |
| 61 | |
| 62 | #define V_ASN1_UNDEF -1 |
| 63 | /* ASN.1 tag values */ |
| 64 | #define V_ASN1_EOC 0 |
| 65 | #define V_ASN1_BOOLEAN 1 |
| 66 | #define V_ASN1_INTEGER 2 |
| 67 | #define V_ASN1_BIT_STRING 3 |
| 68 | #define V_ASN1_OCTET_STRING 4 |
| 69 | #define V_ASN1_NULL 5 |
| 70 | #define V_ASN1_OBJECT 6 |
| 71 | #define V_ASN1_OBJECT_DESCRIPTOR 7 |
| 72 | #define V_ASN1_EXTERNAL 8 |
| 73 | #define V_ASN1_REAL 9 |
| 74 | #define V_ASN1_ENUMERATED 10 |
| 75 | #define V_ASN1_UTF8STRING 12 |
| 76 | #define V_ASN1_SEQUENCE 16 |
| 77 | #define V_ASN1_SET 17 |
| 78 | #define V_ASN1_NUMERICSTRING 18 |
| 79 | #define V_ASN1_PRINTABLESTRING 19 |
| 80 | #define V_ASN1_T61STRING 20 |
| 81 | #define V_ASN1_TELETEXSTRING 20 /* alias */ |
| 82 | #define V_ASN1_VIDEOTEXSTRING 21 |
| 83 | #define V_ASN1_IA5STRING 22 |
| 84 | #define V_ASN1_UTCTIME 23 |
| 85 | #define V_ASN1_GENERALIZEDTIME 24 |
| 86 | #define V_ASN1_GRAPHICSTRING 25 |
| 87 | #define V_ASN1_ISO64STRING 26 |
| 88 | #define V_ASN1_VISIBLESTRING 26 /* alias */ |
| 89 | #define V_ASN1_GENERALSTRING 27 |
| 90 | #define V_ASN1_UNIVERSALSTRING 28 |
| 91 | #define V_ASN1_BMPSTRING 30 |
| 92 | |
| 93 | /* |
| 94 | * NB the constants below are used internally by ASN1_INTEGER |
| 95 | * and ASN1_ENUMERATED to indicate the sign. They are *not* on |
| 96 | * the wire tag values. |
| 97 | */ |
| 98 | |
| 99 | #define V_ASN1_NEG 0x100 |
| 100 | #define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) |
| 101 | #define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) |
| 102 | |
| 103 | /* For use with d2i_ASN1_type_bytes() */ |
| 104 | #define B_ASN1_NUMERICSTRING 0x0001 |
| 105 | #define B_ASN1_PRINTABLESTRING 0x0002 |
| 106 | #define B_ASN1_T61STRING 0x0004 |
| 107 | #define B_ASN1_TELETEXSTRING 0x0004 |
| 108 | #define B_ASN1_VIDEOTEXSTRING 0x0008 |
| 109 | #define B_ASN1_IA5STRING 0x0010 |
| 110 | #define B_ASN1_GRAPHICSTRING 0x0020 |
| 111 | #define B_ASN1_ISO64STRING 0x0040 |
| 112 | #define B_ASN1_VISIBLESTRING 0x0040 |
| 113 | #define B_ASN1_GENERALSTRING 0x0080 |
| 114 | #define B_ASN1_UNIVERSALSTRING 0x0100 |
| 115 | #define B_ASN1_OCTET_STRING 0x0200 |
| 116 | #define B_ASN1_BIT_STRING 0x0400 |
| 117 | #define B_ASN1_BMPSTRING 0x0800 |
| 118 | #define B_ASN1_UNKNOWN 0x1000 |
| 119 | #define B_ASN1_UTF8STRING 0x2000 |
| 120 | #define B_ASN1_UTCTIME 0x4000 |
| 121 | #define B_ASN1_GENERALIZEDTIME 0x8000 |
| 122 | #define B_ASN1_SEQUENCE 0x10000 |
| 123 | /* For use with ASN1_mbstring_copy() */ |
| 124 | #define MBSTRING_FLAG 0x1000 |
| 125 | #define MBSTRING_UTF8 (MBSTRING_FLAG) |
| 126 | #define MBSTRING_ASC (MBSTRING_FLAG | 1) |
| 127 | #define MBSTRING_BMP (MBSTRING_FLAG | 2) |
| 128 | #define MBSTRING_UNIV (MBSTRING_FLAG | 4) |
| 129 | #define SMIME_OLDMIME 0x400 |
| 130 | #define SMIME_CRLFEOL 0x800 |
| 131 | #define SMIME_STREAM 0x1000 |
| 132 | |
| 133 | /* Stacks for types not otherwise defined in this header */ |
| 134 | /* clang-format off */ |
| 135 | SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR) |
| 136 | #define sk_X509_ALGOR_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_type(sk)) |
| 137 | #define sk_X509_ALGOR_value(sk, idx) ((X509_ALGOR *)OPENSSL_sk_value(ossl_check_const_X509_ALGOR_sk_type(sk), (idx))) |
| 138 | #define sk_X509_ALGOR_new(cmp) \ |
| 139 | ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_set_thunks( \ |
| 140 | OPENSSL_sk_set_copy_thunks( \ |
| 141 | OPENSSL_sk_set_cmp_thunks( \ |
| 142 | OPENSSL_sk_new(ossl_check_X509_ALGOR_compfunc_type(cmp)), \ |
| 143 | sk_X509_ALGOR_cmpfunc_thunk), \ |
| 144 | sk_X509_ALGOR_copyfunc_thunk), \ |
| 145 | sk_X509_ALGOR_freefunc_thunk)) |
| 146 | #define sk_X509_ALGOR_new_null() \ |
| 147 | ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_set_thunks( \ |
| 148 | OPENSSL_sk_set_copy_thunks( \ |
| 149 | OPENSSL_sk_set_cmp_thunks( \ |
| 150 | OPENSSL_sk_new_null(), \ |
| 151 | sk_X509_ALGOR_cmpfunc_thunk), \ |
| 152 | sk_X509_ALGOR_copyfunc_thunk), \ |
| 153 | sk_X509_ALGOR_freefunc_thunk)) |
| 154 | #define sk_X509_ALGOR_new_reserve(cmp, n) \ |
| 155 | ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_set_thunks( \ |
| 156 | OPENSSL_sk_set_copy_thunks( \ |
| 157 | OPENSSL_sk_set_cmp_thunks( \ |
| 158 | OPENSSL_sk_new_reserve(ossl_check_X509_ALGOR_compfunc_type(cmp), (n)), \ |
| 159 | sk_X509_ALGOR_cmpfunc_thunk), \ |
| 160 | sk_X509_ALGOR_copyfunc_thunk), \ |
| 161 | sk_X509_ALGOR_freefunc_thunk)) |
| 162 | #define sk_X509_ALGOR_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ALGOR_sk_type(sk), (n)) |
| 163 | #define sk_X509_ALGOR_free(sk) OPENSSL_sk_free(ossl_check_X509_ALGOR_sk_type(sk)) |
| 164 | #define sk_X509_ALGOR_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ALGOR_sk_type(sk)) |
| 165 | #define sk_X509_ALGOR_delete(sk, i) ((X509_ALGOR *)OPENSSL_sk_delete(ossl_check_X509_ALGOR_sk_type(sk), (i))) |
| 166 | #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))) |
| 167 | #define sk_X509_ALGOR_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) |
| 168 | #define sk_X509_ALGOR_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) |
| 169 | #define sk_X509_ALGOR_pop(sk) ((X509_ALGOR *)OPENSSL_sk_pop(ossl_check_X509_ALGOR_sk_type(sk))) |
| 170 | #define sk_X509_ALGOR_shift(sk) ((X509_ALGOR *)OPENSSL_sk_shift(ossl_check_X509_ALGOR_sk_type(sk))) |
| 171 | #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)) |
| 172 | #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)) |
| 173 | #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))) |
| 174 | #define sk_X509_ALGOR_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr)) |
| 175 | #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)) |
| 176 | #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) |
| 177 | #define sk_X509_ALGOR_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ALGOR_sk_type(sk)) |
| 178 | #define sk_X509_ALGOR_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ALGOR_sk_type(sk)) |
| 179 | #define sk_X509_ALGOR_dup(sk) \ |
| 180 | ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_set_thunks( \ |
| 181 | OPENSSL_sk_set_copy_thunks( \ |
| 182 | OPENSSL_sk_set_cmp_thunks( \ |
| 183 | OPENSSL_sk_dup(ossl_check_const_X509_ALGOR_sk_type(sk)), \ |
| 184 | sk_X509_ALGOR_cmpfunc_thunk), \ |
| 185 | sk_X509_ALGOR_copyfunc_thunk), \ |
| 186 | sk_X509_ALGOR_freefunc_thunk)) |
| 187 | #define sk_X509_ALGOR_deep_copy(sk, copyfunc, freefunc) \ |
| 188 | ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_set_thunks( \ |
| 189 | OPENSSL_sk_set_copy_thunks( \ |
| 190 | OPENSSL_sk_set_cmp_thunks( \ |
| 191 | OPENSSL_sk_deep_copy( \ |
| 192 | ossl_check_const_X509_ALGOR_sk_type(sk), \ |
| 193 | ossl_check_X509_ALGOR_copyfunc_type(copyfunc), \ |
| 194 | ossl_check_X509_ALGOR_freefunc_type(freefunc)), \ |
| 195 | sk_X509_ALGOR_cmpfunc_thunk), \ |
| 196 | sk_X509_ALGOR_copyfunc_thunk), \ |
| 197 | sk_X509_ALGOR_freefunc_thunk)) |
| 198 | #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))) |
| 199 | |
| 200 | /* clang-format on */ |
| 201 | |
| 202 | /* This is the base type that holds just about everything :-) */ |
| 203 | struct asn1_string_st; |
| 204 | |
| 205 | /* |
| 206 | * ASN1_ENCODING structure: this is used to save the received encoding of an |
| 207 | * ASN1 type. This is useful to get round problems with invalid encodings |
| 208 | * which can break signatures. |
| 209 | */ |
| 210 | |
| 211 | typedef struct ASN1_ENCODING_st { |
| 212 | unsigned char *enc; /* DER encoding */ |
| 213 | long len; /* Length of encoding */ |
| 214 | int modified; /* set to 1 if 'enc' is invalid */ |
| 215 | } ASN1_ENCODING; |
| 216 | |
| 217 | /* Used with ASN1 LONG type: if a long is set to this it is omitted */ |
| 218 | #define ASN1_LONG_UNDEF 0x7fffffffL |
| 219 | |
| 220 | #define STABLE_FLAGS_MALLOC 0x01 |
| 221 | /* |
| 222 | * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted |
| 223 | * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting |
| 224 | * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias |
| 225 | * STABLE_FLAGS_CLEAR to reflect this. |
| 226 | */ |
| 227 | #define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC |
| 228 | #define STABLE_NO_MASK 0x02 |
| 229 | #define DIRSTRING_TYPE \ |
| 230 | (B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING) |
| 231 | #define PKCS9STRING_TYPE (DIRSTRING_TYPE | B_ASN1_IA5STRING) |
| 232 | |
| 233 | struct asn1_string_table_st { |
| 234 | int nid; |
| 235 | long minsize; |
| 236 | long maxsize; |
| 237 | unsigned long mask; |
| 238 | unsigned long flags; |
| 239 | }; |
| 240 | |
| 241 | /* clang-format off */ |
| 242 | SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING_TABLE, ASN1_STRING_TABLE, ASN1_STRING_TABLE) |
| 243 | #define sk_ASN1_STRING_TABLE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) |
| 244 | #define sk_ASN1_STRING_TABLE_value(sk, idx) ((ASN1_STRING_TABLE *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), (idx))) |
| 245 | #define sk_ASN1_STRING_TABLE_new(cmp) \ |
| 246 | ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_set_thunks( \ |
| 247 | OPENSSL_sk_set_copy_thunks( \ |
| 248 | OPENSSL_sk_set_cmp_thunks( \ |
| 249 | OPENSSL_sk_new(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp)), \ |
| 250 | sk_ASN1_STRING_TABLE_cmpfunc_thunk), \ |
| 251 | sk_ASN1_STRING_TABLE_copyfunc_thunk), \ |
| 252 | sk_ASN1_STRING_TABLE_freefunc_thunk)) |
| 253 | #define sk_ASN1_STRING_TABLE_new_null() \ |
| 254 | ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_set_thunks( \ |
| 255 | OPENSSL_sk_set_copy_thunks( \ |
| 256 | OPENSSL_sk_set_cmp_thunks( \ |
| 257 | OPENSSL_sk_new_null(), \ |
| 258 | sk_ASN1_STRING_TABLE_cmpfunc_thunk), \ |
| 259 | sk_ASN1_STRING_TABLE_copyfunc_thunk), \ |
| 260 | sk_ASN1_STRING_TABLE_freefunc_thunk)) |
| 261 | #define sk_ASN1_STRING_TABLE_new_reserve(cmp, n) \ |
| 262 | ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_set_thunks( \ |
| 263 | OPENSSL_sk_set_copy_thunks( \ |
| 264 | OPENSSL_sk_set_cmp_thunks( \ |
| 265 | OPENSSL_sk_new_reserve(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp), (n)), \ |
| 266 | sk_ASN1_STRING_TABLE_cmpfunc_thunk), \ |
| 267 | sk_ASN1_STRING_TABLE_copyfunc_thunk), \ |
| 268 | sk_ASN1_STRING_TABLE_freefunc_thunk)) |
| 269 | #define sk_ASN1_STRING_TABLE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (n)) |
| 270 | #define sk_ASN1_STRING_TABLE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) |
| 271 | #define sk_ASN1_STRING_TABLE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) |
| 272 | #define sk_ASN1_STRING_TABLE_delete(sk, i) ((ASN1_STRING_TABLE *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (i))) |
| 273 | #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))) |
| 274 | #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)) |
| 275 | #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)) |
| 276 | #define sk_ASN1_STRING_TABLE_pop(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_TABLE_sk_type(sk))) |
| 277 | #define sk_ASN1_STRING_TABLE_shift(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_TABLE_sk_type(sk))) |
| 278 | #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)) |
| 279 | #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)) |
| 280 | #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))) |
| 281 | #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)) |
| 282 | #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)) |
| 283 | #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) |
| 284 | #define sk_ASN1_STRING_TABLE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_TABLE_sk_type(sk)) |
| 285 | #define sk_ASN1_STRING_TABLE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)) |
| 286 | #define sk_ASN1_STRING_TABLE_dup(sk) \ |
| 287 | ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_set_thunks( \ |
| 288 | OPENSSL_sk_set_copy_thunks( \ |
| 289 | OPENSSL_sk_set_cmp_thunks( \ |
| 290 | OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)), \ |
| 291 | sk_ASN1_STRING_TABLE_cmpfunc_thunk), \ |
| 292 | sk_ASN1_STRING_TABLE_copyfunc_thunk), \ |
| 293 | sk_ASN1_STRING_TABLE_freefunc_thunk)) |
| 294 | #define sk_ASN1_STRING_TABLE_deep_copy(sk, copyfunc, freefunc) \ |
| 295 | ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_set_thunks( \ |
| 296 | OPENSSL_sk_set_copy_thunks( \ |
| 297 | OPENSSL_sk_set_cmp_thunks( \ |
| 298 | OPENSSL_sk_deep_copy( \ |
| 299 | ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), \ |
| 300 | ossl_check_ASN1_STRING_TABLE_copyfunc_type(copyfunc), \ |
| 301 | ossl_check_ASN1_STRING_TABLE_freefunc_type(freefunc)), \ |
| 302 | sk_ASN1_STRING_TABLE_cmpfunc_thunk), \ |
| 303 | sk_ASN1_STRING_TABLE_copyfunc_thunk), \ |
| 304 | sk_ASN1_STRING_TABLE_freefunc_thunk)) |
| 305 | #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))) |
| 306 | |
| 307 | /* clang-format on */ |
| 308 | |
| 309 | /* size limits: this stuff is taken straight from RFC 5280 */ |
| 310 | |
| 311 | #define ub_name 32768 |
| 312 | #define ub_common_name 64 |
| 313 | #define ub_locality_name 128 |
| 314 | #define ub_state_name 128 |
| 315 | #define ub_organization_name 64 |
| 316 | #define ub_organization_unit_name 64 |
| 317 | #define ub_title 64 |
| 318 | #define ub_email_address 128 |
| 319 | |
| 320 | /* |
| 321 | * Declarations for template structures: for full definitions see asn1t.h |
| 322 | */ |
| 323 | typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; |
| 324 | typedef struct ASN1_TLC_st ASN1_TLC; |
| 325 | /* |
| 326 | * This is deliberately used as an opaque pointer to a structure that |
| 327 | * is never defined. In other words it will behave like void * |
| 328 | */ |
| 329 | typedef struct ASN1_VALUE_st ASN1_VALUE; |
| 330 | |
| 331 | /* Declare ASN1 functions: the implement macro is in asn1t.h */ |
| 332 | |
| 333 | /* |
| 334 | * The mysterious 'extern' that's passed to some macros is innocuous, |
| 335 | * and is there to quiet pre-C99 compilers that may complain about empty |
| 336 | * arguments in macro calls. |
| 337 | */ |
| 338 | |
| 339 | #define DECLARE_ASN1_FUNCTIONS_attr(attr, type) \ |
| 340 | DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, type) |
| 341 | #define DECLARE_ASN1_FUNCTIONS(type) \ |
| 342 | DECLARE_ASN1_FUNCTIONS_attr(extern, type) |
| 343 | |
| 344 | #define DECLARE_ASN1_ALLOC_FUNCTIONS_attr(attr, type) \ |
| 345 | DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, type) |
| 346 | #define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ |
| 347 | DECLARE_ASN1_ALLOC_FUNCTIONS_attr(extern, type) |
| 348 | |
| 349 | #define DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, name) \ |
| 350 | DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ |
| 351 | DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) |
| 352 | #define DECLARE_ASN1_FUNCTIONS_name(type, name) \ |
| 353 | DECLARE_ASN1_FUNCTIONS_name_attr(extern, type, name) |
| 354 | |
| 355 | #define DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, itname, name) \ |
| 356 | DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ |
| 357 | DECLARE_ASN1_ITEM_attr(attr, itname) |
| 358 | #define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ |
| 359 | DECLARE_ASN1_ENCODE_FUNCTIONS_attr(extern, type, itname, name) |
| 360 | |
| 361 | #define DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) \ |
| 362 | DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, name, name) |
| 363 | #define DECLARE_ASN1_ENCODE_FUNCTIONS_name(type, name) \ |
| 364 | DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, type, name) |
| 365 | |
| 366 | #define DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \ |
| 367 | attr type *d2i_##name(type **a, const unsigned char **in, long len); \ |
| 368 | attr int i2d_##name(const type *a, unsigned char **out); |
| 369 | #define DECLARE_ASN1_ENCODE_FUNCTIONS_only(type, name) \ |
| 370 | DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(extern, type, name) |
| 371 | |
| 372 | #define DECLARE_ASN1_NDEF_FUNCTION_attr(attr, name) \ |
| 373 | attr int i2d_##name##_NDEF(const name *a, unsigned char **out); |
| 374 | #define DECLARE_ASN1_NDEF_FUNCTION(name) \ |
| 375 | DECLARE_ASN1_NDEF_FUNCTION_attr(extern, name) |
| 376 | |
| 377 | #define DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \ |
| 378 | attr type *name##_new(void); \ |
| 379 | attr void name##_free(type *a); |
| 380 | #define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ |
| 381 | DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(extern, type, name) |
| 382 | |
| 383 | #define DECLARE_ASN1_DUP_FUNCTION_attr(attr, type) \ |
| 384 | DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, type) |
| 385 | #define DECLARE_ASN1_DUP_FUNCTION(type) \ |
| 386 | DECLARE_ASN1_DUP_FUNCTION_attr(extern, type) |
| 387 | |
| 388 | #define DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, name) \ |
| 389 | attr type *name##_dup(const type *a); |
| 390 | #define DECLARE_ASN1_DUP_FUNCTION_name(type, name) \ |
| 391 | DECLARE_ASN1_DUP_FUNCTION_name_attr(extern, type, name) |
| 392 | |
| 393 | #define DECLARE_ASN1_PRINT_FUNCTION_attr(attr, stname) \ |
| 394 | DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, stname) |
| 395 | #define DECLARE_ASN1_PRINT_FUNCTION(stname) \ |
| 396 | DECLARE_ASN1_PRINT_FUNCTION_attr(extern, stname) |
| 397 | |
| 398 | #define DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, fname) \ |
| 399 | attr int fname##_print_ctx(BIO *out, const stname *x, int indent, \ |
| 400 | const ASN1_PCTX *pctx); |
| 401 | #define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ |
| 402 | DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname) |
| 403 | |
| 404 | #define D2I_OF(type) type *(*)(type **, const unsigned char **, long) |
| 405 | #define I2D_OF(type) int (*)(const type *, unsigned char **) |
| 406 | |
| 407 | #define CHECKED_D2I_OF(type, d2i) \ |
| 408 | ((d2i_of_void *)(1 ? d2i : ((D2I_OF(type))0))) |
| 409 | #define CHECKED_I2D_OF(type, i2d) \ |
| 410 | ((i2d_of_void *)(1 ? i2d : ((I2D_OF(type))0))) |
| 411 | #define CHECKED_NEW_OF(type, xnew) \ |
| 412 | ((void *(*)(void))(1 ? xnew : ((type * (*)(void))0))) |
| 413 | #define CHECKED_PTR_OF(type, p) \ |
| 414 | ((void *)(1 ? p : (type *)0)) |
| 415 | #define CHECKED_PPTR_OF(type, p) \ |
| 416 | ((void **)(1 ? p : (type **)0)) |
| 417 | |
| 418 | #define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **, const unsigned char **, long) |
| 419 | #define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *, unsigned char **) |
| 420 | #define TYPEDEF_D2I2D_OF(type) \ |
| 421 | TYPEDEF_D2I_OF(type); \ |
| 422 | TYPEDEF_I2D_OF(type) |
| 423 | |
| 424 | typedef void *d2i_of_void(void **, const unsigned char **, long); |
| 425 | typedef int i2d_of_void(const void *, unsigned char **); |
| 426 | typedef int OSSL_i2d_of_void_ctx(const void *, unsigned char **, void *vctx); |
| 427 | |
| 428 | /*- |
| 429 | * The following macros and typedefs allow an ASN1_ITEM |
| 430 | * to be embedded in a structure and referenced. Since |
| 431 | * the ASN1_ITEM pointers need to be globally accessible |
| 432 | * (possibly from shared libraries) they may exist in |
| 433 | * different forms. On platforms that support it the |
| 434 | * ASN1_ITEM structure itself will be globally exported. |
| 435 | * Other platforms will export a function that returns |
| 436 | * an ASN1_ITEM pointer. |
| 437 | * |
| 438 | * To handle both cases transparently the macros below |
| 439 | * should be used instead of hard coding an ASN1_ITEM |
| 440 | * pointer in a structure. |
| 441 | * |
| 442 | * The structure will look like this: |
| 443 | * |
| 444 | * typedef struct SOMETHING_st { |
| 445 | * ... |
| 446 | * ASN1_ITEM_EXP *iptr; |
| 447 | * ... |
| 448 | * } SOMETHING; |
| 449 | * |
| 450 | * It would be initialised as e.g.: |
| 451 | * |
| 452 | * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; |
| 453 | * |
| 454 | * and the actual pointer extracted with: |
| 455 | * |
| 456 | * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); |
| 457 | * |
| 458 | * Finally an ASN1_ITEM pointer can be extracted from an |
| 459 | * appropriate reference with: ASN1_ITEM_rptr(X509). This |
| 460 | * would be used when a function takes an ASN1_ITEM * argument. |
| 461 | * |
| 462 | */ |
| 463 | |
| 464 | /* |
| 465 | * Platforms that can't easily handle shared global variables are declared as |
| 466 | * functions returning ASN1_ITEM pointers. |
| 467 | */ |
| 468 | |
| 469 | /* ASN1_ITEM pointer exported type */ |
| 470 | typedef const ASN1_ITEM *ASN1_ITEM_EXP(void); |
| 471 | |
| 472 | /* Macro to obtain ASN1_ITEM pointer from exported type */ |
| 473 | #define ASN1_ITEM_ptr(iptr) (iptr()) |
| 474 | |
| 475 | /* Macro to include ASN1_ITEM pointer from base type */ |
| 476 | #define ASN1_ITEM_ref(iptr) (iptr##_it) |
| 477 | |
| 478 | #define ASN1_ITEM_rptr(ref) (ref##_it()) |
| 479 | |
| 480 | #define DECLARE_ASN1_ITEM_attr(attr, name) \ |
| 481 | attr const ASN1_ITEM *name##_it(void); |
| 482 | #define DECLARE_ASN1_ITEM(name) \ |
| 483 | DECLARE_ASN1_ITEM_attr(extern, name) |
| 484 | |
| 485 | /* Parameters used by ASN1_STRING_print_ex() */ |
| 486 | |
| 487 | /* |
| 488 | * These determine which characters to escape: RFC2253 special characters, |
| 489 | * control characters and MSB set characters |
| 490 | */ |
| 491 | |
| 492 | #define ASN1_STRFLGS_ESC_2253 1 |
| 493 | #define ASN1_STRFLGS_ESC_CTRL 2 |
| 494 | #define ASN1_STRFLGS_ESC_MSB 4 |
| 495 | |
| 496 | /* Lower 8 bits are reserved as an output type specifier */ |
| 497 | #define ASN1_DTFLGS_TYPE_MASK 0x0FUL |
| 498 | #define ASN1_DTFLGS_RFC822 0x00UL |
| 499 | #define ASN1_DTFLGS_ISO8601 0x01UL |
| 500 | |
| 501 | /* |
| 502 | * This flag determines how we do escaping: normally RC2253 backslash only, |
| 503 | * set this to use backslash and quote. |
| 504 | */ |
| 505 | |
| 506 | #define ASN1_STRFLGS_ESC_QUOTE 8 |
| 507 | |
| 508 | /* These three flags are internal use only. */ |
| 509 | |
| 510 | /* Character is a valid PrintableString character */ |
| 511 | #define CHARTYPE_PRINTABLESTRING 0x10 |
| 512 | /* Character needs escaping if it is the first character */ |
| 513 | #define CHARTYPE_FIRST_ESC_2253 0x20 |
| 514 | /* Character needs escaping if it is the last character */ |
| 515 | #define CHARTYPE_LAST_ESC_2253 0x40 |
| 516 | |
| 517 | /* |
| 518 | * NB the internal flags are safely reused below by flags handled at the top |
| 519 | * level. |
| 520 | */ |
| 521 | |
| 522 | /* |
| 523 | * If this is set we convert all character strings to UTF8 first |
| 524 | */ |
| 525 | |
| 526 | #define ASN1_STRFLGS_UTF8_CONVERT 0x10 |
| 527 | |
| 528 | /* |
| 529 | * If this is set we don't attempt to interpret content: just assume all |
| 530 | * strings are 1 byte per character. This will produce some pretty odd |
| 531 | * looking output! |
| 532 | */ |
| 533 | |
| 534 | #define ASN1_STRFLGS_IGNORE_TYPE 0x20 |
| 535 | |
| 536 | /* If this is set we include the string type in the output */ |
| 537 | #define ASN1_STRFLGS_SHOW_TYPE 0x40 |
| 538 | |
| 539 | /* |
| 540 | * This determines which strings to display and which to 'dump' (hex dump of |
| 541 | * content octets or DER encoding). We can only dump non character strings or |
| 542 | * everything. If we don't dump 'unknown' they are interpreted as character |
| 543 | * strings with 1 octet per character and are subject to the usual escaping |
| 544 | * options. |
| 545 | */ |
| 546 | |
| 547 | #define ASN1_STRFLGS_DUMP_ALL 0x80 |
| 548 | #define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 |
| 549 | |
| 550 | /* |
| 551 | * These determine what 'dumping' does, we can dump the content octets or the |
| 552 | * DER encoding: both use the RFC2253 #XXXXX notation. |
| 553 | */ |
| 554 | |
| 555 | #define ASN1_STRFLGS_DUMP_DER 0x200 |
| 556 | |
| 557 | /* |
| 558 | * This flag specifies that RC2254 escaping shall be performed. |
| 559 | */ |
| 560 | #define ASN1_STRFLGS_ESC_2254 0x400 |
| 561 | |
| 562 | /* |
| 563 | * All the string flags consistent with RFC2253, escaping control characters |
| 564 | * isn't essential in RFC2253 but it is advisable anyway. |
| 565 | */ |
| 566 | |
| 567 | #define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN | ASN1_STRFLGS_DUMP_DER) |
| 568 | |
| 569 | struct asn1_type_st { |
| 570 | int type; |
| 571 | union { |
| 572 | char *ptr; |
| 573 | ASN1_BOOLEAN boolean; |
| 574 | ASN1_STRING *asn1_string; |
| 575 | ASN1_OBJECT *object; |
| 576 | ASN1_INTEGER *integer; |
| 577 | ASN1_ENUMERATED *enumerated; |
| 578 | ASN1_BIT_STRING *bit_string; |
| 579 | ASN1_OCTET_STRING *octet_string; |
| 580 | ASN1_PRINTABLESTRING *printablestring; |
| 581 | ASN1_T61STRING *t61string; |
| 582 | ASN1_IA5STRING *ia5string; |
| 583 | ASN1_GENERALSTRING *generalstring; |
| 584 | ASN1_BMPSTRING *bmpstring; |
| 585 | ASN1_UNIVERSALSTRING *universalstring; |
| 586 | ASN1_UTCTIME *utctime; |
| 587 | ASN1_GENERALIZEDTIME *generalizedtime; |
| 588 | ASN1_VISIBLESTRING *visiblestring; |
| 589 | ASN1_UTF8STRING *utf8string; |
| 590 | /* |
| 591 | * set and sequence are left complete and still contain the set or |
| 592 | * sequence bytes |
| 593 | */ |
| 594 | ASN1_STRING *set; |
| 595 | ASN1_STRING *sequence; |
| 596 | ASN1_VALUE *asn1_value; |
| 597 | } value; |
| 598 | }; |
| 599 | |
| 600 | /* clang-format off */ |
| 601 | SKM_DEFINE_STACK_OF_INTERNAL(ASN1_TYPE, ASN1_TYPE, ASN1_TYPE) |
| 602 | #define sk_ASN1_TYPE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_TYPE_sk_type(sk)) |
| 603 | #define sk_ASN1_TYPE_value(sk, idx) ((ASN1_TYPE *)OPENSSL_sk_value(ossl_check_const_ASN1_TYPE_sk_type(sk), (idx))) |
| 604 | #define sk_ASN1_TYPE_new(cmp) \ |
| 605 | ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_set_thunks( \ |
| 606 | OPENSSL_sk_set_copy_thunks( \ |
| 607 | OPENSSL_sk_set_cmp_thunks( \ |
| 608 | OPENSSL_sk_new(ossl_check_ASN1_TYPE_compfunc_type(cmp)), \ |
| 609 | sk_ASN1_TYPE_cmpfunc_thunk), \ |
| 610 | sk_ASN1_TYPE_copyfunc_thunk), \ |
| 611 | sk_ASN1_TYPE_freefunc_thunk)) |
| 612 | #define sk_ASN1_TYPE_new_null() \ |
| 613 | ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_set_thunks( \ |
| 614 | OPENSSL_sk_set_copy_thunks( \ |
| 615 | OPENSSL_sk_set_cmp_thunks( \ |
| 616 | OPENSSL_sk_new_null(), \ |
| 617 | sk_ASN1_TYPE_cmpfunc_thunk), \ |
| 618 | sk_ASN1_TYPE_copyfunc_thunk), \ |
| 619 | sk_ASN1_TYPE_freefunc_thunk)) |
| 620 | #define sk_ASN1_TYPE_new_reserve(cmp, n) \ |
| 621 | ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_set_thunks( \ |
| 622 | OPENSSL_sk_set_copy_thunks( \ |
| 623 | OPENSSL_sk_set_cmp_thunks( \ |
| 624 | OPENSSL_sk_new_reserve(ossl_check_ASN1_TYPE_compfunc_type(cmp), (n)), \ |
| 625 | sk_ASN1_TYPE_cmpfunc_thunk), \ |
| 626 | sk_ASN1_TYPE_copyfunc_thunk), \ |
| 627 | sk_ASN1_TYPE_freefunc_thunk)) |
| 628 | #define sk_ASN1_TYPE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_TYPE_sk_type(sk), (n)) |
| 629 | #define sk_ASN1_TYPE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_TYPE_sk_type(sk)) |
| 630 | #define sk_ASN1_TYPE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_TYPE_sk_type(sk)) |
| 631 | #define sk_ASN1_TYPE_delete(sk, i) ((ASN1_TYPE *)OPENSSL_sk_delete(ossl_check_ASN1_TYPE_sk_type(sk), (i))) |
| 632 | #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))) |
| 633 | #define sk_ASN1_TYPE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) |
| 634 | #define sk_ASN1_TYPE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) |
| 635 | #define sk_ASN1_TYPE_pop(sk) ((ASN1_TYPE *)OPENSSL_sk_pop(ossl_check_ASN1_TYPE_sk_type(sk))) |
| 636 | #define sk_ASN1_TYPE_shift(sk) ((ASN1_TYPE *)OPENSSL_sk_shift(ossl_check_ASN1_TYPE_sk_type(sk))) |
| 637 | #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)) |
| 638 | #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)) |
| 639 | #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))) |
| 640 | #define sk_ASN1_TYPE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr)) |
| 641 | #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)) |
| 642 | #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) |
| 643 | #define sk_ASN1_TYPE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_TYPE_sk_type(sk)) |
| 644 | #define sk_ASN1_TYPE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_TYPE_sk_type(sk)) |
| 645 | #define sk_ASN1_TYPE_dup(sk) \ |
| 646 | ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_set_thunks( \ |
| 647 | OPENSSL_sk_set_copy_thunks( \ |
| 648 | OPENSSL_sk_set_cmp_thunks( \ |
| 649 | OPENSSL_sk_dup(ossl_check_const_ASN1_TYPE_sk_type(sk)), \ |
| 650 | sk_ASN1_TYPE_cmpfunc_thunk), \ |
| 651 | sk_ASN1_TYPE_copyfunc_thunk), \ |
| 652 | sk_ASN1_TYPE_freefunc_thunk)) |
| 653 | #define sk_ASN1_TYPE_deep_copy(sk, copyfunc, freefunc) \ |
| 654 | ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_set_thunks( \ |
| 655 | OPENSSL_sk_set_copy_thunks( \ |
| 656 | OPENSSL_sk_set_cmp_thunks( \ |
| 657 | OPENSSL_sk_deep_copy( \ |
| 658 | ossl_check_const_ASN1_TYPE_sk_type(sk), \ |
| 659 | ossl_check_ASN1_TYPE_copyfunc_type(copyfunc), \ |
| 660 | ossl_check_ASN1_TYPE_freefunc_type(freefunc)), \ |
| 661 | sk_ASN1_TYPE_cmpfunc_thunk), \ |
| 662 | sk_ASN1_TYPE_copyfunc_thunk), \ |
| 663 | sk_ASN1_TYPE_freefunc_thunk)) |
| 664 | #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))) |
| 665 | |
| 666 | /* clang-format on */ |
| 667 | |
| 668 | typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; |
| 669 | |
| 670 | DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) |
| 671 | DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) |
| 672 | |
| 673 | /* This is used to contain a list of bit names */ |
| 674 | typedef struct BIT_STRING_BITNAME_st { |
| 675 | int bitnum; |
| 676 | const char *lname; |
| 677 | const char *sname; |
| 678 | } BIT_STRING_BITNAME; |
| 679 | |
| 680 | #define B_ASN1_TIME \ |
| 681 | B_ASN1_UTCTIME | B_ASN1_GENERALIZEDTIME |
| 682 | |
| 683 | #define B_ASN1_PRINTABLE \ |
| 684 | B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING | B_ASN1_BIT_STRING | B_ASN1_UNIVERSALSTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING | B_ASN1_SEQUENCE | B_ASN1_UNKNOWN |
| 685 | |
| 686 | #define B_ASN1_DIRECTORYSTRING \ |
| 687 | B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING | B_ASN1_BMPSTRING | B_ASN1_UNIVERSALSTRING | B_ASN1_UTF8STRING |
| 688 | |
| 689 | #define B_ASN1_DISPLAYTEXT \ |
| 690 | B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING |
| 691 | |
| 692 | DECLARE_ASN1_ALLOC_FUNCTIONS_name(ASN1_TYPE, ASN1_TYPE) |
| 693 | DECLARE_ASN1_ENCODE_FUNCTIONS(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) |
| 694 | |
| 695 | int ASN1_TYPE_get(const ASN1_TYPE *a); |
| 696 | void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); |
| 697 | int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); |
| 698 | int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); |
| 699 | |
| 700 | ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); |
| 701 | void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); |
| 702 | |
| 703 | /* clang-format off */ |
| 704 | SKM_DEFINE_STACK_OF_INTERNAL(ASN1_OBJECT, ASN1_OBJECT, ASN1_OBJECT) |
| 705 | #define sk_ASN1_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_OBJECT_sk_type(sk)) |
| 706 | #define sk_ASN1_OBJECT_value(sk, idx) ((ASN1_OBJECT *)OPENSSL_sk_value(ossl_check_const_ASN1_OBJECT_sk_type(sk), (idx))) |
| 707 | #define sk_ASN1_OBJECT_new(cmp) \ |
| 708 | ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_set_thunks( \ |
| 709 | OPENSSL_sk_set_copy_thunks( \ |
| 710 | OPENSSL_sk_set_cmp_thunks( \ |
| 711 | OPENSSL_sk_new(ossl_check_ASN1_OBJECT_compfunc_type(cmp)), \ |
| 712 | sk_ASN1_OBJECT_cmpfunc_thunk), \ |
| 713 | sk_ASN1_OBJECT_copyfunc_thunk), \ |
| 714 | sk_ASN1_OBJECT_freefunc_thunk)) |
| 715 | #define sk_ASN1_OBJECT_new_null() \ |
| 716 | ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_set_thunks( \ |
| 717 | OPENSSL_sk_set_copy_thunks( \ |
| 718 | OPENSSL_sk_set_cmp_thunks( \ |
| 719 | OPENSSL_sk_new_null(), \ |
| 720 | sk_ASN1_OBJECT_cmpfunc_thunk), \ |
| 721 | sk_ASN1_OBJECT_copyfunc_thunk), \ |
| 722 | sk_ASN1_OBJECT_freefunc_thunk)) |
| 723 | #define sk_ASN1_OBJECT_new_reserve(cmp, n) \ |
| 724 | ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_set_thunks( \ |
| 725 | OPENSSL_sk_set_copy_thunks( \ |
| 726 | OPENSSL_sk_set_cmp_thunks( \ |
| 727 | OPENSSL_sk_new_reserve(ossl_check_ASN1_OBJECT_compfunc_type(cmp), (n)), \ |
| 728 | sk_ASN1_OBJECT_cmpfunc_thunk), \ |
| 729 | sk_ASN1_OBJECT_copyfunc_thunk), \ |
| 730 | sk_ASN1_OBJECT_freefunc_thunk)) |
| 731 | #define sk_ASN1_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_OBJECT_sk_type(sk), (n)) |
| 732 | #define sk_ASN1_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_ASN1_OBJECT_sk_type(sk)) |
| 733 | #define sk_ASN1_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_OBJECT_sk_type(sk)) |
| 734 | #define sk_ASN1_OBJECT_delete(sk, i) ((ASN1_OBJECT *)OPENSSL_sk_delete(ossl_check_ASN1_OBJECT_sk_type(sk), (i))) |
| 735 | #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))) |
| 736 | #define sk_ASN1_OBJECT_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) |
| 737 | #define sk_ASN1_OBJECT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) |
| 738 | #define sk_ASN1_OBJECT_pop(sk) ((ASN1_OBJECT *)OPENSSL_sk_pop(ossl_check_ASN1_OBJECT_sk_type(sk))) |
| 739 | #define sk_ASN1_OBJECT_shift(sk) ((ASN1_OBJECT *)OPENSSL_sk_shift(ossl_check_ASN1_OBJECT_sk_type(sk))) |
| 740 | #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)) |
| 741 | #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)) |
| 742 | #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))) |
| 743 | #define sk_ASN1_OBJECT_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr)) |
| 744 | #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)) |
| 745 | #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) |
| 746 | #define sk_ASN1_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_OBJECT_sk_type(sk)) |
| 747 | #define sk_ASN1_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_OBJECT_sk_type(sk)) |
| 748 | #define sk_ASN1_OBJECT_dup(sk) \ |
| 749 | ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_set_thunks( \ |
| 750 | OPENSSL_sk_set_copy_thunks( \ |
| 751 | OPENSSL_sk_set_cmp_thunks( \ |
| 752 | OPENSSL_sk_dup(ossl_check_const_ASN1_OBJECT_sk_type(sk)), \ |
| 753 | sk_ASN1_OBJECT_cmpfunc_thunk), \ |
| 754 | sk_ASN1_OBJECT_copyfunc_thunk), \ |
| 755 | sk_ASN1_OBJECT_freefunc_thunk)) |
| 756 | #define sk_ASN1_OBJECT_deep_copy(sk, copyfunc, freefunc) \ |
| 757 | ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_set_thunks( \ |
| 758 | OPENSSL_sk_set_copy_thunks( \ |
| 759 | OPENSSL_sk_set_cmp_thunks( \ |
| 760 | OPENSSL_sk_deep_copy( \ |
| 761 | ossl_check_const_ASN1_OBJECT_sk_type(sk), \ |
| 762 | ossl_check_ASN1_OBJECT_copyfunc_type(copyfunc), \ |
| 763 | ossl_check_ASN1_OBJECT_freefunc_type(freefunc)), \ |
| 764 | sk_ASN1_OBJECT_cmpfunc_thunk), \ |
| 765 | sk_ASN1_OBJECT_copyfunc_thunk), \ |
| 766 | sk_ASN1_OBJECT_freefunc_thunk)) |
| 767 | #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))) |
| 768 | |
| 769 | /* clang-format on */ |
| 770 | |
| 771 | #ifndef OPENSSL_NO_DEPRECATED_4_0 |
| 772 | OSSL_DEPRECATEDIN_4_0 ASN1_OBJECT *ASN1_OBJECT_new(void); |
| 773 | #endif /* OPENSSL_NO_DEPRECATED_4_0 */ |
| 774 | void ASN1_OBJECT_free(ASN1_OBJECT *a); |
| 775 | DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, ASN1_OBJECT, ASN1_OBJECT) |
| 776 | |
| 777 | ASN1_STRING *ASN1_STRING_new(void); |
| 778 | void ASN1_STRING_free(ASN1_STRING *a); |
| 779 | void ASN1_STRING_clear_free(ASN1_STRING *a); |
| 780 | int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); |
| 781 | DECLARE_ASN1_DUP_FUNCTION(ASN1_STRING) |
| 782 | ASN1_STRING *ASN1_STRING_type_new(int type); |
| 783 | ASN1_STRING *ASN1_STRING_new_not_owned(int type, const uint8_t *data, |
| 784 | size_t length); |
| 785 | int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); |
| 786 | /* |
| 787 | * Since this is used to store all sorts of things, via macros, for now, |
| 788 | * make its data void * |
| 789 | */ |
| 790 | #if !defined(OPENSSL_NO_DEPRECATED_4_1) |
| 791 | OSSL_DEPRECATEDIN_4_1_FOR("use ASN1_STRING_set1_data() or ASN1_STRING_set1_string()" ) |
| 792 | int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); |
| 793 | OSSL_DEPRECATEDIN_4_1_FOR("use ASN1_STRING_get_length()" ) |
| 794 | int ASN1_STRING_length(const ASN1_STRING *x); |
| 795 | #endif /* !defined(OPENSSL_NO_DEPRECATED_4_1) */ |
| 796 | void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); |
| 797 | int ASN1_STRING_set1_data(ASN1_STRING *str, const uint8_t *data, size_t len); |
| 798 | int ASN1_STRING_set1_string(ASN1_STRING *str, const char *cstring); |
| 799 | size_t ASN1_STRING_get_length(const ASN1_STRING *x); |
| 800 | #ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 801 | OSSL_DEPRECATEDIN_3_0 void ASN1_STRING_length_set(ASN1_STRING *x, int n); |
| 802 | #endif |
| 803 | int ASN1_STRING_type(const ASN1_STRING *x); |
| 804 | const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x); |
| 805 | |
| 806 | DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) |
| 807 | #ifndef OPENSSL_NO_DEPRECATED_4_1 |
| 808 | OSSL_DEPRECATEDIN_4_1_FOR("use ASN1_BIT_STRING_set1()" ) |
| 809 | int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, |
| 810 | unsigned char *d, int length); |
| 811 | #endif |
| 812 | int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); |
| 813 | int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); |
| 814 | int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, |
| 815 | const unsigned char *flags, int flags_len); |
| 816 | |
| 817 | #if !defined(OPENSSL_NO_DEPRECATED_4_1) |
| 818 | OSSL_DEPRECATEDIN_4_1 int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, |
| 819 | BIT_STRING_BITNAME *tbl, int indent); |
| 820 | OSSL_DEPRECATEDIN_4_1 int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); |
| 821 | OSSL_DEPRECATEDIN_4_1 int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, |
| 822 | BIT_STRING_BITNAME *tbl); |
| 823 | #endif /* !defined(OPENSSL_NO_DEPRECATED_4_1) */ |
| 824 | int ASN1_BIT_STRING_get_length(const ASN1_BIT_STRING *abs, size_t *length, |
| 825 | int *unused_bits); |
| 826 | int ASN1_BIT_STRING_set1(ASN1_BIT_STRING *abs, const uint8_t *data, |
| 827 | size_t length, int unused_bits); |
| 828 | |
| 829 | /* clang-format off */ |
| 830 | SKM_DEFINE_STACK_OF_INTERNAL(ASN1_INTEGER, ASN1_INTEGER, ASN1_INTEGER) |
| 831 | #define sk_ASN1_INTEGER_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk)) |
| 832 | #define sk_ASN1_INTEGER_value(sk, idx) ((ASN1_INTEGER *)OPENSSL_sk_value(ossl_check_const_ASN1_INTEGER_sk_type(sk), (idx))) |
| 833 | #define sk_ASN1_INTEGER_new(cmp) \ |
| 834 | ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_set_thunks( \ |
| 835 | OPENSSL_sk_set_copy_thunks( \ |
| 836 | OPENSSL_sk_set_cmp_thunks( \ |
| 837 | OPENSSL_sk_new(ossl_check_ASN1_INTEGER_compfunc_type(cmp)), \ |
| 838 | sk_ASN1_INTEGER_cmpfunc_thunk), \ |
| 839 | sk_ASN1_INTEGER_copyfunc_thunk), \ |
| 840 | sk_ASN1_INTEGER_freefunc_thunk)) |
| 841 | #define sk_ASN1_INTEGER_new_null() \ |
| 842 | ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_set_thunks( \ |
| 843 | OPENSSL_sk_set_copy_thunks( \ |
| 844 | OPENSSL_sk_set_cmp_thunks( \ |
| 845 | OPENSSL_sk_new_null(), \ |
| 846 | sk_ASN1_INTEGER_cmpfunc_thunk), \ |
| 847 | sk_ASN1_INTEGER_copyfunc_thunk), \ |
| 848 | sk_ASN1_INTEGER_freefunc_thunk)) |
| 849 | #define sk_ASN1_INTEGER_new_reserve(cmp, n) \ |
| 850 | ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_set_thunks( \ |
| 851 | OPENSSL_sk_set_copy_thunks( \ |
| 852 | OPENSSL_sk_set_cmp_thunks( \ |
| 853 | OPENSSL_sk_new_reserve(ossl_check_ASN1_INTEGER_compfunc_type(cmp), (n)), \ |
| 854 | sk_ASN1_INTEGER_cmpfunc_thunk), \ |
| 855 | sk_ASN1_INTEGER_copyfunc_thunk), \ |
| 856 | sk_ASN1_INTEGER_freefunc_thunk)) |
| 857 | #define sk_ASN1_INTEGER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_INTEGER_sk_type(sk), (n)) |
| 858 | #define sk_ASN1_INTEGER_free(sk) OPENSSL_sk_free(ossl_check_ASN1_INTEGER_sk_type(sk)) |
| 859 | #define sk_ASN1_INTEGER_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_INTEGER_sk_type(sk)) |
| 860 | #define sk_ASN1_INTEGER_delete(sk, i) ((ASN1_INTEGER *)OPENSSL_sk_delete(ossl_check_ASN1_INTEGER_sk_type(sk), (i))) |
| 861 | #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))) |
| 862 | #define sk_ASN1_INTEGER_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) |
| 863 | #define sk_ASN1_INTEGER_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) |
| 864 | #define sk_ASN1_INTEGER_pop(sk) ((ASN1_INTEGER *)OPENSSL_sk_pop(ossl_check_ASN1_INTEGER_sk_type(sk))) |
| 865 | #define sk_ASN1_INTEGER_shift(sk) ((ASN1_INTEGER *)OPENSSL_sk_shift(ossl_check_ASN1_INTEGER_sk_type(sk))) |
| 866 | #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)) |
| 867 | #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)) |
| 868 | #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))) |
| 869 | #define sk_ASN1_INTEGER_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr)) |
| 870 | #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)) |
| 871 | #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) |
| 872 | #define sk_ASN1_INTEGER_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_INTEGER_sk_type(sk)) |
| 873 | #define sk_ASN1_INTEGER_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_INTEGER_sk_type(sk)) |
| 874 | #define sk_ASN1_INTEGER_dup(sk) \ |
| 875 | ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_set_thunks( \ |
| 876 | OPENSSL_sk_set_copy_thunks( \ |
| 877 | OPENSSL_sk_set_cmp_thunks( \ |
| 878 | OPENSSL_sk_dup(ossl_check_const_ASN1_INTEGER_sk_type(sk)), \ |
| 879 | sk_ASN1_INTEGER_cmpfunc_thunk), \ |
| 880 | sk_ASN1_INTEGER_copyfunc_thunk), \ |
| 881 | sk_ASN1_INTEGER_freefunc_thunk)) |
| 882 | #define sk_ASN1_INTEGER_deep_copy(sk, copyfunc, freefunc) \ |
| 883 | ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_set_thunks( \ |
| 884 | OPENSSL_sk_set_copy_thunks( \ |
| 885 | OPENSSL_sk_set_cmp_thunks( \ |
| 886 | OPENSSL_sk_deep_copy( \ |
| 887 | ossl_check_const_ASN1_INTEGER_sk_type(sk), \ |
| 888 | ossl_check_ASN1_INTEGER_copyfunc_type(copyfunc), \ |
| 889 | ossl_check_ASN1_INTEGER_freefunc_type(freefunc)), \ |
| 890 | sk_ASN1_INTEGER_cmpfunc_thunk), \ |
| 891 | sk_ASN1_INTEGER_copyfunc_thunk), \ |
| 892 | sk_ASN1_INTEGER_freefunc_thunk)) |
| 893 | #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))) |
| 894 | |
| 895 | /* clang-format on */ |
| 896 | |
| 897 | DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) |
| 898 | ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, |
| 899 | long length); |
| 900 | DECLARE_ASN1_DUP_FUNCTION(ASN1_INTEGER) |
| 901 | int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); |
| 902 | |
| 903 | DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) |
| 904 | |
| 905 | int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); |
| 906 | ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); |
| 907 | ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, |
| 908 | int offset_day, long offset_sec); |
| 909 | int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); |
| 910 | int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); |
| 911 | |
| 912 | int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); |
| 913 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, |
| 914 | time_t t); |
| 915 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, |
| 916 | time_t t, int offset_day, |
| 917 | long offset_sec); |
| 918 | int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); |
| 919 | |
| 920 | int ASN1_TIME_diff(int *pday, int *psec, |
| 921 | const ASN1_TIME *from, const ASN1_TIME *to); |
| 922 | |
| 923 | DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) |
| 924 | DECLARE_ASN1_DUP_FUNCTION(ASN1_OCTET_STRING) |
| 925 | int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, |
| 926 | const ASN1_OCTET_STRING *b); |
| 927 | int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, |
| 928 | int len); |
| 929 | |
| 930 | /* clang-format off */ |
| 931 | SKM_DEFINE_STACK_OF_INTERNAL(ASN1_UTF8STRING, ASN1_UTF8STRING, ASN1_UTF8STRING) |
| 932 | #define sk_ASN1_UTF8STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) |
| 933 | #define sk_ASN1_UTF8STRING_value(sk, idx) ((ASN1_UTF8STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), (idx))) |
| 934 | #define sk_ASN1_UTF8STRING_new(cmp) \ |
| 935 | ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_set_thunks( \ |
| 936 | OPENSSL_sk_set_copy_thunks( \ |
| 937 | OPENSSL_sk_set_cmp_thunks( \ |
| 938 | OPENSSL_sk_new(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp)), \ |
| 939 | sk_ASN1_UTF8STRING_cmpfunc_thunk), \ |
| 940 | sk_ASN1_UTF8STRING_copyfunc_thunk), \ |
| 941 | sk_ASN1_UTF8STRING_freefunc_thunk)) |
| 942 | #define sk_ASN1_UTF8STRING_new_null() \ |
| 943 | ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_set_thunks( \ |
| 944 | OPENSSL_sk_set_copy_thunks( \ |
| 945 | OPENSSL_sk_set_cmp_thunks( \ |
| 946 | OPENSSL_sk_new_null(), \ |
| 947 | sk_ASN1_UTF8STRING_cmpfunc_thunk), \ |
| 948 | sk_ASN1_UTF8STRING_copyfunc_thunk), \ |
| 949 | sk_ASN1_UTF8STRING_freefunc_thunk)) |
| 950 | #define sk_ASN1_UTF8STRING_new_reserve(cmp, n) \ |
| 951 | ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_set_thunks( \ |
| 952 | OPENSSL_sk_set_copy_thunks( \ |
| 953 | OPENSSL_sk_set_cmp_thunks( \ |
| 954 | OPENSSL_sk_new_reserve(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp), (n)), \ |
| 955 | sk_ASN1_UTF8STRING_cmpfunc_thunk), \ |
| 956 | sk_ASN1_UTF8STRING_copyfunc_thunk), \ |
| 957 | sk_ASN1_UTF8STRING_freefunc_thunk)) |
| 958 | #define sk_ASN1_UTF8STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_UTF8STRING_sk_type(sk), (n)) |
| 959 | #define sk_ASN1_UTF8STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_UTF8STRING_sk_type(sk)) |
| 960 | #define sk_ASN1_UTF8STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_UTF8STRING_sk_type(sk)) |
| 961 | #define sk_ASN1_UTF8STRING_delete(sk, i) ((ASN1_UTF8STRING *)OPENSSL_sk_delete(ossl_check_ASN1_UTF8STRING_sk_type(sk), (i))) |
| 962 | #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))) |
| 963 | #define sk_ASN1_UTF8STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) |
| 964 | #define sk_ASN1_UTF8STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) |
| 965 | #define sk_ASN1_UTF8STRING_pop(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_pop(ossl_check_ASN1_UTF8STRING_sk_type(sk))) |
| 966 | #define sk_ASN1_UTF8STRING_shift(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_shift(ossl_check_ASN1_UTF8STRING_sk_type(sk))) |
| 967 | #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)) |
| 968 | #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)) |
| 969 | #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))) |
| 970 | #define sk_ASN1_UTF8STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr)) |
| 971 | #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)) |
| 972 | #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) |
| 973 | #define sk_ASN1_UTF8STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_UTF8STRING_sk_type(sk)) |
| 974 | #define sk_ASN1_UTF8STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)) |
| 975 | #define sk_ASN1_UTF8STRING_dup(sk) \ |
| 976 | ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_set_thunks( \ |
| 977 | OPENSSL_sk_set_copy_thunks( \ |
| 978 | OPENSSL_sk_set_cmp_thunks( \ |
| 979 | OPENSSL_sk_dup(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)), \ |
| 980 | sk_ASN1_UTF8STRING_cmpfunc_thunk), \ |
| 981 | sk_ASN1_UTF8STRING_copyfunc_thunk), \ |
| 982 | sk_ASN1_UTF8STRING_freefunc_thunk)) |
| 983 | #define sk_ASN1_UTF8STRING_deep_copy(sk, copyfunc, freefunc) \ |
| 984 | ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_set_thunks( \ |
| 985 | OPENSSL_sk_set_copy_thunks( \ |
| 986 | OPENSSL_sk_set_cmp_thunks( \ |
| 987 | OPENSSL_sk_deep_copy( \ |
| 988 | ossl_check_const_ASN1_UTF8STRING_sk_type(sk), \ |
| 989 | ossl_check_ASN1_UTF8STRING_copyfunc_type(copyfunc), \ |
| 990 | ossl_check_ASN1_UTF8STRING_freefunc_type(freefunc)), \ |
| 991 | sk_ASN1_UTF8STRING_cmpfunc_thunk), \ |
| 992 | sk_ASN1_UTF8STRING_copyfunc_thunk), \ |
| 993 | sk_ASN1_UTF8STRING_freefunc_thunk)) |
| 994 | #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))) |
| 995 | |
| 996 | /* clang-format on */ |
| 997 | |
| 998 | DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) |
| 999 | DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) |
| 1000 | DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) |
| 1001 | DECLARE_ASN1_FUNCTIONS(ASN1_NULL) |
| 1002 | DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) |
| 1003 | |
| 1004 | #if !defined(OPENSSL_NO_DEPRECATED_4_1) |
| 1005 | OSSL_DEPRECATEDIN_4_1 int UTF8_getc(const unsigned char *str, int len, unsigned long *val); |
| 1006 | OSSL_DEPRECATEDIN_4_1 int UTF8_putc(unsigned char *str, int len, unsigned long value); |
| 1007 | #endif /* !defined(OPENSSL_NO_DEPRECATED_4_1) */ |
| 1008 | |
| 1009 | /* clang-format off */ |
| 1010 | SKM_DEFINE_STACK_OF_INTERNAL(ASN1_GENERALSTRING, ASN1_GENERALSTRING, ASN1_GENERALSTRING) |
| 1011 | #define sk_ASN1_GENERALSTRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) |
| 1012 | #define sk_ASN1_GENERALSTRING_value(sk, idx) ((ASN1_GENERALSTRING *)OPENSSL_sk_value(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), (idx))) |
| 1013 | #define sk_ASN1_GENERALSTRING_new(cmp) \ |
| 1014 | ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_set_thunks( \ |
| 1015 | OPENSSL_sk_set_copy_thunks( \ |
| 1016 | OPENSSL_sk_set_cmp_thunks( \ |
| 1017 | OPENSSL_sk_new(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp)), \ |
| 1018 | sk_ASN1_GENERALSTRING_cmpfunc_thunk), \ |
| 1019 | sk_ASN1_GENERALSTRING_copyfunc_thunk), \ |
| 1020 | sk_ASN1_GENERALSTRING_freefunc_thunk)) |
| 1021 | #define sk_ASN1_GENERALSTRING_new_null() \ |
| 1022 | ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_set_thunks( \ |
| 1023 | OPENSSL_sk_set_copy_thunks( \ |
| 1024 | OPENSSL_sk_set_cmp_thunks( \ |
| 1025 | OPENSSL_sk_new_null(), \ |
| 1026 | sk_ASN1_GENERALSTRING_cmpfunc_thunk), \ |
| 1027 | sk_ASN1_GENERALSTRING_copyfunc_thunk), \ |
| 1028 | sk_ASN1_GENERALSTRING_freefunc_thunk)) |
| 1029 | #define sk_ASN1_GENERALSTRING_new_reserve(cmp, n) \ |
| 1030 | ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_set_thunks( \ |
| 1031 | OPENSSL_sk_set_copy_thunks( \ |
| 1032 | OPENSSL_sk_set_cmp_thunks( \ |
| 1033 | OPENSSL_sk_new_reserve(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp), (n)), \ |
| 1034 | sk_ASN1_GENERALSTRING_cmpfunc_thunk), \ |
| 1035 | sk_ASN1_GENERALSTRING_copyfunc_thunk), \ |
| 1036 | sk_ASN1_GENERALSTRING_freefunc_thunk)) |
| 1037 | #define sk_ASN1_GENERALSTRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (n)) |
| 1038 | #define sk_ASN1_GENERALSTRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) |
| 1039 | #define sk_ASN1_GENERALSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) |
| 1040 | #define sk_ASN1_GENERALSTRING_delete(sk, i) ((ASN1_GENERALSTRING *)OPENSSL_sk_delete(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (i))) |
| 1041 | #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))) |
| 1042 | #define sk_ASN1_GENERALSTRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) |
| 1043 | #define sk_ASN1_GENERALSTRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) |
| 1044 | #define sk_ASN1_GENERALSTRING_pop(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_pop(ossl_check_ASN1_GENERALSTRING_sk_type(sk))) |
| 1045 | #define sk_ASN1_GENERALSTRING_shift(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_shift(ossl_check_ASN1_GENERALSTRING_sk_type(sk))) |
| 1046 | #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)) |
| 1047 | #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)) |
| 1048 | #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))) |
| 1049 | #define sk_ASN1_GENERALSTRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr)) |
| 1050 | #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)) |
| 1051 | #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) |
| 1052 | #define sk_ASN1_GENERALSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_GENERALSTRING_sk_type(sk)) |
| 1053 | #define sk_ASN1_GENERALSTRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)) |
| 1054 | #define sk_ASN1_GENERALSTRING_dup(sk) \ |
| 1055 | ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_set_thunks( \ |
| 1056 | OPENSSL_sk_set_copy_thunks( \ |
| 1057 | OPENSSL_sk_set_cmp_thunks( \ |
| 1058 | OPENSSL_sk_dup(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)), \ |
| 1059 | sk_ASN1_GENERALSTRING_cmpfunc_thunk), \ |
| 1060 | sk_ASN1_GENERALSTRING_copyfunc_thunk), \ |
| 1061 | sk_ASN1_GENERALSTRING_freefunc_thunk)) |
| 1062 | #define sk_ASN1_GENERALSTRING_deep_copy(sk, copyfunc, freefunc) \ |
| 1063 | ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_set_thunks( \ |
| 1064 | OPENSSL_sk_set_copy_thunks( \ |
| 1065 | OPENSSL_sk_set_cmp_thunks( \ |
| 1066 | OPENSSL_sk_deep_copy( \ |
| 1067 | ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), \ |
| 1068 | ossl_check_ASN1_GENERALSTRING_copyfunc_type(copyfunc), \ |
| 1069 | ossl_check_ASN1_GENERALSTRING_freefunc_type(freefunc)), \ |
| 1070 | sk_ASN1_GENERALSTRING_cmpfunc_thunk), \ |
| 1071 | sk_ASN1_GENERALSTRING_copyfunc_thunk), \ |
| 1072 | sk_ASN1_GENERALSTRING_freefunc_thunk)) |
| 1073 | #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))) |
| 1074 | |
| 1075 | /* clang-format on */ |
| 1076 | |
| 1077 | DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) |
| 1078 | |
| 1079 | DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) |
| 1080 | DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) |
| 1081 | DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) |
| 1082 | DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) |
| 1083 | DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) |
| 1084 | DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) |
| 1085 | DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) |
| 1086 | DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) |
| 1087 | DECLARE_ASN1_FUNCTIONS(ASN1_TIME) |
| 1088 | |
| 1089 | DECLARE_ASN1_DUP_FUNCTION(ASN1_TIME) |
| 1090 | DECLARE_ASN1_DUP_FUNCTION(ASN1_UTCTIME) |
| 1091 | DECLARE_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME) |
| 1092 | |
| 1093 | DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) |
| 1094 | |
| 1095 | ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); |
| 1096 | ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, |
| 1097 | int offset_day, long offset_sec); |
| 1098 | int ASN1_TIME_check(const ASN1_TIME *t); |
| 1099 | ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, |
| 1100 | ASN1_GENERALIZEDTIME **out); |
| 1101 | int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); |
| 1102 | int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str); |
| 1103 | int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm); |
| 1104 | int ASN1_TIME_normalize(ASN1_TIME *s); |
| 1105 | int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t); |
| 1106 | int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b); |
| 1107 | |
| 1108 | int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a); |
| 1109 | int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); |
| 1110 | int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a); |
| 1111 | int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); |
| 1112 | int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a); |
| 1113 | int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); |
| 1114 | int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type); |
| 1115 | int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a); |
| 1116 | |
| 1117 | int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); |
| 1118 | ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, |
| 1119 | const char *sn, const char *ln); |
| 1120 | |
| 1121 | int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a); |
| 1122 | int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r); |
| 1123 | int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a); |
| 1124 | int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r); |
| 1125 | |
| 1126 | int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); |
| 1127 | long ASN1_INTEGER_get(const ASN1_INTEGER *a); |
| 1128 | ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); |
| 1129 | BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); |
| 1130 | |
| 1131 | int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a); |
| 1132 | int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r); |
| 1133 | |
| 1134 | int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); |
| 1135 | long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a); |
| 1136 | ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai); |
| 1137 | BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn); |
| 1138 | |
| 1139 | /* General */ |
| 1140 | /* given a string, return the correct type, max is the maximum length */ |
| 1141 | int ASN1_PRINTABLE_type(const unsigned char *s, int max); |
| 1142 | |
| 1143 | unsigned long ASN1_tag2bit(int tag); |
| 1144 | |
| 1145 | /* SPECIALS */ |
| 1146 | int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, |
| 1147 | int *pclass, long omax); |
| 1148 | int ASN1_check_infinite_end(unsigned char **p, long len); |
| 1149 | int ASN1_const_check_infinite_end(const unsigned char **p, long len); |
| 1150 | void ASN1_put_object(unsigned char **pp, int constructed, int length, |
| 1151 | int tag, int xclass); |
| 1152 | int ASN1_put_eoc(unsigned char **pp); |
| 1153 | int ASN1_object_size(int constructed, int length, int tag); |
| 1154 | |
| 1155 | /* Used to implement other functions */ |
| 1156 | void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x); |
| 1157 | |
| 1158 | #define ASN1_dup_of(type, i2d, d2i, x) \ |
| 1159 | ((type *)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ |
| 1160 | CHECKED_D2I_OF(type, d2i), \ |
| 1161 | CHECKED_PTR_OF(const type, x))) |
| 1162 | |
| 1163 | void *ASN1_item_dup(const ASN1_ITEM *it, const void *x); |
| 1164 | int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1, |
| 1165 | X509_ALGOR *algor2, ASN1_BIT_STRING *signature, |
| 1166 | const void *data, const ASN1_OCTET_STRING *id, |
| 1167 | EVP_PKEY *pkey, const EVP_MD *md, OSSL_LIB_CTX *libctx, |
| 1168 | const char *propq); |
| 1169 | int ASN1_item_verify_ex(const ASN1_ITEM *it, const X509_ALGOR *alg, |
| 1170 | const ASN1_BIT_STRING *signature, const void *data, |
| 1171 | const ASN1_OCTET_STRING *id, EVP_PKEY *pkey, |
| 1172 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1173 | |
| 1174 | /* ASN1 alloc/free macros for when a type is only used internally */ |
| 1175 | |
| 1176 | #define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) |
| 1177 | #define M_ASN1_free_of(x, type) \ |
| 1178 | ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) |
| 1179 | |
| 1180 | #ifndef OPENSSL_NO_STDIO |
| 1181 | void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); |
| 1182 | |
| 1183 | #define ASN1_d2i_fp_of(type, xnew, d2i, in, x) \ |
| 1184 | ((type *)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ |
| 1185 | CHECKED_D2I_OF(type, d2i), \ |
| 1186 | in, \ |
| 1187 | CHECKED_PPTR_OF(type, x))) |
| 1188 | |
| 1189 | void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x, |
| 1190 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1191 | void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); |
| 1192 | int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x); |
| 1193 | |
| 1194 | #define ASN1_i2d_fp_of(type, i2d, out, x) \ |
| 1195 | (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ |
| 1196 | out, \ |
| 1197 | CHECKED_PTR_OF(const type, x))) |
| 1198 | |
| 1199 | int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x); |
| 1200 | int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags); |
| 1201 | #endif |
| 1202 | |
| 1203 | int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); |
| 1204 | |
| 1205 | void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); |
| 1206 | |
| 1207 | #define ASN1_d2i_bio_of(type, xnew, d2i, in, x) \ |
| 1208 | ((type *)ASN1_d2i_bio(CHECKED_NEW_OF(type, xnew), \ |
| 1209 | CHECKED_D2I_OF(type, d2i), \ |
| 1210 | in, \ |
| 1211 | CHECKED_PPTR_OF(type, x))) |
| 1212 | |
| 1213 | void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *pval, |
| 1214 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1215 | void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *pval); |
| 1216 | int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x); |
| 1217 | |
| 1218 | #define ASN1_i2d_bio_of(type, i2d, out, x) \ |
| 1219 | (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ |
| 1220 | out, \ |
| 1221 | CHECKED_PTR_OF(const type, x))) |
| 1222 | |
| 1223 | int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x); |
| 1224 | BIO *ASN1_item_i2d_mem_bio(const ASN1_ITEM *it, const ASN1_VALUE *val); |
| 1225 | int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); |
| 1226 | int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); |
| 1227 | int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm); |
| 1228 | int ASN1_TIME_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags); |
| 1229 | int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); |
| 1230 | int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); |
| 1231 | int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off); |
| 1232 | int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, |
| 1233 | unsigned char *buf, int off); |
| 1234 | int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); |
| 1235 | int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, |
| 1236 | int dump); |
| 1237 | const char *ASN1_tag2str(int tag); |
| 1238 | |
| 1239 | /* Used to load and write Netscape format cert */ |
| 1240 | |
| 1241 | int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); |
| 1242 | |
| 1243 | int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); |
| 1244 | int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len); |
| 1245 | int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, |
| 1246 | unsigned char *data, int len); |
| 1247 | int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, |
| 1248 | unsigned char *data, int max_len); |
| 1249 | |
| 1250 | void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it); |
| 1251 | void *ASN1_item_unpack_ex(const ASN1_STRING *oct, const ASN1_ITEM *it, |
| 1252 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1253 | |
| 1254 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, |
| 1255 | ASN1_OCTET_STRING **oct); |
| 1256 | |
| 1257 | void ASN1_STRING_set_default_mask(unsigned long mask); |
| 1258 | int ASN1_STRING_set_default_mask_asc(const char *p); |
| 1259 | unsigned long ASN1_STRING_get_default_mask(void); |
| 1260 | int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, |
| 1261 | int inform, unsigned long mask); |
| 1262 | int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, |
| 1263 | int inform, unsigned long mask, |
| 1264 | long minsize, long maxsize); |
| 1265 | |
| 1266 | ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, |
| 1267 | const unsigned char *in, int inlen, |
| 1268 | int inform, int nid); |
| 1269 | ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); |
| 1270 | int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); |
| 1271 | void ASN1_STRING_TABLE_cleanup(void); |
| 1272 | |
| 1273 | /* ASN1 template functions */ |
| 1274 | |
| 1275 | /* Old API compatible functions */ |
| 1276 | ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); |
| 1277 | ASN1_VALUE *ASN1_item_new_ex(const ASN1_ITEM *it, OSSL_LIB_CTX *libctx, |
| 1278 | const char *propq); |
| 1279 | void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); |
| 1280 | ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **val, const unsigned char **in, |
| 1281 | long len, const ASN1_ITEM *it, |
| 1282 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1283 | ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, |
| 1284 | long len, const ASN1_ITEM *it); |
| 1285 | int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); |
| 1286 | int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out, |
| 1287 | const ASN1_ITEM *it); |
| 1288 | |
| 1289 | void ASN1_add_oid_module(void); |
| 1290 | void ASN1_add_stable_module(void); |
| 1291 | |
| 1292 | ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf); |
| 1293 | ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf); |
| 1294 | int ASN1_str2mask(const char *str, unsigned long *pmask); |
| 1295 | |
| 1296 | /* ASN1 Print flags */ |
| 1297 | |
| 1298 | /* Indicate missing OPTIONAL fields */ |
| 1299 | #define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 |
| 1300 | /* Mark start and end of SEQUENCE */ |
| 1301 | #define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 |
| 1302 | /* Mark start and end of SEQUENCE/SET OF */ |
| 1303 | #define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 |
| 1304 | /* Show the ASN1 type of primitives */ |
| 1305 | #define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 |
| 1306 | /* Don't show ASN1 type of ANY */ |
| 1307 | #define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 |
| 1308 | /* Don't show ASN1 type of MSTRINGs */ |
| 1309 | #define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 |
| 1310 | /* Don't show field names in SEQUENCE */ |
| 1311 | #define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 |
| 1312 | /* Show structure names of each SEQUENCE field */ |
| 1313 | #define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 |
| 1314 | /* Don't show structure name even at top level */ |
| 1315 | #define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 |
| 1316 | |
| 1317 | int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent, |
| 1318 | const ASN1_ITEM *it, const ASN1_PCTX *pctx); |
| 1319 | ASN1_PCTX *ASN1_PCTX_new(void); |
| 1320 | void ASN1_PCTX_free(ASN1_PCTX *p); |
| 1321 | unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p); |
| 1322 | void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); |
| 1323 | unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p); |
| 1324 | void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); |
| 1325 | unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p); |
| 1326 | void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); |
| 1327 | unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p); |
| 1328 | void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); |
| 1329 | unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p); |
| 1330 | void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); |
| 1331 | |
| 1332 | ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb)(ASN1_SCTX *ctx)); |
| 1333 | void ASN1_SCTX_free(ASN1_SCTX *p); |
| 1334 | const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p); |
| 1335 | const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p); |
| 1336 | unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p); |
| 1337 | void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data); |
| 1338 | void *ASN1_SCTX_get_app_data(ASN1_SCTX *p); |
| 1339 | |
| 1340 | const BIO_METHOD *BIO_f_asn1(void); |
| 1341 | |
| 1342 | /* cannot constify val because of CMS_stream() */ |
| 1343 | BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); |
| 1344 | |
| 1345 | int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, |
| 1346 | const ASN1_ITEM *it); |
| 1347 | int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, |
| 1348 | const char *hdr, const ASN1_ITEM *it); |
| 1349 | /* cannot constify val because of CMS_dataFinal() */ |
| 1350 | int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, |
| 1351 | int ctype_nid, int econt_nid, |
| 1352 | STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); |
| 1353 | int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, |
| 1354 | int ctype_nid, int econt_nid, |
| 1355 | STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it, |
| 1356 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1357 | ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); |
| 1358 | ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, int flags, BIO **bcont, |
| 1359 | const ASN1_ITEM *it, ASN1_VALUE **x, |
| 1360 | OSSL_LIB_CTX *libctx, const char *propq); |
| 1361 | int SMIME_crlf_copy(BIO *in, BIO *out, int flags); |
| 1362 | int SMIME_text(BIO *in, BIO *out); |
| 1363 | |
| 1364 | const ASN1_ITEM *ASN1_ITEM_lookup(const char *name); |
| 1365 | const ASN1_ITEM *ASN1_ITEM_get(size_t i); |
| 1366 | |
| 1367 | /* Legacy compatibility */ |
| 1368 | #define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ |
| 1369 | DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ |
| 1370 | DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) |
| 1371 | #define DECLARE_ASN1_FUNCTIONS_const(type) DECLARE_ASN1_FUNCTIONS(type) |
| 1372 | #define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ |
| 1373 | DECLARE_ASN1_ENCODE_FUNCTIONS(type, name) |
| 1374 | #define I2D_OF_const(type) I2D_OF(type) |
| 1375 | #define ASN1_dup_of_const(type, i2d, d2i, x) ASN1_dup_of(type, i2d, d2i, x) |
| 1376 | #define ASN1_i2d_fp_of_const(type, i2d, out, x) ASN1_i2d_fp_of(type, i2d, out, x) |
| 1377 | #define ASN1_i2d_bio_of_const(type, i2d, out, x) ASN1_i2d_bio_of(type, i2d, out, x) |
| 1378 | |
| 1379 | #ifdef __cplusplus |
| 1380 | } |
| 1381 | #endif |
| 1382 | #endif |
| 1383 | |