asn1.h 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. /*
  2. * WARNING: do not edit!
  3. * Generated by Makefile from include/openssl/asn1.h.in
  4. *
  5. * Copyright 1995-2021 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. #ifndef OPENSSL_ASN1_H
  13. # define OPENSSL_ASN1_H
  14. # pragma once
  15. # include <openssl/macros.h>
  16. # ifndef OPENSSL_NO_DEPRECATED_3_0
  17. # define HEADER_ASN1_H
  18. # endif
  19. # include <time.h>
  20. # include <openssl/e_os2.h>
  21. # include <openssl/opensslconf.h>
  22. # include <openssl/bio.h>
  23. # include <openssl/safestack.h>
  24. # include <openssl/asn1err.h>
  25. # include <openssl/symhacks.h>
  26. # include <openssl/types.h>
  27. # include <openssl/bn.h>
  28. # ifdef OPENSSL_BUILD_SHLIBCRYPTO
  29. # undef OPENSSL_EXTERN
  30. # define OPENSSL_EXTERN OPENSSL_EXPORT
  31. # endif
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. # define V_ASN1_UNIVERSAL 0x00
  36. # define V_ASN1_APPLICATION 0x40
  37. # define V_ASN1_CONTEXT_SPECIFIC 0x80
  38. # define V_ASN1_PRIVATE 0xc0
  39. # define V_ASN1_CONSTRUCTED 0x20
  40. # define V_ASN1_PRIMITIVE_TAG 0x1f
  41. # define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG
  42. # define V_ASN1_APP_CHOOSE -2/* let the recipient choose */
  43. # define V_ASN1_OTHER -3/* used in ASN1_TYPE */
  44. # define V_ASN1_ANY -4/* used in ASN1 template code */
  45. # define V_ASN1_UNDEF -1
  46. /* ASN.1 tag values */
  47. # define V_ASN1_EOC 0
  48. # define V_ASN1_BOOLEAN 1 /**/
  49. # define V_ASN1_INTEGER 2
  50. # define V_ASN1_BIT_STRING 3
  51. # define V_ASN1_OCTET_STRING 4
  52. # define V_ASN1_NULL 5
  53. # define V_ASN1_OBJECT 6
  54. # define V_ASN1_OBJECT_DESCRIPTOR 7
  55. # define V_ASN1_EXTERNAL 8
  56. # define V_ASN1_REAL 9
  57. # define V_ASN1_ENUMERATED 10
  58. # define V_ASN1_UTF8STRING 12
  59. # define V_ASN1_SEQUENCE 16
  60. # define V_ASN1_SET 17
  61. # define V_ASN1_NUMERICSTRING 18 /**/
  62. # define V_ASN1_PRINTABLESTRING 19
  63. # define V_ASN1_T61STRING 20
  64. # define V_ASN1_TELETEXSTRING 20/* alias */
  65. # define V_ASN1_VIDEOTEXSTRING 21 /**/
  66. # define V_ASN1_IA5STRING 22
  67. # define V_ASN1_UTCTIME 23
  68. # define V_ASN1_GENERALIZEDTIME 24 /**/
  69. # define V_ASN1_GRAPHICSTRING 25 /**/
  70. # define V_ASN1_ISO64STRING 26 /**/
  71. # define V_ASN1_VISIBLESTRING 26/* alias */
  72. # define V_ASN1_GENERALSTRING 27 /**/
  73. # define V_ASN1_UNIVERSALSTRING 28 /**/
  74. # define V_ASN1_BMPSTRING 30
  75. /*
  76. * NB the constants below are used internally by ASN1_INTEGER
  77. * and ASN1_ENUMERATED to indicate the sign. They are *not* on
  78. * the wire tag values.
  79. */
  80. # define V_ASN1_NEG 0x100
  81. # define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
  82. # define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
  83. /* For use with d2i_ASN1_type_bytes() */
  84. # define B_ASN1_NUMERICSTRING 0x0001
  85. # define B_ASN1_PRINTABLESTRING 0x0002
  86. # define B_ASN1_T61STRING 0x0004
  87. # define B_ASN1_TELETEXSTRING 0x0004
  88. # define B_ASN1_VIDEOTEXSTRING 0x0008
  89. # define B_ASN1_IA5STRING 0x0010
  90. # define B_ASN1_GRAPHICSTRING 0x0020
  91. # define B_ASN1_ISO64STRING 0x0040
  92. # define B_ASN1_VISIBLESTRING 0x0040
  93. # define B_ASN1_GENERALSTRING 0x0080
  94. # define B_ASN1_UNIVERSALSTRING 0x0100
  95. # define B_ASN1_OCTET_STRING 0x0200
  96. # define B_ASN1_BIT_STRING 0x0400
  97. # define B_ASN1_BMPSTRING 0x0800
  98. # define B_ASN1_UNKNOWN 0x1000
  99. # define B_ASN1_UTF8STRING 0x2000
  100. # define B_ASN1_UTCTIME 0x4000
  101. # define B_ASN1_GENERALIZEDTIME 0x8000
  102. # define B_ASN1_SEQUENCE 0x10000
  103. /* For use with ASN1_mbstring_copy() */
  104. # define MBSTRING_FLAG 0x1000
  105. # define MBSTRING_UTF8 (MBSTRING_FLAG)
  106. # define MBSTRING_ASC (MBSTRING_FLAG|1)
  107. # define MBSTRING_BMP (MBSTRING_FLAG|2)
  108. # define MBSTRING_UNIV (MBSTRING_FLAG|4)
  109. # define SMIME_OLDMIME 0x400
  110. # define SMIME_CRLFEOL 0x800
  111. # define SMIME_STREAM 0x1000
  112. /* Stacks for types not otherwise defined in this header */
  113. SKM_DEFINE_STACK_OF_INTERNAL(X509_ALGOR, X509_ALGOR, X509_ALGOR)
  114. #define sk_X509_ALGOR_num(sk) OPENSSL_sk_num(ossl_check_const_X509_ALGOR_sk_type(sk))
  115. #define sk_X509_ALGOR_value(sk, idx) ((X509_ALGOR *)OPENSSL_sk_value(ossl_check_const_X509_ALGOR_sk_type(sk), (idx)))
  116. #define sk_X509_ALGOR_new(cmp) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new(ossl_check_X509_ALGOR_compfunc_type(cmp)))
  117. #define sk_X509_ALGOR_new_null() ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_null())
  118. #define sk_X509_ALGOR_new_reserve(cmp, n) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_new_reserve(ossl_check_X509_ALGOR_compfunc_type(cmp), (n)))
  119. #define sk_X509_ALGOR_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_X509_ALGOR_sk_type(sk), (n))
  120. #define sk_X509_ALGOR_free(sk) OPENSSL_sk_free(ossl_check_X509_ALGOR_sk_type(sk))
  121. #define sk_X509_ALGOR_zero(sk) OPENSSL_sk_zero(ossl_check_X509_ALGOR_sk_type(sk))
  122. #define sk_X509_ALGOR_delete(sk, i) ((X509_ALGOR *)OPENSSL_sk_delete(ossl_check_X509_ALGOR_sk_type(sk), (i)))
  123. #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)))
  124. #define sk_X509_ALGOR_push(sk, ptr) OPENSSL_sk_push(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
  125. #define sk_X509_ALGOR_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
  126. #define sk_X509_ALGOR_pop(sk) ((X509_ALGOR *)OPENSSL_sk_pop(ossl_check_X509_ALGOR_sk_type(sk)))
  127. #define sk_X509_ALGOR_shift(sk) ((X509_ALGOR *)OPENSSL_sk_shift(ossl_check_X509_ALGOR_sk_type(sk)))
  128. #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))
  129. #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))
  130. #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)))
  131. #define sk_X509_ALGOR_find(sk, ptr) OPENSSL_sk_find(ossl_check_X509_ALGOR_sk_type(sk), ossl_check_X509_ALGOR_type(ptr))
  132. #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))
  133. #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)
  134. #define sk_X509_ALGOR_sort(sk) OPENSSL_sk_sort(ossl_check_X509_ALGOR_sk_type(sk))
  135. #define sk_X509_ALGOR_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_X509_ALGOR_sk_type(sk))
  136. #define sk_X509_ALGOR_dup(sk) ((STACK_OF(X509_ALGOR) *)OPENSSL_sk_dup(ossl_check_const_X509_ALGOR_sk_type(sk)))
  137. #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)))
  138. #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)))
  139. # define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */
  140. /*
  141. * This indicates that the ASN1_STRING is not a real value but just a place
  142. * holder for the location where indefinite length constructed data should be
  143. * inserted in the memory buffer
  144. */
  145. # define ASN1_STRING_FLAG_NDEF 0x010
  146. /*
  147. * This flag is used by the CMS code to indicate that a string is not
  148. * complete and is a place holder for content when it had all been accessed.
  149. * The flag will be reset when content has been written to it.
  150. */
  151. # define ASN1_STRING_FLAG_CONT 0x020
  152. /*
  153. * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
  154. * type.
  155. */
  156. # define ASN1_STRING_FLAG_MSTRING 0x040
  157. /* String is embedded and only content should be freed */
  158. # define ASN1_STRING_FLAG_EMBED 0x080
  159. /* String should be parsed in RFC 5280's time format */
  160. # define ASN1_STRING_FLAG_X509_TIME 0x100
  161. /* This is the base type that holds just about everything :-) */
  162. struct asn1_string_st {
  163. int length;
  164. int type;
  165. unsigned char *data;
  166. /*
  167. * The value of the following field depends on the type being held. It
  168. * is mostly being used for BIT_STRING so if the input data has a
  169. * non-zero 'unused bits' value, it will be handled correctly
  170. */
  171. long flags;
  172. };
  173. /*
  174. * ASN1_ENCODING structure: this is used to save the received encoding of an
  175. * ASN1 type. This is useful to get round problems with invalid encodings
  176. * which can break signatures.
  177. */
  178. typedef struct ASN1_ENCODING_st {
  179. unsigned char *enc; /* DER encoding */
  180. long len; /* Length of encoding */
  181. int modified; /* set to 1 if 'enc' is invalid */
  182. } ASN1_ENCODING;
  183. /* Used with ASN1 LONG type: if a long is set to this it is omitted */
  184. # define ASN1_LONG_UNDEF 0x7fffffffL
  185. # define STABLE_FLAGS_MALLOC 0x01
  186. /*
  187. * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted
  188. * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting
  189. * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias
  190. * STABLE_FLAGS_CLEAR to reflect this.
  191. */
  192. # define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC
  193. # define STABLE_NO_MASK 0x02
  194. # define DIRSTRING_TYPE \
  195. (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
  196. # define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
  197. struct asn1_string_table_st {
  198. int nid;
  199. long minsize;
  200. long maxsize;
  201. unsigned long mask;
  202. unsigned long flags;
  203. };
  204. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_STRING_TABLE, ASN1_STRING_TABLE, ASN1_STRING_TABLE)
  205. #define sk_ASN1_STRING_TABLE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))
  206. #define sk_ASN1_STRING_TABLE_value(sk, idx) ((ASN1_STRING_TABLE *)OPENSSL_sk_value(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk), (idx)))
  207. #define sk_ASN1_STRING_TABLE_new(cmp) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new(ossl_check_ASN1_STRING_TABLE_compfunc_type(cmp)))
  208. #define sk_ASN1_STRING_TABLE_new_null() ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_new_null())
  209. #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)))
  210. #define sk_ASN1_STRING_TABLE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (n))
  211. #define sk_ASN1_STRING_TABLE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_STRING_TABLE_sk_type(sk))
  212. #define sk_ASN1_STRING_TABLE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_STRING_TABLE_sk_type(sk))
  213. #define sk_ASN1_STRING_TABLE_delete(sk, i) ((ASN1_STRING_TABLE *)OPENSSL_sk_delete(ossl_check_ASN1_STRING_TABLE_sk_type(sk), (i)))
  214. #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)))
  215. #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))
  216. #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))
  217. #define sk_ASN1_STRING_TABLE_pop(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_pop(ossl_check_ASN1_STRING_TABLE_sk_type(sk)))
  218. #define sk_ASN1_STRING_TABLE_shift(sk) ((ASN1_STRING_TABLE *)OPENSSL_sk_shift(ossl_check_ASN1_STRING_TABLE_sk_type(sk)))
  219. #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))
  220. #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))
  221. #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)))
  222. #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))
  223. #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))
  224. #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)
  225. #define sk_ASN1_STRING_TABLE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_STRING_TABLE_sk_type(sk))
  226. #define sk_ASN1_STRING_TABLE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk))
  227. #define sk_ASN1_STRING_TABLE_dup(sk) ((STACK_OF(ASN1_STRING_TABLE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_STRING_TABLE_sk_type(sk)))
  228. #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)))
  229. #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)))
  230. /* size limits: this stuff is taken straight from RFC2459 */
  231. # define ub_name 32768
  232. # define ub_common_name 64
  233. # define ub_locality_name 128
  234. # define ub_state_name 128
  235. # define ub_organization_name 64
  236. # define ub_organization_unit_name 64
  237. # define ub_title 64
  238. # define ub_email_address 128
  239. /*
  240. * Declarations for template structures: for full definitions see asn1t.h
  241. */
  242. typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
  243. typedef struct ASN1_TLC_st ASN1_TLC;
  244. /* This is just an opaque pointer */
  245. typedef struct ASN1_VALUE_st ASN1_VALUE;
  246. /* Declare ASN1 functions: the implement macro in in asn1t.h */
  247. /*
  248. * The mysterious 'extern' that's passed to some macros is innocuous,
  249. * and is there to quiet pre-C99 compilers that may complain about empty
  250. * arguments in macro calls.
  251. */
  252. # define DECLARE_ASN1_FUNCTIONS_attr(attr, type) \
  253. DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, type)
  254. # define DECLARE_ASN1_FUNCTIONS(type) \
  255. DECLARE_ASN1_FUNCTIONS_attr(extern, type)
  256. # define DECLARE_ASN1_ALLOC_FUNCTIONS_attr(attr, type) \
  257. DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, type)
  258. # define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
  259. DECLARE_ASN1_ALLOC_FUNCTIONS_attr(extern, type)
  260. # define DECLARE_ASN1_FUNCTIONS_name_attr(attr, type, name) \
  261. DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \
  262. DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name)
  263. # define DECLARE_ASN1_FUNCTIONS_name(type, name) \
  264. DECLARE_ASN1_FUNCTIONS_name_attr(extern, type, name)
  265. # define DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, itname, name) \
  266. DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \
  267. DECLARE_ASN1_ITEM_attr(attr, itname)
  268. # define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
  269. DECLARE_ASN1_ENCODE_FUNCTIONS_attr(extern, type, itname, name)
  270. # define DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(attr, type, name) \
  271. DECLARE_ASN1_ENCODE_FUNCTIONS_attr(attr, type, name, name)
  272. # define DECLARE_ASN1_ENCODE_FUNCTIONS_name(type, name) \
  273. DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(extern, type, name)
  274. # define DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(attr, type, name) \
  275. attr type *d2i_##name(type **a, const unsigned char **in, long len); \
  276. attr int i2d_##name(const type *a, unsigned char **out);
  277. # define DECLARE_ASN1_ENCODE_FUNCTIONS_only(type, name) \
  278. DECLARE_ASN1_ENCODE_FUNCTIONS_only_attr(extern, type, name)
  279. # define DECLARE_ASN1_NDEF_FUNCTION_attr(attr, name) \
  280. attr int i2d_##name##_NDEF(const name *a, unsigned char **out);
  281. # define DECLARE_ASN1_NDEF_FUNCTION(name) \
  282. DECLARE_ASN1_NDEF_FUNCTION_attr(extern, name)
  283. # define DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(attr, type, name) \
  284. attr type *name##_new(void); \
  285. attr void name##_free(type *a);
  286. # define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
  287. DECLARE_ASN1_ALLOC_FUNCTIONS_name_attr(extern, type, name)
  288. # define DECLARE_ASN1_DUP_FUNCTION_attr(attr, type) \
  289. DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, type)
  290. # define DECLARE_ASN1_DUP_FUNCTION(type) \
  291. DECLARE_ASN1_DUP_FUNCTION_attr(extern, type)
  292. # define DECLARE_ASN1_DUP_FUNCTION_name_attr(attr, type, name) \
  293. attr type *name##_dup(const type *a);
  294. # define DECLARE_ASN1_DUP_FUNCTION_name(type, name) \
  295. DECLARE_ASN1_DUP_FUNCTION_name_attr(extern, type, name)
  296. # define DECLARE_ASN1_PRINT_FUNCTION_attr(attr, stname) \
  297. DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, stname)
  298. # define DECLARE_ASN1_PRINT_FUNCTION(stname) \
  299. DECLARE_ASN1_PRINT_FUNCTION_attr(extern, stname)
  300. # define DECLARE_ASN1_PRINT_FUNCTION_fname_attr(attr, stname, fname) \
  301. attr int fname##_print_ctx(BIO *out, const stname *x, int indent, \
  302. const ASN1_PCTX *pctx);
  303. # define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \
  304. DECLARE_ASN1_PRINT_FUNCTION_fname_attr(extern, stname, fname)
  305. # define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
  306. # define I2D_OF(type) int (*)(const type *,unsigned char **)
  307. # define CHECKED_D2I_OF(type, d2i) \
  308. ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))
  309. # define CHECKED_I2D_OF(type, i2d) \
  310. ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))
  311. # define CHECKED_NEW_OF(type, xnew) \
  312. ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))
  313. # define CHECKED_PTR_OF(type, p) \
  314. ((void*) (1 ? p : (type*)0))
  315. # define CHECKED_PPTR_OF(type, p) \
  316. ((void**) (1 ? p : (type**)0))
  317. # define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
  318. # define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(const type *,unsigned char **)
  319. # define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
  320. typedef void *d2i_of_void(void **, const unsigned char **, long);
  321. typedef int i2d_of_void(const void *, unsigned char **);
  322. /*-
  323. * The following macros and typedefs allow an ASN1_ITEM
  324. * to be embedded in a structure and referenced. Since
  325. * the ASN1_ITEM pointers need to be globally accessible
  326. * (possibly from shared libraries) they may exist in
  327. * different forms. On platforms that support it the
  328. * ASN1_ITEM structure itself will be globally exported.
  329. * Other platforms will export a function that returns
  330. * an ASN1_ITEM pointer.
  331. *
  332. * To handle both cases transparently the macros below
  333. * should be used instead of hard coding an ASN1_ITEM
  334. * pointer in a structure.
  335. *
  336. * The structure will look like this:
  337. *
  338. * typedef struct SOMETHING_st {
  339. * ...
  340. * ASN1_ITEM_EXP *iptr;
  341. * ...
  342. * } SOMETHING;
  343. *
  344. * It would be initialised as e.g.:
  345. *
  346. * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
  347. *
  348. * and the actual pointer extracted with:
  349. *
  350. * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
  351. *
  352. * Finally an ASN1_ITEM pointer can be extracted from an
  353. * appropriate reference with: ASN1_ITEM_rptr(X509). This
  354. * would be used when a function takes an ASN1_ITEM * argument.
  355. *
  356. */
  357. /*
  358. * Platforms that can't easily handle shared global variables are declared as
  359. * functions returning ASN1_ITEM pointers.
  360. */
  361. /* ASN1_ITEM pointer exported type */
  362. typedef const ASN1_ITEM *ASN1_ITEM_EXP (void);
  363. /* Macro to obtain ASN1_ITEM pointer from exported type */
  364. # define ASN1_ITEM_ptr(iptr) (iptr())
  365. /* Macro to include ASN1_ITEM pointer from base type */
  366. # define ASN1_ITEM_ref(iptr) (iptr##_it)
  367. # define ASN1_ITEM_rptr(ref) (ref##_it())
  368. # define DECLARE_ASN1_ITEM_attr(attr, name) \
  369. attr const ASN1_ITEM * name##_it(void);
  370. # define DECLARE_ASN1_ITEM(name) \
  371. DECLARE_ASN1_ITEM_attr(extern, name)
  372. /* Parameters used by ASN1_STRING_print_ex() */
  373. /*
  374. * These determine which characters to escape: RFC2253 special characters,
  375. * control characters and MSB set characters
  376. */
  377. # define ASN1_STRFLGS_ESC_2253 1
  378. # define ASN1_STRFLGS_ESC_CTRL 2
  379. # define ASN1_STRFLGS_ESC_MSB 4
  380. /* Lower 8 bits are reserved as an output type specifier */
  381. # define ASN1_DTFLGS_TYPE_MASK 0x0FUL
  382. # define ASN1_DTFLGS_RFC822 0x00UL
  383. # define ASN1_DTFLGS_ISO8601 0x01UL
  384. /*
  385. * This flag determines how we do escaping: normally RC2253 backslash only,
  386. * set this to use backslash and quote.
  387. */
  388. # define ASN1_STRFLGS_ESC_QUOTE 8
  389. /* These three flags are internal use only. */
  390. /* Character is a valid PrintableString character */
  391. # define CHARTYPE_PRINTABLESTRING 0x10
  392. /* Character needs escaping if it is the first character */
  393. # define CHARTYPE_FIRST_ESC_2253 0x20
  394. /* Character needs escaping if it is the last character */
  395. # define CHARTYPE_LAST_ESC_2253 0x40
  396. /*
  397. * NB the internal flags are safely reused below by flags handled at the top
  398. * level.
  399. */
  400. /*
  401. * If this is set we convert all character strings to UTF8 first
  402. */
  403. # define ASN1_STRFLGS_UTF8_CONVERT 0x10
  404. /*
  405. * If this is set we don't attempt to interpret content: just assume all
  406. * strings are 1 byte per character. This will produce some pretty odd
  407. * looking output!
  408. */
  409. # define ASN1_STRFLGS_IGNORE_TYPE 0x20
  410. /* If this is set we include the string type in the output */
  411. # define ASN1_STRFLGS_SHOW_TYPE 0x40
  412. /*
  413. * This determines which strings to display and which to 'dump' (hex dump of
  414. * content octets or DER encoding). We can only dump non character strings or
  415. * everything. If we don't dump 'unknown' they are interpreted as character
  416. * strings with 1 octet per character and are subject to the usual escaping
  417. * options.
  418. */
  419. # define ASN1_STRFLGS_DUMP_ALL 0x80
  420. # define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
  421. /*
  422. * These determine what 'dumping' does, we can dump the content octets or the
  423. * DER encoding: both use the RFC2253 #XXXXX notation.
  424. */
  425. # define ASN1_STRFLGS_DUMP_DER 0x200
  426. /*
  427. * This flag specifies that RC2254 escaping shall be performed.
  428. */
  429. #define ASN1_STRFLGS_ESC_2254 0x400
  430. /*
  431. * All the string flags consistent with RFC2253, escaping control characters
  432. * isn't essential in RFC2253 but it is advisable anyway.
  433. */
  434. # define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
  435. ASN1_STRFLGS_ESC_CTRL | \
  436. ASN1_STRFLGS_ESC_MSB | \
  437. ASN1_STRFLGS_UTF8_CONVERT | \
  438. ASN1_STRFLGS_DUMP_UNKNOWN | \
  439. ASN1_STRFLGS_DUMP_DER)
  440. struct asn1_type_st {
  441. int type;
  442. union {
  443. char *ptr;
  444. ASN1_BOOLEAN boolean;
  445. ASN1_STRING *asn1_string;
  446. ASN1_OBJECT *object;
  447. ASN1_INTEGER *integer;
  448. ASN1_ENUMERATED *enumerated;
  449. ASN1_BIT_STRING *bit_string;
  450. ASN1_OCTET_STRING *octet_string;
  451. ASN1_PRINTABLESTRING *printablestring;
  452. ASN1_T61STRING *t61string;
  453. ASN1_IA5STRING *ia5string;
  454. ASN1_GENERALSTRING *generalstring;
  455. ASN1_BMPSTRING *bmpstring;
  456. ASN1_UNIVERSALSTRING *universalstring;
  457. ASN1_UTCTIME *utctime;
  458. ASN1_GENERALIZEDTIME *generalizedtime;
  459. ASN1_VISIBLESTRING *visiblestring;
  460. ASN1_UTF8STRING *utf8string;
  461. /*
  462. * set and sequence are left complete and still contain the set or
  463. * sequence bytes
  464. */
  465. ASN1_STRING *set;
  466. ASN1_STRING *sequence;
  467. ASN1_VALUE *asn1_value;
  468. } value;
  469. };
  470. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_TYPE, ASN1_TYPE, ASN1_TYPE)
  471. #define sk_ASN1_TYPE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_TYPE_sk_type(sk))
  472. #define sk_ASN1_TYPE_value(sk, idx) ((ASN1_TYPE *)OPENSSL_sk_value(ossl_check_const_ASN1_TYPE_sk_type(sk), (idx)))
  473. #define sk_ASN1_TYPE_new(cmp) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new(ossl_check_ASN1_TYPE_compfunc_type(cmp)))
  474. #define sk_ASN1_TYPE_new_null() ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_null())
  475. #define sk_ASN1_TYPE_new_reserve(cmp, n) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_TYPE_compfunc_type(cmp), (n)))
  476. #define sk_ASN1_TYPE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_TYPE_sk_type(sk), (n))
  477. #define sk_ASN1_TYPE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_TYPE_sk_type(sk))
  478. #define sk_ASN1_TYPE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_TYPE_sk_type(sk))
  479. #define sk_ASN1_TYPE_delete(sk, i) ((ASN1_TYPE *)OPENSSL_sk_delete(ossl_check_ASN1_TYPE_sk_type(sk), (i)))
  480. #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)))
  481. #define sk_ASN1_TYPE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
  482. #define sk_ASN1_TYPE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
  483. #define sk_ASN1_TYPE_pop(sk) ((ASN1_TYPE *)OPENSSL_sk_pop(ossl_check_ASN1_TYPE_sk_type(sk)))
  484. #define sk_ASN1_TYPE_shift(sk) ((ASN1_TYPE *)OPENSSL_sk_shift(ossl_check_ASN1_TYPE_sk_type(sk)))
  485. #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))
  486. #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))
  487. #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)))
  488. #define sk_ASN1_TYPE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_TYPE_sk_type(sk), ossl_check_ASN1_TYPE_type(ptr))
  489. #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))
  490. #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)
  491. #define sk_ASN1_TYPE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_TYPE_sk_type(sk))
  492. #define sk_ASN1_TYPE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_TYPE_sk_type(sk))
  493. #define sk_ASN1_TYPE_dup(sk) ((STACK_OF(ASN1_TYPE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_TYPE_sk_type(sk)))
  494. #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)))
  495. #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)))
  496. typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
  497. DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
  498. DECLARE_ASN1_ENCODE_FUNCTIONS_name(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)
  499. /* This is used to contain a list of bit names */
  500. typedef struct BIT_STRING_BITNAME_st {
  501. int bitnum;
  502. const char *lname;
  503. const char *sname;
  504. } BIT_STRING_BITNAME;
  505. # define B_ASN1_TIME \
  506. B_ASN1_UTCTIME | \
  507. B_ASN1_GENERALIZEDTIME
  508. # define B_ASN1_PRINTABLE \
  509. B_ASN1_NUMERICSTRING| \
  510. B_ASN1_PRINTABLESTRING| \
  511. B_ASN1_T61STRING| \
  512. B_ASN1_IA5STRING| \
  513. B_ASN1_BIT_STRING| \
  514. B_ASN1_UNIVERSALSTRING|\
  515. B_ASN1_BMPSTRING|\
  516. B_ASN1_UTF8STRING|\
  517. B_ASN1_SEQUENCE|\
  518. B_ASN1_UNKNOWN
  519. # define B_ASN1_DIRECTORYSTRING \
  520. B_ASN1_PRINTABLESTRING| \
  521. B_ASN1_TELETEXSTRING|\
  522. B_ASN1_BMPSTRING|\
  523. B_ASN1_UNIVERSALSTRING|\
  524. B_ASN1_UTF8STRING
  525. # define B_ASN1_DISPLAYTEXT \
  526. B_ASN1_IA5STRING| \
  527. B_ASN1_VISIBLESTRING| \
  528. B_ASN1_BMPSTRING|\
  529. B_ASN1_UTF8STRING
  530. DECLARE_ASN1_ALLOC_FUNCTIONS_name(ASN1_TYPE, ASN1_TYPE)
  531. DECLARE_ASN1_ENCODE_FUNCTIONS(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
  532. int ASN1_TYPE_get(const ASN1_TYPE *a);
  533. void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
  534. int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
  535. int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
  536. ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);
  537. void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
  538. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_OBJECT, ASN1_OBJECT, ASN1_OBJECT)
  539. #define sk_ASN1_OBJECT_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_OBJECT_sk_type(sk))
  540. #define sk_ASN1_OBJECT_value(sk, idx) ((ASN1_OBJECT *)OPENSSL_sk_value(ossl_check_const_ASN1_OBJECT_sk_type(sk), (idx)))
  541. #define sk_ASN1_OBJECT_new(cmp) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new(ossl_check_ASN1_OBJECT_compfunc_type(cmp)))
  542. #define sk_ASN1_OBJECT_new_null() ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_null())
  543. #define sk_ASN1_OBJECT_new_reserve(cmp, n) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_OBJECT_compfunc_type(cmp), (n)))
  544. #define sk_ASN1_OBJECT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_OBJECT_sk_type(sk), (n))
  545. #define sk_ASN1_OBJECT_free(sk) OPENSSL_sk_free(ossl_check_ASN1_OBJECT_sk_type(sk))
  546. #define sk_ASN1_OBJECT_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_OBJECT_sk_type(sk))
  547. #define sk_ASN1_OBJECT_delete(sk, i) ((ASN1_OBJECT *)OPENSSL_sk_delete(ossl_check_ASN1_OBJECT_sk_type(sk), (i)))
  548. #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)))
  549. #define sk_ASN1_OBJECT_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
  550. #define sk_ASN1_OBJECT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
  551. #define sk_ASN1_OBJECT_pop(sk) ((ASN1_OBJECT *)OPENSSL_sk_pop(ossl_check_ASN1_OBJECT_sk_type(sk)))
  552. #define sk_ASN1_OBJECT_shift(sk) ((ASN1_OBJECT *)OPENSSL_sk_shift(ossl_check_ASN1_OBJECT_sk_type(sk)))
  553. #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))
  554. #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))
  555. #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)))
  556. #define sk_ASN1_OBJECT_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_OBJECT_sk_type(sk), ossl_check_ASN1_OBJECT_type(ptr))
  557. #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))
  558. #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)
  559. #define sk_ASN1_OBJECT_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_OBJECT_sk_type(sk))
  560. #define sk_ASN1_OBJECT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_OBJECT_sk_type(sk))
  561. #define sk_ASN1_OBJECT_dup(sk) ((STACK_OF(ASN1_OBJECT) *)OPENSSL_sk_dup(ossl_check_const_ASN1_OBJECT_sk_type(sk)))
  562. #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)))
  563. #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)))
  564. DECLARE_ASN1_FUNCTIONS(ASN1_OBJECT)
  565. ASN1_STRING *ASN1_STRING_new(void);
  566. void ASN1_STRING_free(ASN1_STRING *a);
  567. void ASN1_STRING_clear_free(ASN1_STRING *a);
  568. int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
  569. DECLARE_ASN1_DUP_FUNCTION(ASN1_STRING)
  570. ASN1_STRING *ASN1_STRING_type_new(int type);
  571. int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
  572. /*
  573. * Since this is used to store all sorts of things, via macros, for now,
  574. * make its data void *
  575. */
  576. int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
  577. void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
  578. int ASN1_STRING_length(const ASN1_STRING *x);
  579. # ifndef OPENSSL_NO_DEPRECATED_3_0
  580. OSSL_DEPRECATEDIN_3_0 void ASN1_STRING_length_set(ASN1_STRING *x, int n);
  581. # endif
  582. int ASN1_STRING_type(const ASN1_STRING *x);
  583. # ifndef OPENSSL_NO_DEPRECATED_1_1_0
  584. OSSL_DEPRECATEDIN_1_1_0 unsigned char *ASN1_STRING_data(ASN1_STRING *x);
  585. # endif
  586. const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);
  587. DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
  588. int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);
  589. int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
  590. int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);
  591. int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,
  592. const unsigned char *flags, int flags_len);
  593. int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
  594. BIT_STRING_BITNAME *tbl, int indent);
  595. int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);
  596. int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,
  597. BIT_STRING_BITNAME *tbl);
  598. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_INTEGER, ASN1_INTEGER, ASN1_INTEGER)
  599. #define sk_ASN1_INTEGER_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_INTEGER_sk_type(sk))
  600. #define sk_ASN1_INTEGER_value(sk, idx) ((ASN1_INTEGER *)OPENSSL_sk_value(ossl_check_const_ASN1_INTEGER_sk_type(sk), (idx)))
  601. #define sk_ASN1_INTEGER_new(cmp) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new(ossl_check_ASN1_INTEGER_compfunc_type(cmp)))
  602. #define sk_ASN1_INTEGER_new_null() ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_null())
  603. #define sk_ASN1_INTEGER_new_reserve(cmp, n) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_INTEGER_compfunc_type(cmp), (n)))
  604. #define sk_ASN1_INTEGER_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_INTEGER_sk_type(sk), (n))
  605. #define sk_ASN1_INTEGER_free(sk) OPENSSL_sk_free(ossl_check_ASN1_INTEGER_sk_type(sk))
  606. #define sk_ASN1_INTEGER_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_INTEGER_sk_type(sk))
  607. #define sk_ASN1_INTEGER_delete(sk, i) ((ASN1_INTEGER *)OPENSSL_sk_delete(ossl_check_ASN1_INTEGER_sk_type(sk), (i)))
  608. #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)))
  609. #define sk_ASN1_INTEGER_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
  610. #define sk_ASN1_INTEGER_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
  611. #define sk_ASN1_INTEGER_pop(sk) ((ASN1_INTEGER *)OPENSSL_sk_pop(ossl_check_ASN1_INTEGER_sk_type(sk)))
  612. #define sk_ASN1_INTEGER_shift(sk) ((ASN1_INTEGER *)OPENSSL_sk_shift(ossl_check_ASN1_INTEGER_sk_type(sk)))
  613. #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))
  614. #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))
  615. #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)))
  616. #define sk_ASN1_INTEGER_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_INTEGER_sk_type(sk), ossl_check_ASN1_INTEGER_type(ptr))
  617. #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))
  618. #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)
  619. #define sk_ASN1_INTEGER_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_INTEGER_sk_type(sk))
  620. #define sk_ASN1_INTEGER_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_INTEGER_sk_type(sk))
  621. #define sk_ASN1_INTEGER_dup(sk) ((STACK_OF(ASN1_INTEGER) *)OPENSSL_sk_dup(ossl_check_const_ASN1_INTEGER_sk_type(sk)))
  622. #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)))
  623. #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)))
  624. DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
  625. ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
  626. long length);
  627. DECLARE_ASN1_DUP_FUNCTION(ASN1_INTEGER)
  628. int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
  629. DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
  630. int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
  631. ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);
  632. ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
  633. int offset_day, long offset_sec);
  634. int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
  635. int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
  636. int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
  637. ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
  638. time_t t);
  639. ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
  640. time_t t, int offset_day,
  641. long offset_sec);
  642. int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
  643. int ASN1_TIME_diff(int *pday, int *psec,
  644. const ASN1_TIME *from, const ASN1_TIME *to);
  645. DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
  646. DECLARE_ASN1_DUP_FUNCTION(ASN1_OCTET_STRING)
  647. int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
  648. const ASN1_OCTET_STRING *b);
  649. int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
  650. int len);
  651. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_UTF8STRING, ASN1_UTF8STRING, ASN1_UTF8STRING)
  652. #define sk_ASN1_UTF8STRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_UTF8STRING_sk_type(sk))
  653. #define sk_ASN1_UTF8STRING_value(sk, idx) ((ASN1_UTF8STRING *)OPENSSL_sk_value(ossl_check_const_ASN1_UTF8STRING_sk_type(sk), (idx)))
  654. #define sk_ASN1_UTF8STRING_new(cmp) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp)))
  655. #define sk_ASN1_UTF8STRING_new_null() ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_null())
  656. #define sk_ASN1_UTF8STRING_new_reserve(cmp, n) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_UTF8STRING_compfunc_type(cmp), (n)))
  657. #define sk_ASN1_UTF8STRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_UTF8STRING_sk_type(sk), (n))
  658. #define sk_ASN1_UTF8STRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_UTF8STRING_sk_type(sk))
  659. #define sk_ASN1_UTF8STRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_UTF8STRING_sk_type(sk))
  660. #define sk_ASN1_UTF8STRING_delete(sk, i) ((ASN1_UTF8STRING *)OPENSSL_sk_delete(ossl_check_ASN1_UTF8STRING_sk_type(sk), (i)))
  661. #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)))
  662. #define sk_ASN1_UTF8STRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
  663. #define sk_ASN1_UTF8STRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
  664. #define sk_ASN1_UTF8STRING_pop(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_pop(ossl_check_ASN1_UTF8STRING_sk_type(sk)))
  665. #define sk_ASN1_UTF8STRING_shift(sk) ((ASN1_UTF8STRING *)OPENSSL_sk_shift(ossl_check_ASN1_UTF8STRING_sk_type(sk)))
  666. #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))
  667. #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))
  668. #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)))
  669. #define sk_ASN1_UTF8STRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_UTF8STRING_sk_type(sk), ossl_check_ASN1_UTF8STRING_type(ptr))
  670. #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))
  671. #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)
  672. #define sk_ASN1_UTF8STRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_UTF8STRING_sk_type(sk))
  673. #define sk_ASN1_UTF8STRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_UTF8STRING_sk_type(sk))
  674. #define sk_ASN1_UTF8STRING_dup(sk) ((STACK_OF(ASN1_UTF8STRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_UTF8STRING_sk_type(sk)))
  675. #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)))
  676. #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)))
  677. DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
  678. DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
  679. DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
  680. DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
  681. DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
  682. int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
  683. int UTF8_putc(unsigned char *str, int len, unsigned long value);
  684. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_GENERALSTRING, ASN1_GENERALSTRING, ASN1_GENERALSTRING)
  685. #define sk_ASN1_GENERALSTRING_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))
  686. #define sk_ASN1_GENERALSTRING_value(sk, idx) ((ASN1_GENERALSTRING *)OPENSSL_sk_value(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk), (idx)))
  687. #define sk_ASN1_GENERALSTRING_new(cmp) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp)))
  688. #define sk_ASN1_GENERALSTRING_new_null() ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_null())
  689. #define sk_ASN1_GENERALSTRING_new_reserve(cmp, n) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_GENERALSTRING_compfunc_type(cmp), (n)))
  690. #define sk_ASN1_GENERALSTRING_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (n))
  691. #define sk_ASN1_GENERALSTRING_free(sk) OPENSSL_sk_free(ossl_check_ASN1_GENERALSTRING_sk_type(sk))
  692. #define sk_ASN1_GENERALSTRING_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_GENERALSTRING_sk_type(sk))
  693. #define sk_ASN1_GENERALSTRING_delete(sk, i) ((ASN1_GENERALSTRING *)OPENSSL_sk_delete(ossl_check_ASN1_GENERALSTRING_sk_type(sk), (i)))
  694. #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)))
  695. #define sk_ASN1_GENERALSTRING_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
  696. #define sk_ASN1_GENERALSTRING_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
  697. #define sk_ASN1_GENERALSTRING_pop(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_pop(ossl_check_ASN1_GENERALSTRING_sk_type(sk)))
  698. #define sk_ASN1_GENERALSTRING_shift(sk) ((ASN1_GENERALSTRING *)OPENSSL_sk_shift(ossl_check_ASN1_GENERALSTRING_sk_type(sk)))
  699. #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))
  700. #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))
  701. #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)))
  702. #define sk_ASN1_GENERALSTRING_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_GENERALSTRING_sk_type(sk), ossl_check_ASN1_GENERALSTRING_type(ptr))
  703. #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))
  704. #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)
  705. #define sk_ASN1_GENERALSTRING_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_GENERALSTRING_sk_type(sk))
  706. #define sk_ASN1_GENERALSTRING_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk))
  707. #define sk_ASN1_GENERALSTRING_dup(sk) ((STACK_OF(ASN1_GENERALSTRING) *)OPENSSL_sk_dup(ossl_check_const_ASN1_GENERALSTRING_sk_type(sk)))
  708. #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)))
  709. #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)))
  710. DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
  711. DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
  712. DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
  713. DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
  714. DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
  715. DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
  716. DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
  717. DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
  718. DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
  719. DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
  720. DECLARE_ASN1_DUP_FUNCTION(ASN1_TIME)
  721. DECLARE_ASN1_DUP_FUNCTION(ASN1_UTCTIME)
  722. DECLARE_ASN1_DUP_FUNCTION(ASN1_GENERALIZEDTIME)
  723. DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
  724. ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
  725. ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
  726. int offset_day, long offset_sec);
  727. int ASN1_TIME_check(const ASN1_TIME *t);
  728. ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
  729. ASN1_GENERALIZEDTIME **out);
  730. int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
  731. int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str);
  732. int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);
  733. int ASN1_TIME_normalize(ASN1_TIME *s);
  734. int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t);
  735. int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b);
  736. int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a);
  737. int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);
  738. int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a);
  739. int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);
  740. int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a);
  741. int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);
  742. int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);
  743. int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);
  744. int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);
  745. ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
  746. const char *sn, const char *ln);
  747. int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);
  748. int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
  749. int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
  750. int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
  751. int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
  752. long ASN1_INTEGER_get(const ASN1_INTEGER *a);
  753. ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
  754. BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
  755. int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);
  756. int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);
  757. int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
  758. long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
  759. ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);
  760. BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);
  761. /* General */
  762. /* given a string, return the correct type, max is the maximum length */
  763. int ASN1_PRINTABLE_type(const unsigned char *s, int max);
  764. unsigned long ASN1_tag2bit(int tag);
  765. /* SPECIALS */
  766. int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
  767. int *pclass, long omax);
  768. int ASN1_check_infinite_end(unsigned char **p, long len);
  769. int ASN1_const_check_infinite_end(const unsigned char **p, long len);
  770. void ASN1_put_object(unsigned char **pp, int constructed, int length,
  771. int tag, int xclass);
  772. int ASN1_put_eoc(unsigned char **pp);
  773. int ASN1_object_size(int constructed, int length, int tag);
  774. /* Used to implement other functions */
  775. void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x);
  776. # define ASN1_dup_of(type,i2d,d2i,x) \
  777. ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
  778. CHECKED_D2I_OF(type, d2i), \
  779. CHECKED_PTR_OF(const type, x)))
  780. void *ASN1_item_dup(const ASN1_ITEM *it, const void *x);
  781. int ASN1_item_sign_ex(const ASN1_ITEM *it, X509_ALGOR *algor1,
  782. X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
  783. const void *data, const ASN1_OCTET_STRING *id,
  784. EVP_PKEY *pkey, const EVP_MD *md, OSSL_LIB_CTX *libctx,
  785. const char *propq);
  786. int ASN1_item_verify_ex(const ASN1_ITEM *it, const X509_ALGOR *alg,
  787. const ASN1_BIT_STRING *signature, const void *data,
  788. const ASN1_OCTET_STRING *id, EVP_PKEY *pkey,
  789. OSSL_LIB_CTX *libctx, const char *propq);
  790. /* ASN1 alloc/free macros for when a type is only used internally */
  791. # define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))
  792. # define M_ASN1_free_of(x, type) \
  793. ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))
  794. # ifndef OPENSSL_NO_STDIO
  795. void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);
  796. # define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
  797. ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \
  798. CHECKED_D2I_OF(type, d2i), \
  799. in, \
  800. CHECKED_PPTR_OF(type, x)))
  801. void *ASN1_item_d2i_fp_ex(const ASN1_ITEM *it, FILE *in, void *x,
  802. OSSL_LIB_CTX *libctx, const char *propq);
  803. void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
  804. int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x);
  805. # define ASN1_i2d_fp_of(type,i2d,out,x) \
  806. (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \
  807. out, \
  808. CHECKED_PTR_OF(const type, x)))
  809. int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x);
  810. int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);
  811. # endif
  812. int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);
  813. void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);
  814. # define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
  815. ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \
  816. CHECKED_D2I_OF(type, d2i), \
  817. in, \
  818. CHECKED_PPTR_OF(type, x)))
  819. void *ASN1_item_d2i_bio_ex(const ASN1_ITEM *it, BIO *in, void *pval,
  820. OSSL_LIB_CTX *libctx, const char *propq);
  821. void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *pval);
  822. int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x);
  823. # define ASN1_i2d_bio_of(type,i2d,out,x) \
  824. (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \
  825. out, \
  826. CHECKED_PTR_OF(const type, x)))
  827. int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x);
  828. BIO *ASN1_item_i2d_mem_bio(const ASN1_ITEM *it, const ASN1_VALUE *val);
  829. int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
  830. int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
  831. int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm);
  832. int ASN1_TIME_print_ex(BIO *bp, const ASN1_TIME *tm, unsigned long flags);
  833. int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
  834. int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);
  835. int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off);
  836. int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
  837. unsigned char *buf, int off);
  838. int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);
  839. int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,
  840. int dump);
  841. const char *ASN1_tag2str(int tag);
  842. /* Used to load and write Netscape format cert */
  843. int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
  844. int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);
  845. int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len);
  846. int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
  847. unsigned char *data, int len);
  848. int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num,
  849. unsigned char *data, int max_len);
  850. void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it);
  851. ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,
  852. ASN1_OCTET_STRING **oct);
  853. void ASN1_STRING_set_default_mask(unsigned long mask);
  854. int ASN1_STRING_set_default_mask_asc(const char *p);
  855. unsigned long ASN1_STRING_get_default_mask(void);
  856. int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
  857. int inform, unsigned long mask);
  858. int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
  859. int inform, unsigned long mask,
  860. long minsize, long maxsize);
  861. ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
  862. const unsigned char *in, int inlen,
  863. int inform, int nid);
  864. ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
  865. int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
  866. void ASN1_STRING_TABLE_cleanup(void);
  867. /* ASN1 template functions */
  868. /* Old API compatible functions */
  869. ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
  870. ASN1_VALUE *ASN1_item_new_ex(const ASN1_ITEM *it, OSSL_LIB_CTX *libctx,
  871. const char *propq);
  872. void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
  873. ASN1_VALUE *ASN1_item_d2i_ex(ASN1_VALUE **val, const unsigned char **in,
  874. long len, const ASN1_ITEM *it,
  875. OSSL_LIB_CTX *libctx, const char *propq);
  876. ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,
  877. long len, const ASN1_ITEM *it);
  878. int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
  879. int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out,
  880. const ASN1_ITEM *it);
  881. void ASN1_add_oid_module(void);
  882. void ASN1_add_stable_module(void);
  883. ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf);
  884. ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf);
  885. int ASN1_str2mask(const char *str, unsigned long *pmask);
  886. /* ASN1 Print flags */
  887. /* Indicate missing OPTIONAL fields */
  888. # define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001
  889. /* Mark start and end of SEQUENCE */
  890. # define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002
  891. /* Mark start and end of SEQUENCE/SET OF */
  892. # define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004
  893. /* Show the ASN1 type of primitives */
  894. # define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008
  895. /* Don't show ASN1 type of ANY */
  896. # define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010
  897. /* Don't show ASN1 type of MSTRINGs */
  898. # define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020
  899. /* Don't show field names in SEQUENCE */
  900. # define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040
  901. /* Show structure names of each SEQUENCE field */
  902. # define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080
  903. /* Don't show structure name even at top level */
  904. # define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100
  905. int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent,
  906. const ASN1_ITEM *it, const ASN1_PCTX *pctx);
  907. ASN1_PCTX *ASN1_PCTX_new(void);
  908. void ASN1_PCTX_free(ASN1_PCTX *p);
  909. unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p);
  910. void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
  911. unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p);
  912. void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
  913. unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p);
  914. void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
  915. unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p);
  916. void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
  917. unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p);
  918. void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
  919. ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx));
  920. void ASN1_SCTX_free(ASN1_SCTX *p);
  921. const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p);
  922. const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p);
  923. unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p);
  924. void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data);
  925. void *ASN1_SCTX_get_app_data(ASN1_SCTX *p);
  926. const BIO_METHOD *BIO_f_asn1(void);
  927. /* cannot constify val because of CMS_stream() */
  928. BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
  929. int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
  930. const ASN1_ITEM *it);
  931. int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
  932. const char *hdr, const ASN1_ITEM *it);
  933. /* cannot constify val because of CMS_dataFinal() */
  934. int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
  935. int ctype_nid, int econt_nid,
  936. STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);
  937. int SMIME_write_ASN1_ex(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
  938. int ctype_nid, int econt_nid,
  939. STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it,
  940. OSSL_LIB_CTX *libctx, const char *propq);
  941. ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
  942. ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, int flags, BIO **bcont,
  943. const ASN1_ITEM *it, ASN1_VALUE **x,
  944. OSSL_LIB_CTX *libctx, const char *propq);
  945. int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
  946. int SMIME_text(BIO *in, BIO *out);
  947. const ASN1_ITEM *ASN1_ITEM_lookup(const char *name);
  948. const ASN1_ITEM *ASN1_ITEM_get(size_t i);
  949. /* Legacy compatibility */
  950. # define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
  951. DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
  952. DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
  953. # define DECLARE_ASN1_FUNCTIONS_const(type) DECLARE_ASN1_FUNCTIONS(type)
  954. # define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
  955. DECLARE_ASN1_ENCODE_FUNCTIONS(type, name)
  956. # define I2D_OF_const(type) I2D_OF(type)
  957. # define ASN1_dup_of_const(type,i2d,d2i,x) ASN1_dup_of(type,i2d,d2i,x)
  958. # define ASN1_i2d_fp_of_const(type,i2d,out,x) ASN1_i2d_fp_of(type,i2d,out,x)
  959. # define ASN1_i2d_bio_of_const(type,i2d,out,x) ASN1_i2d_bio_of(type,i2d,out,x)
  960. # ifdef __cplusplus
  961. }
  962. # endif
  963. #endif