asn1t.h 35 KB

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