You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

asn1t.h 40 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927
  1. /*
  2. * WARNING: do not edit!
  3. * Generated by makefile from include\openssl\asn1t.h.in
  4. *
  5. * Copyright 2000-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_ASN1T_H
  13. #define OPENSSL_ASN1T_H
  14. #pragma once
  15. #include <openssl/macros.h>
  16. #ifndef OPENSSL_NO_DEPRECATED_3_0
  17. #define HEADER_ASN1T_H
  18. #endif
  19. #include <stddef.h>
  20. #include <openssl/e_os2.h>
  21. #include <openssl/asn1.h>
  22. #ifdef OPENSSL_BUILD_SHLIBCRYPTO
  23. #undef OPENSSL_EXTERN
  24. #define OPENSSL_EXTERN OPENSSL_EXPORT
  25. #endif
  26. /* ASN1 template defines, structures and functions */
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif
  31. /*-
  32. * These are the possible values for the itype field of the
  33. * ASN1_ITEM structure and determine how it is interpreted.
  34. *
  35. * For PRIMITIVE types the underlying type
  36. * determines the behaviour if items is NULL.
  37. *
  38. * Otherwise templates must contain a single
  39. * template and the type is treated in the
  40. * same way as the type specified in the template.
  41. *
  42. * For SEQUENCE types the templates field points
  43. * to the members, the size field is the
  44. * structure size.
  45. *
  46. * For CHOICE types the templates field points
  47. * to each possible member (typically a union)
  48. * and the 'size' field is the offset of the
  49. * selector.
  50. *
  51. * The 'funcs' field is used for application-specific
  52. * data and functions.
  53. *
  54. * The EXTERN type uses a new style d2i/i2d.
  55. * The new style should be used where possible
  56. * because it avoids things like the d2i IMPLICIT
  57. * hack.
  58. *
  59. * MSTRING is a multiple string type, it is used
  60. * for a CHOICE of character strings where the
  61. * actual strings all occupy an ASN1_STRING
  62. * structure. In this case the 'utype' field
  63. * has a special meaning, it is used as a mask
  64. * of acceptable types using the B_ASN1 constants.
  65. *
  66. * NDEF_SEQUENCE is the same as SEQUENCE except
  67. * that it will use indefinite length constructed
  68. * encoding if requested.
  69. *
  70. */
  71. #define ASN1_ITYPE_PRIMITIVE 0x0
  72. #define ASN1_ITYPE_SEQUENCE 0x1
  73. #define ASN1_ITYPE_CHOICE 0x2
  74. /* unused value 0x3 */
  75. #define ASN1_ITYPE_EXTERN 0x4
  76. #define ASN1_ITYPE_MSTRING 0x5
  77. #define ASN1_ITYPE_NDEF_SEQUENCE 0x6
  78. /* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
  79. #define ASN1_ADB_ptr(iptr) ((const ASN1_ADB*)((iptr)()))
  80. /* Macros for start and end of ASN1_ITEM definition */
  81. #define ASN1_ITEM_start(itname) \
  82. const ASN1_ITEM* itname##_it(void) \
  83. { \
  84. static const ASN1_ITEM local_it = {
  85. #define static_ASN1_ITEM_start(itname) \
  86. static ASN1_ITEM_start(itname)
  87. #define ASN1_ITEM_end(itname) \
  88. } \
  89. ; \
  90. return &local_it; \
  91. }
  92. /* Macros to aid ASN1 template writing */
  93. #define ASN1_ITEM_TEMPLATE(tname) \
  94. static const ASN1_TEMPLATE tname##_item_tt
  95. #define ASN1_ITEM_TEMPLATE_END(tname) \
  96. ; \
  97. ASN1_ITEM_start(tname) \
  98. ASN1_ITYPE_PRIMITIVE, \
  99. -1, \
  100. &tname##_item_tt, \
  101. 0, \
  102. NULL, \
  103. 0, \
  104. #tname ASN1_ITEM_end(tname)
  105. #define static_ASN1_ITEM_TEMPLATE_END(tname) \
  106. ; \
  107. static_ASN1_ITEM_start(tname) \
  108. ASN1_ITYPE_PRIMITIVE, \
  109. -1, \
  110. &tname##_item_tt, \
  111. 0, \
  112. NULL, \
  113. 0, \
  114. #tname ASN1_ITEM_end(tname)
  115. /* This is a ASN1 type which just embeds a template */
  116. /*-
  117. * This pair helps declare a SEQUENCE. We can do:
  118. *
  119. * ASN1_SEQUENCE(stname) = {
  120. * ... SEQUENCE components ...
  121. * } ASN1_SEQUENCE_END(stname)
  122. *
  123. * This will produce an ASN1_ITEM called stname_it
  124. * for a structure called stname.
  125. *
  126. * If you want the same structure but a different
  127. * name then use:
  128. *
  129. * ASN1_SEQUENCE(itname) = {
  130. * ... SEQUENCE components ...
  131. * } ASN1_SEQUENCE_END_name(stname, itname)
  132. *
  133. * This will create an item called itname_it using
  134. * a structure called stname.
  135. */
  136. #define ASN1_SEQUENCE(tname) \
  137. static const ASN1_TEMPLATE tname##_seq_tt[]
  138. #define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
  139. #define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)
  140. #define ASN1_SEQUENCE_END_name(stname, tname) \
  141. ; \
  142. ASN1_ITEM_start(tname) \
  143. ASN1_ITYPE_SEQUENCE, \
  144. V_ASN1_SEQUENCE, \
  145. tname##_seq_tt, \
  146. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  147. NULL, \
  148. sizeof(stname), \
  149. #tname ASN1_ITEM_end(tname)
  150. #define static_ASN1_SEQUENCE_END_name(stname, tname) \
  151. ; \
  152. static_ASN1_ITEM_start(tname) \
  153. ASN1_ITYPE_SEQUENCE, \
  154. V_ASN1_SEQUENCE, \
  155. tname##_seq_tt, \
  156. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  157. NULL, \
  158. sizeof(stname), \
  159. #stname ASN1_ITEM_end(tname)
  160. #define ASN1_NDEF_SEQUENCE(tname) \
  161. ASN1_SEQUENCE(tname)
  162. #define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
  163. ASN1_SEQUENCE_cb(tname, cb)
  164. #define ASN1_SEQUENCE_cb(tname, cb) \
  165. static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \
  166. ASN1_SEQUENCE(tname)
  167. #define ASN1_SEQUENCE_const_cb(tname, const_cb) \
  168. static const ASN1_AUX tname##_aux = \
  169. {NULL, ASN1_AFLG_CONST_CB, 0, 0, NULL, 0, const_cb}; \
  170. ASN1_SEQUENCE(tname)
  171. #define ASN1_SEQUENCE_cb_const_cb(tname, cb, const_cb) \
  172. static const ASN1_AUX tname##_aux = \
  173. {NULL, ASN1_AFLG_CONST_CB, 0, 0, cb, 0, const_cb}; \
  174. ASN1_SEQUENCE(tname)
  175. #define ASN1_SEQUENCE_ref(tname, cb) \
  176. static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0, NULL}; \
  177. ASN1_SEQUENCE(tname)
  178. #define ASN1_SEQUENCE_enc(tname, enc, cb) \
  179. static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc), NULL}; \
  180. ASN1_SEQUENCE(tname)
  181. #define ASN1_NDEF_SEQUENCE_END(tname) \
  182. ; \
  183. ASN1_ITEM_start(tname) \
  184. ASN1_ITYPE_NDEF_SEQUENCE, \
  185. V_ASN1_SEQUENCE, \
  186. tname##_seq_tt, \
  187. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  188. NULL, \
  189. sizeof(tname), \
  190. #tname ASN1_ITEM_end(tname)
  191. #define static_ASN1_NDEF_SEQUENCE_END(tname) \
  192. ; \
  193. static_ASN1_ITEM_start(tname) \
  194. ASN1_ITYPE_NDEF_SEQUENCE, \
  195. V_ASN1_SEQUENCE, \
  196. tname##_seq_tt, \
  197. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  198. NULL, \
  199. sizeof(tname), \
  200. #tname ASN1_ITEM_end(tname)
  201. #define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
  202. #define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
  203. #define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
  204. #define ASN1_SEQUENCE_END_ref(stname, tname) \
  205. ; \
  206. ASN1_ITEM_start(tname) \
  207. ASN1_ITYPE_SEQUENCE, \
  208. V_ASN1_SEQUENCE, \
  209. tname##_seq_tt, \
  210. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  211. &tname##_aux, \
  212. sizeof(stname), \
  213. #tname ASN1_ITEM_end(tname)
  214. #define static_ASN1_SEQUENCE_END_ref(stname, tname) \
  215. ; \
  216. static_ASN1_ITEM_start(tname) \
  217. ASN1_ITYPE_SEQUENCE, \
  218. V_ASN1_SEQUENCE, \
  219. tname##_seq_tt, \
  220. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  221. &tname##_aux, \
  222. sizeof(stname), \
  223. #stname ASN1_ITEM_end(tname)
  224. #define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
  225. ; \
  226. ASN1_ITEM_start(tname) \
  227. ASN1_ITYPE_NDEF_SEQUENCE, \
  228. V_ASN1_SEQUENCE, \
  229. tname##_seq_tt, \
  230. sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE), \
  231. &tname##_aux, \
  232. sizeof(stname), \
  233. #stname ASN1_ITEM_end(tname)
  234. /*-
  235. * This pair helps declare a CHOICE type. We can do:
  236. *
  237. * ASN1_CHOICE(chname) = {
  238. * ... CHOICE options ...
  239. * ASN1_CHOICE_END(chname)
  240. *
  241. * This will produce an ASN1_ITEM called chname_it
  242. * for a structure called chname. The structure
  243. * definition must look like this:
  244. * typedef struct {
  245. * int type;
  246. * union {
  247. * ASN1_SOMETHING *opt1;
  248. * ASN1_SOMEOTHER *opt2;
  249. * } value;
  250. * } chname;
  251. *
  252. * the name of the selector must be 'type'.
  253. * to use an alternative selector name use the
  254. * ASN1_CHOICE_END_selector() version.
  255. */
  256. #define ASN1_CHOICE(tname) \
  257. static const ASN1_TEMPLATE tname##_ch_tt[]
  258. #define ASN1_CHOICE_cb(tname, cb) \
  259. static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \
  260. ASN1_CHOICE(tname)
  261. #define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
  262. #define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)
  263. #define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
  264. #define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)
  265. #define ASN1_CHOICE_END_selector(stname, tname, selname) \
  266. ; \
  267. ASN1_ITEM_start(tname) \
  268. ASN1_ITYPE_CHOICE, \
  269. offsetof(stname, selname), \
  270. tname##_ch_tt, \
  271. sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), \
  272. NULL, \
  273. sizeof(stname), \
  274. #stname ASN1_ITEM_end(tname)
  275. #define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
  276. ; \
  277. static_ASN1_ITEM_start(tname) \
  278. ASN1_ITYPE_CHOICE, \
  279. offsetof(stname, selname), \
  280. tname##_ch_tt, \
  281. sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), \
  282. NULL, \
  283. sizeof(stname), \
  284. #stname ASN1_ITEM_end(tname)
  285. #define ASN1_CHOICE_END_cb(stname, tname, selname) \
  286. ; \
  287. ASN1_ITEM_start(tname) \
  288. ASN1_ITYPE_CHOICE, \
  289. offsetof(stname, selname), \
  290. tname##_ch_tt, \
  291. sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE), \
  292. &tname##_aux, \
  293. sizeof(stname), \
  294. #stname ASN1_ITEM_end(tname)
  295. /* This helps with the template wrapper form of ASN1_ITEM */
  296. #define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) \
  297. { \
  298. (flags), (tag), 0, \
  299. #name, ASN1_ITEM_ref(type) \
  300. }
  301. /* These help with SEQUENCE or CHOICE components */
  302. /* used to declare other types */
  303. #define ASN1_EX_TYPE(flags, tag, stname, field, type) \
  304. { \
  305. (flags), (tag), offsetof(stname, field), \
  306. #field, ASN1_ITEM_ref(type) \
  307. }
  308. /* implicit and explicit helper macros */
  309. #define ASN1_IMP_EX(stname, field, type, tag, ex) \
  310. ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)
  311. #define ASN1_EXP_EX(stname, field, type, tag, ex) \
  312. ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)
  313. /* Any defined by macros: the field used is in the table itself */
  314. #define ASN1_ADB_OBJECT(tblname) \
  315. { \
  316. ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb \
  317. }
  318. #define ASN1_ADB_INTEGER(tblname) \
  319. { \
  320. ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb \
  321. }
  322. /* Plain simple type */
  323. #define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0, 0, stname, field, type)
  324. /* Embedded simple type */
  325. #define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED, 0, stname, field, type)
  326. /* OPTIONAL simple type */
  327. #define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
  328. #define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED, 0, stname, field, type)
  329. /* IMPLICIT tagged simple type */
  330. #define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
  331. #define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
  332. /* IMPLICIT tagged OPTIONAL simple type */
  333. #define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
  334. #define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED)
  335. /* Same as above but EXPLICIT */
  336. #define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
  337. #define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
  338. #define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
  339. #define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_EMBED)
  340. /* SEQUENCE OF type */
  341. #define ASN1_SEQUENCE_OF(stname, field, type) \
  342. ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
  343. /* OPTIONAL SEQUENCE OF */
  344. #define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
  345. ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, 0, stname, field, type)
  346. /* Same as above but for SET OF */
  347. #define ASN1_SET_OF(stname, field, type) \
  348. ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
  349. #define ASN1_SET_OF_OPT(stname, field, type) \
  350. ASN1_EX_TYPE(ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL, 0, stname, field, type)
  351. /* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
  352. #define ASN1_IMP_SET_OF(stname, field, type, tag) \
  353. ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
  354. #define ASN1_EXP_SET_OF(stname, field, type, tag) \
  355. ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
  356. #define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
  357. ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL)
  358. #define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
  359. ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF | ASN1_TFLG_OPTIONAL)
  360. #define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
  361. ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
  362. #define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
  363. ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL)
  364. #define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
  365. ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
  366. #define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
  367. ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL)
  368. /* EXPLICIT using indefinite length constructed form */
  369. #define ASN1_NDEF_EXP(stname, field, type, tag) \
  370. ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
  371. /* EXPLICIT OPTIONAL using indefinite length constructed form */
  372. #define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
  373. ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL | ASN1_TFLG_NDEF)
  374. /* Macros for the ASN1_ADB structure */
  375. #define ASN1_ADB(name) \
  376. static const ASN1_ADB_TABLE name##_adbtbl[]
  377. #define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
  378. ; \
  379. static const ASN1_ITEM* name##_adb(void) \
  380. { \
  381. static const ASN1_ADB internal_adb = \
  382. { \
  383. flags, \
  384. offsetof(name, field), \
  385. adb_cb, \
  386. name##_adbtbl, \
  387. sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE), \
  388. def, \
  389. none}; \
  390. return (const ASN1_ITEM*)&internal_adb; \
  391. } \
  392. void dummy_function(void)
  393. #define ADB_ENTRY(val, template) \
  394. { \
  395. val, template \
  396. }
  397. #define ASN1_ADB_TEMPLATE(name) \
  398. static const ASN1_TEMPLATE name##_tt
  399. /*
  400. * This is the ASN1 template structure that defines a wrapper round the
  401. * actual type. It determines the actual position of the field in the value
  402. * structure, various flags such as OPTIONAL and the field name.
  403. */
  404. struct ASN1_TEMPLATE_st
  405. {
  406. unsigned long flags; /* Various flags */
  407. long tag; /* tag, not used if no tagging */
  408. unsigned long offset; /* Offset of this field in structure */
  409. const char* field_name; /* Field name */
  410. ASN1_ITEM_EXP* item; /* Relevant ASN1_ITEM or ASN1_ADB */
  411. };
  412. /* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
  413. #define ASN1_TEMPLATE_item(t) (t->item_ptr)
  414. #define ASN1_TEMPLATE_adb(t) (t->item_ptr)
  415. typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
  416. typedef struct ASN1_ADB_st ASN1_ADB;
  417. struct ASN1_ADB_st
  418. {
  419. unsigned long flags; /* Various flags */
  420. unsigned long offset; /* Offset of selector field */
  421. int (*adb_cb)(long* psel); /* Application callback */
  422. const ASN1_ADB_TABLE* tbl; /* Table of possible types */
  423. long tblcount; /* Number of entries in tbl */
  424. const ASN1_TEMPLATE* default_tt; /* Type to use if no match */
  425. const ASN1_TEMPLATE* null_tt; /* Type to use if selector is NULL */
  426. };
  427. struct ASN1_ADB_TABLE_st
  428. {
  429. long value; /* NID for an object or value for an int */
  430. const ASN1_TEMPLATE tt; /* item for this value */
  431. };
  432. /* template flags */
  433. /* Field is optional */
  434. #define ASN1_TFLG_OPTIONAL (0x1)
  435. /* Field is a SET OF */
  436. #define ASN1_TFLG_SET_OF (0x1 << 1)
  437. /* Field is a SEQUENCE OF */
  438. #define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
  439. /*
  440. * Special case: this refers to a SET OF that will be sorted into DER order
  441. * when encoded *and* the corresponding STACK will be modified to match the
  442. * new order.
  443. */
  444. #define ASN1_TFLG_SET_ORDER (0x3 << 1)
  445. /* Mask for SET OF or SEQUENCE OF */
  446. #define ASN1_TFLG_SK_MASK (0x3 << 1)
  447. /*
  448. * These flags mean the tag should be taken from the tag field. If EXPLICIT
  449. * then the underlying type is used for the inner tag.
  450. */
  451. /* IMPLICIT tagging */
  452. #define ASN1_TFLG_IMPTAG (0x1 << 3)
  453. /* EXPLICIT tagging, inner tag from underlying type */
  454. #define ASN1_TFLG_EXPTAG (0x2 << 3)
  455. #define ASN1_TFLG_TAG_MASK (0x3 << 3)
  456. /* context specific IMPLICIT */
  457. #define ASN1_TFLG_IMPLICIT (ASN1_TFLG_IMPTAG | ASN1_TFLG_CONTEXT)
  458. /* context specific EXPLICIT */
  459. #define ASN1_TFLG_EXPLICIT (ASN1_TFLG_EXPTAG | ASN1_TFLG_CONTEXT)
  460. /*
  461. * If tagging is in force these determine the type of tag to use. Otherwise
  462. * the tag is determined by the underlying type. These values reflect the
  463. * actual octet format.
  464. */
  465. /* Universal tag */
  466. #define ASN1_TFLG_UNIVERSAL (0x0 << 6)
  467. /* Application tag */
  468. #define ASN1_TFLG_APPLICATION (0x1 << 6)
  469. /* Context specific tag */
  470. #define ASN1_TFLG_CONTEXT (0x2 << 6)
  471. /* Private tag */
  472. #define ASN1_TFLG_PRIVATE (0x3 << 6)
  473. #define ASN1_TFLG_TAG_CLASS (0x3 << 6)
  474. /*
  475. * These are for ANY DEFINED BY type. In this case the 'item' field points to
  476. * an ASN1_ADB structure which contains a table of values to decode the
  477. * relevant type
  478. */
  479. #define ASN1_TFLG_ADB_MASK (0x3 << 8)
  480. #define ASN1_TFLG_ADB_OID (0x1 << 8)
  481. #define ASN1_TFLG_ADB_INT (0x1 << 9)
  482. /*
  483. * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
  484. * indefinite length constructed encoding to be used if required.
  485. */
  486. #define ASN1_TFLG_NDEF (0x1 << 11)
  487. /* Field is embedded and not a pointer */
  488. #define ASN1_TFLG_EMBED (0x1 << 12)
  489. /* This is the actual ASN1 item itself */
  490. struct ASN1_ITEM_st
  491. {
  492. char itype; /* The item type, primitive, SEQUENCE, CHOICE
  493. * or extern */
  494. long utype; /* underlying type */
  495. const ASN1_TEMPLATE* templates; /* If SEQUENCE or CHOICE this contains
  496. * the contents */
  497. long tcount; /* Number of templates if SEQUENCE or CHOICE */
  498. const void* funcs; /* further data and type-specific functions */
  499. /* funcs can be ASN1_PRIMITIVE_FUNCS*, ASN1_EXTERN_FUNCS*, or ASN1_AUX* */
  500. long size; /* Structure size (usually) */
  501. const char* sname; /* Structure name */
  502. };
  503. /*
  504. * Cache for ASN1 tag and length, so we don't keep re-reading it for things
  505. * like CHOICE
  506. */
  507. struct ASN1_TLC_st
  508. {
  509. char valid; /* Values below are valid */
  510. int ret; /* return value */
  511. long plen; /* length */
  512. int ptag; /* class value */
  513. int pclass; /* class value */
  514. int hdrlen; /* header length */
  515. };
  516. /* Typedefs for ASN1 function pointers */
  517. typedef int ASN1_ex_d2i(ASN1_VALUE** pval, const unsigned char** in, long len, const ASN1_ITEM* it, int tag, int aclass, char opt, ASN1_TLC* ctx);
  518. typedef int ASN1_ex_d2i_ex(ASN1_VALUE** pval, const unsigned char** in, long len, const ASN1_ITEM* it, int tag, int aclass, char opt, ASN1_TLC* ctx, OSSL_LIB_CTX* libctx, const char* propq);
  519. typedef int ASN1_ex_i2d(const ASN1_VALUE** pval, unsigned char** out, const ASN1_ITEM* it, int tag, int aclass);
  520. typedef int ASN1_ex_new_func(ASN1_VALUE** pval, const ASN1_ITEM* it);
  521. typedef int ASN1_ex_new_ex_func(ASN1_VALUE** pval, const ASN1_ITEM* it, OSSL_LIB_CTX* libctx, const char* propq);
  522. typedef void ASN1_ex_free_func(ASN1_VALUE** pval, const ASN1_ITEM* it);
  523. typedef int ASN1_ex_print_func(BIO* out, const ASN1_VALUE** pval, int indent, const char* fname, const ASN1_PCTX* pctx);
  524. typedef int ASN1_primitive_i2c(const ASN1_VALUE** pval, unsigned char* cont, int* putype, const ASN1_ITEM* it);
  525. typedef int ASN1_primitive_c2i(ASN1_VALUE** pval, const unsigned char* cont, int len, int utype, char* free_cont, const ASN1_ITEM* it);
  526. typedef int ASN1_primitive_print(BIO* out, const ASN1_VALUE** pval, const ASN1_ITEM* it, int indent, const ASN1_PCTX* pctx);
  527. typedef struct ASN1_EXTERN_FUNCS_st
  528. {
  529. void* app_data;
  530. ASN1_ex_new_func* asn1_ex_new;
  531. ASN1_ex_free_func* asn1_ex_free;
  532. ASN1_ex_free_func* asn1_ex_clear;
  533. ASN1_ex_d2i* asn1_ex_d2i;
  534. ASN1_ex_i2d* asn1_ex_i2d;
  535. ASN1_ex_print_func* asn1_ex_print;
  536. ASN1_ex_new_ex_func* asn1_ex_new_ex;
  537. ASN1_ex_d2i_ex* asn1_ex_d2i_ex;
  538. } ASN1_EXTERN_FUNCS;
  539. typedef struct ASN1_PRIMITIVE_FUNCS_st
  540. {
  541. void* app_data;
  542. unsigned long flags;
  543. ASN1_ex_new_func* prim_new;
  544. ASN1_ex_free_func* prim_free;
  545. ASN1_ex_free_func* prim_clear;
  546. ASN1_primitive_c2i* prim_c2i;
  547. ASN1_primitive_i2c* prim_i2c;
  548. ASN1_primitive_print* prim_print;
  549. } ASN1_PRIMITIVE_FUNCS;
  550. /*
  551. * This is the ASN1_AUX structure: it handles various miscellaneous
  552. * requirements. For example the use of reference counts and an informational
  553. * callback. The "informational callback" is called at various points during
  554. * the ASN1 encoding and decoding. It can be used to provide minor
  555. * customisation of the structures used. This is most useful where the
  556. * supplied routines *almost* do the right thing but need some extra help at
  557. * a few points. If the callback returns zero then it is assumed a fatal
  558. * error has occurred and the main operation should be abandoned. If major
  559. * changes in the default behaviour are required then an external type is
  560. * more appropriate.
  561. * For the operations ASN1_OP_I2D_PRE, ASN1_OP_I2D_POST, ASN1_OP_PRINT_PRE, and
  562. * ASN1_OP_PRINT_POST, meanwhile a variant of the callback with const parameter
  563. * 'in' is provided to make clear statically that its input is not modified. If
  564. * and only if this variant is in use the flag ASN1_AFLG_CONST_CB must be set.
  565. */
  566. typedef int ASN1_aux_cb(int operation, ASN1_VALUE** in, const ASN1_ITEM* it, void* exarg);
  567. typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE** in, const ASN1_ITEM* it, void* exarg);
  568. typedef struct ASN1_AUX_st
  569. {
  570. void* app_data;
  571. int flags;
  572. int ref_offset; /* Offset of reference value */
  573. int ref_lock; /* Offset of lock value */
  574. ASN1_aux_cb* asn1_cb;
  575. int enc_offset; /* Offset of ASN1_ENCODING structure */
  576. ASN1_aux_const_cb* asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */
  577. } ASN1_AUX;
  578. /* For print related callbacks exarg points to this structure */
  579. typedef struct ASN1_PRINT_ARG_st
  580. {
  581. BIO* out;
  582. int indent;
  583. const ASN1_PCTX* pctx;
  584. } ASN1_PRINT_ARG;
  585. /* For streaming related callbacks exarg points to this structure */
  586. typedef struct ASN1_STREAM_ARG_st
  587. {
  588. /* BIO to stream through */
  589. BIO* out;
  590. /* BIO with filters appended */
  591. BIO* ndef_bio;
  592. /* Streaming I/O boundary */
  593. unsigned char** boundary;
  594. } ASN1_STREAM_ARG;
  595. /* Flags in ASN1_AUX */
  596. /* Use a reference count */
  597. #define ASN1_AFLG_REFCOUNT 1
  598. /* Save the encoding of structure (useful for signatures) */
  599. #define ASN1_AFLG_ENCODING 2
  600. /* The Sequence length is invalid */
  601. #define ASN1_AFLG_BROKEN 4
  602. /* Use the new asn1_const_cb */
  603. #define ASN1_AFLG_CONST_CB 8
  604. /* operation values for asn1_cb */
  605. #define ASN1_OP_NEW_PRE 0
  606. #define ASN1_OP_NEW_POST 1
  607. #define ASN1_OP_FREE_PRE 2
  608. #define ASN1_OP_FREE_POST 3
  609. #define ASN1_OP_D2I_PRE 4
  610. #define ASN1_OP_D2I_POST 5
  611. #define ASN1_OP_I2D_PRE 6
  612. #define ASN1_OP_I2D_POST 7
  613. #define ASN1_OP_PRINT_PRE 8
  614. #define ASN1_OP_PRINT_POST 9
  615. #define ASN1_OP_STREAM_PRE 10
  616. #define ASN1_OP_STREAM_POST 11
  617. #define ASN1_OP_DETACHED_PRE 12
  618. #define ASN1_OP_DETACHED_POST 13
  619. #define ASN1_OP_DUP_PRE 14
  620. #define ASN1_OP_DUP_POST 15
  621. #define ASN1_OP_GET0_LIBCTX 16
  622. #define ASN1_OP_GET0_PROPQ 17
  623. /* Macro to implement a primitive type */
  624. #define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
  625. #define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
  626. ASN1_ITEM_start(itname) \
  627. ASN1_ITYPE_PRIMITIVE, \
  628. V_##vname, NULL, 0, NULL, ex, #itname ASN1_ITEM_end(itname)
  629. /* Macro to implement a multi string type */
  630. #define IMPLEMENT_ASN1_MSTRING(itname, mask) \
  631. ASN1_ITEM_start(itname) \
  632. ASN1_ITYPE_MSTRING, \
  633. mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname ASN1_ITEM_end(itname)
  634. #define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
  635. ASN1_ITEM_start(sname) \
  636. ASN1_ITYPE_EXTERN, \
  637. tag, \
  638. NULL, \
  639. 0, \
  640. &fptrs, \
  641. 0, \
  642. #sname ASN1_ITEM_end(sname)
  643. /* Macro to implement standard functions in terms of ASN1_ITEM structures */
  644. #define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
  645. #define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
  646. #define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
  647. IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
  648. #define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
  649. IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
  650. #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
  651. IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
  652. #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
  653. pre stname* fname##_new(void) \
  654. { \
  655. return (stname*)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
  656. } \
  657. pre void fname##_free(stname* a) \
  658. { \
  659. ASN1_item_free((ASN1_VALUE*)a, ASN1_ITEM_rptr(itname)); \
  660. }
  661. #define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
  662. stname* fname##_new(void) \
  663. { \
  664. return (stname*)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
  665. } \
  666. void fname##_free(stname* a) \
  667. { \
  668. ASN1_item_free((ASN1_VALUE*)a, ASN1_ITEM_rptr(itname)); \
  669. }
  670. #define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
  671. IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
  672. IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
  673. #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
  674. stname* d2i_##fname(stname** a, const unsigned char** in, long len) \
  675. { \
  676. return (stname*)ASN1_item_d2i((ASN1_VALUE**)a, in, len, ASN1_ITEM_rptr(itname)); \
  677. } \
  678. int i2d_##fname(const stname* a, unsigned char** out) \
  679. { \
  680. return ASN1_item_i2d((const ASN1_VALUE*)a, out, ASN1_ITEM_rptr(itname)); \
  681. }
  682. #define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
  683. int i2d_##stname##_NDEF(const stname* a, unsigned char** out) \
  684. { \
  685. return ASN1_item_ndef_i2d((const ASN1_VALUE*)a, out, ASN1_ITEM_rptr(stname)); \
  686. }
  687. #define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
  688. static stname* d2i_##stname(stname** a, const unsigned char** in, long len) \
  689. { \
  690. return (stname*)ASN1_item_d2i((ASN1_VALUE**)a, in, len, ASN1_ITEM_rptr(stname)); \
  691. } \
  692. static int i2d_##stname(const stname* a, unsigned char** out) \
  693. { \
  694. return ASN1_item_i2d((const ASN1_VALUE*)a, out, ASN1_ITEM_rptr(stname)); \
  695. }
  696. #define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
  697. stname* stname##_dup(const stname* x) \
  698. { \
  699. return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
  700. }
  701. #define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
  702. IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
  703. #define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
  704. int fname##_print_ctx(BIO* out, const stname* x, int indent, const ASN1_PCTX* pctx) \
  705. { \
  706. return ASN1_item_print(out, (const ASN1_VALUE*)x, indent, ASN1_ITEM_rptr(itname), pctx); \
  707. }
  708. /* external definitions for primitive types */
  709. DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
  710. DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
  711. DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
  712. DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
  713. DECLARE_ASN1_ITEM(CBIGNUM)
  714. DECLARE_ASN1_ITEM(BIGNUM)
  715. DECLARE_ASN1_ITEM(INT32)
  716. DECLARE_ASN1_ITEM(ZINT32)
  717. DECLARE_ASN1_ITEM(UINT32)
  718. DECLARE_ASN1_ITEM(ZUINT32)
  719. DECLARE_ASN1_ITEM(INT64)
  720. DECLARE_ASN1_ITEM(ZINT64)
  721. DECLARE_ASN1_ITEM(UINT64)
  722. DECLARE_ASN1_ITEM(ZUINT64)
  723. #ifndef OPENSSL_NO_DEPRECATED_3_0
  724. /*
  725. * LONG and ZLONG are strongly discouraged for use as stored data, as the
  726. * underlying C type (long) differs in size depending on the architecture.
  727. * They are designed with 32-bit longs in mind.
  728. */
  729. DECLARE_ASN1_ITEM(LONG)
  730. DECLARE_ASN1_ITEM(ZLONG)
  731. #endif
  732. SKM_DEFINE_STACK_OF_INTERNAL(ASN1_VALUE, ASN1_VALUE, ASN1_VALUE)
  733. #define sk_ASN1_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_VALUE_sk_type(sk))
  734. #define sk_ASN1_VALUE_value(sk, idx) ((ASN1_VALUE*)OPENSSL_sk_value(ossl_check_const_ASN1_VALUE_sk_type(sk), (idx)))
  735. #define sk_ASN1_VALUE_new(cmp) ((STACK_OF(ASN1_VALUE)*)OPENSSL_sk_new(ossl_check_ASN1_VALUE_compfunc_type(cmp)))
  736. #define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE)*)OPENSSL_sk_new_null())
  737. #define sk_ASN1_VALUE_new_reserve(cmp, n) ((STACK_OF(ASN1_VALUE)*)OPENSSL_sk_new_reserve(ossl_check_ASN1_VALUE_compfunc_type(cmp), (n)))
  738. #define sk_ASN1_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_VALUE_sk_type(sk), (n))
  739. #define sk_ASN1_VALUE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_VALUE_sk_type(sk))
  740. #define sk_ASN1_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_VALUE_sk_type(sk))
  741. #define sk_ASN1_VALUE_delete(sk, i) ((ASN1_VALUE*)OPENSSL_sk_delete(ossl_check_ASN1_VALUE_sk_type(sk), (i)))
  742. #define sk_ASN1_VALUE_delete_ptr(sk, ptr) ((ASN1_VALUE*)OPENSSL_sk_delete_ptr(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)))
  743. #define sk_ASN1_VALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
  744. #define sk_ASN1_VALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
  745. #define sk_ASN1_VALUE_pop(sk) ((ASN1_VALUE*)OPENSSL_sk_pop(ossl_check_ASN1_VALUE_sk_type(sk)))
  746. #define sk_ASN1_VALUE_shift(sk) ((ASN1_VALUE*)OPENSSL_sk_shift(ossl_check_ASN1_VALUE_sk_type(sk)))
  747. #define sk_ASN1_VALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_freefunc_type(freefunc))
  748. #define sk_ASN1_VALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), (idx))
  749. #define sk_ASN1_VALUE_set(sk, idx, ptr) ((ASN1_VALUE*)OPENSSL_sk_set(ossl_check_ASN1_VALUE_sk_type(sk), (idx), ossl_check_ASN1_VALUE_type(ptr)))
  750. #define sk_ASN1_VALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
  751. #define sk_ASN1_VALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
  752. #define sk_ASN1_VALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), pnum)
  753. #define sk_ASN1_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_VALUE_sk_type(sk))
  754. #define sk_ASN1_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_VALUE_sk_type(sk))
  755. #define sk_ASN1_VALUE_dup(sk) ((STACK_OF(ASN1_VALUE)*)OPENSSL_sk_dup(ossl_check_const_ASN1_VALUE_sk_type(sk)))
  756. #define sk_ASN1_VALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_VALUE)*)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_copyfunc_type(copyfunc), ossl_check_ASN1_VALUE_freefunc_type(freefunc)))
  757. #define sk_ASN1_VALUE_set_cmp_func(sk, cmp) ((sk_ASN1_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_compfunc_type(cmp)))
  758. /* Functions used internally by the ASN1 code */
  759. int ASN1_item_ex_new(ASN1_VALUE** pval, const ASN1_ITEM* it);
  760. void ASN1_item_ex_free(ASN1_VALUE** pval, const ASN1_ITEM* it);
  761. int ASN1_item_ex_d2i(ASN1_VALUE** pval, const unsigned char** in, long len, const ASN1_ITEM* it, int tag, int aclass, char opt, ASN1_TLC* ctx);
  762. int ASN1_item_ex_i2d(const ASN1_VALUE** pval, unsigned char** out, const ASN1_ITEM* it, int tag, int aclass);
  763. /* Legacy compatibility */
  764. #define IMPLEMENT_ASN1_FUNCTIONS_const(name) IMPLEMENT_ASN1_FUNCTIONS(name)
  765. #define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
  766. IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname)
  767. #ifdef __cplusplus
  768. }
  769. #endif
  770. #endif