asn1.h 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. /*
  2. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef HEADER_ASN1_H
  10. # define HEADER_ASN1_H
  11. # include <time.h>
  12. # include <openssl/e_os2.h>
  13. # include <openssl/opensslconf.h>
  14. # include <openssl/bio.h>
  15. # include <openssl/stack.h>
  16. # include <openssl/safestack.h>
  17. # include <openssl/symhacks.h>
  18. # include <openssl/ossl_typ.h>
  19. # if OPENSSL_API_COMPAT < 0x10100000L
  20. # include <openssl/bn.h>
  21. # endif
  22. # ifdef OPENSSL_BUILD_SHLIBCRYPTO
  23. # undef OPENSSL_EXTERN
  24. # define OPENSSL_EXTERN OPENSSL_EXPORT
  25. # endif
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. # define V_ASN1_UNIVERSAL 0x00
  30. # define V_ASN1_APPLICATION 0x40
  31. # define V_ASN1_CONTEXT_SPECIFIC 0x80
  32. # define V_ASN1_PRIVATE 0xc0
  33. # define V_ASN1_CONSTRUCTED 0x20
  34. # define V_ASN1_PRIMITIVE_TAG 0x1f
  35. # define V_ASN1_PRIMATIVE_TAG 0x1f
  36. # define V_ASN1_APP_CHOOSE -2/* let the recipient choose */
  37. # define V_ASN1_OTHER -3/* used in ASN1_TYPE */
  38. # define V_ASN1_ANY -4/* used in ASN1 template code */
  39. # define V_ASN1_UNDEF -1
  40. /* ASN.1 tag values */
  41. # define V_ASN1_EOC 0
  42. # define V_ASN1_BOOLEAN 1 /**/
  43. # define V_ASN1_INTEGER 2
  44. # define V_ASN1_BIT_STRING 3
  45. # define V_ASN1_OCTET_STRING 4
  46. # define V_ASN1_NULL 5
  47. # define V_ASN1_OBJECT 6
  48. # define V_ASN1_OBJECT_DESCRIPTOR 7
  49. # define V_ASN1_EXTERNAL 8
  50. # define V_ASN1_REAL 9
  51. # define V_ASN1_ENUMERATED 10
  52. # define V_ASN1_UTF8STRING 12
  53. # define V_ASN1_SEQUENCE 16
  54. # define V_ASN1_SET 17
  55. # define V_ASN1_NUMERICSTRING 18 /**/
  56. # define V_ASN1_PRINTABLESTRING 19
  57. # define V_ASN1_T61STRING 20
  58. # define V_ASN1_TELETEXSTRING 20/* alias */
  59. # define V_ASN1_VIDEOTEXSTRING 21 /**/
  60. # define V_ASN1_IA5STRING 22
  61. # define V_ASN1_UTCTIME 23
  62. # define V_ASN1_GENERALIZEDTIME 24 /**/
  63. # define V_ASN1_GRAPHICSTRING 25 /**/
  64. # define V_ASN1_ISO64STRING 26 /**/
  65. # define V_ASN1_VISIBLESTRING 26/* alias */
  66. # define V_ASN1_GENERALSTRING 27 /**/
  67. # define V_ASN1_UNIVERSALSTRING 28 /**/
  68. # define V_ASN1_BMPSTRING 30
  69. /*
  70. * NB the constants below are used internally by ASN1_INTEGER
  71. * and ASN1_ENUMERATED to indicate the sign. They are *not* on
  72. * the wire tag values.
  73. */
  74. # define V_ASN1_NEG 0x100
  75. # define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
  76. # define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
  77. /* For use with d2i_ASN1_type_bytes() */
  78. # define B_ASN1_NUMERICSTRING 0x0001
  79. # define B_ASN1_PRINTABLESTRING 0x0002
  80. # define B_ASN1_T61STRING 0x0004
  81. # define B_ASN1_TELETEXSTRING 0x0004
  82. # define B_ASN1_VIDEOTEXSTRING 0x0008
  83. # define B_ASN1_IA5STRING 0x0010
  84. # define B_ASN1_GRAPHICSTRING 0x0020
  85. # define B_ASN1_ISO64STRING 0x0040
  86. # define B_ASN1_VISIBLESTRING 0x0040
  87. # define B_ASN1_GENERALSTRING 0x0080
  88. # define B_ASN1_UNIVERSALSTRING 0x0100
  89. # define B_ASN1_OCTET_STRING 0x0200
  90. # define B_ASN1_BIT_STRING 0x0400
  91. # define B_ASN1_BMPSTRING 0x0800
  92. # define B_ASN1_UNKNOWN 0x1000
  93. # define B_ASN1_UTF8STRING 0x2000
  94. # define B_ASN1_UTCTIME 0x4000
  95. # define B_ASN1_GENERALIZEDTIME 0x8000
  96. # define B_ASN1_SEQUENCE 0x10000
  97. /* For use with ASN1_mbstring_copy() */
  98. # define MBSTRING_FLAG 0x1000
  99. # define MBSTRING_UTF8 (MBSTRING_FLAG)
  100. # define MBSTRING_ASC (MBSTRING_FLAG|1)
  101. # define MBSTRING_BMP (MBSTRING_FLAG|2)
  102. # define MBSTRING_UNIV (MBSTRING_FLAG|4)
  103. # define SMIME_OLDMIME 0x400
  104. # define SMIME_CRLFEOL 0x800
  105. # define SMIME_STREAM 0x1000
  106. struct X509_algor_st;
  107. DEFINE_STACK_OF(X509_ALGOR)
  108. # define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */
  109. /*
  110. * This indicates that the ASN1_STRING is not a real value but just a place
  111. * holder for the location where indefinite length constructed data should be
  112. * inserted in the memory buffer
  113. */
  114. # define ASN1_STRING_FLAG_NDEF 0x010
  115. /*
  116. * This flag is used by the CMS code to indicate that a string is not
  117. * complete and is a place holder for content when it had all been accessed.
  118. * The flag will be reset when content has been written to it.
  119. */
  120. # define ASN1_STRING_FLAG_CONT 0x020
  121. /*
  122. * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING
  123. * type.
  124. */
  125. # define ASN1_STRING_FLAG_MSTRING 0x040
  126. /* String is embedded and only content should be freed */
  127. # define ASN1_STRING_FLAG_EMBED 0x080
  128. /* This is the base type that holds just about everything :-) */
  129. struct asn1_string_st {
  130. int length;
  131. int type;
  132. unsigned char *data;
  133. /*
  134. * The value of the following field depends on the type being held. It
  135. * is mostly being used for BIT_STRING so if the input data has a
  136. * non-zero 'unused bits' value, it will be handled correctly
  137. */
  138. long flags;
  139. };
  140. /*
  141. * ASN1_ENCODING structure: this is used to save the received encoding of an
  142. * ASN1 type. This is useful to get round problems with invalid encodings
  143. * which can break signatures.
  144. */
  145. typedef struct ASN1_ENCODING_st {
  146. unsigned char *enc; /* DER encoding */
  147. long len; /* Length of encoding */
  148. int modified; /* set to 1 if 'enc' is invalid */
  149. } ASN1_ENCODING;
  150. /* Used with ASN1 LONG type: if a long is set to this it is omitted */
  151. # define ASN1_LONG_UNDEF 0x7fffffffL
  152. # define STABLE_FLAGS_MALLOC 0x01
  153. /*
  154. * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted
  155. * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting
  156. * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias
  157. * STABLE_FLAGS_CLEAR to reflect this.
  158. */
  159. # define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC
  160. # define STABLE_NO_MASK 0x02
  161. # define DIRSTRING_TYPE \
  162. (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)
  163. # define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)
  164. typedef struct asn1_string_table_st {
  165. int nid;
  166. long minsize;
  167. long maxsize;
  168. unsigned long mask;
  169. unsigned long flags;
  170. } ASN1_STRING_TABLE;
  171. DEFINE_STACK_OF(ASN1_STRING_TABLE)
  172. /* size limits: this stuff is taken straight from RFC2459 */
  173. # define ub_name 32768
  174. # define ub_common_name 64
  175. # define ub_locality_name 128
  176. # define ub_state_name 128
  177. # define ub_organization_name 64
  178. # define ub_organization_unit_name 64
  179. # define ub_title 64
  180. # define ub_email_address 128
  181. /*
  182. * Declarations for template structures: for full definitions see asn1t.h
  183. */
  184. typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;
  185. typedef struct ASN1_TLC_st ASN1_TLC;
  186. /* This is just an opaque pointer */
  187. typedef struct ASN1_VALUE_st ASN1_VALUE;
  188. /* Declare ASN1 functions: the implement macro in in asn1t.h */
  189. # define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)
  190. # define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \
  191. DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)
  192. # define DECLARE_ASN1_FUNCTIONS_name(type, name) \
  193. DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
  194. DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)
  195. # define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \
  196. DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
  197. DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)
  198. # define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \
  199. type *d2i_##name(type **a, const unsigned char **in, long len); \
  200. int i2d_##name(type *a, unsigned char **out); \
  201. DECLARE_ASN1_ITEM(itname)
  202. # define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \
  203. type *d2i_##name(type **a, const unsigned char **in, long len); \
  204. int i2d_##name(const type *a, unsigned char **out); \
  205. DECLARE_ASN1_ITEM(name)
  206. # define DECLARE_ASN1_NDEF_FUNCTION(name) \
  207. int i2d_##name##_NDEF(name *a, unsigned char **out);
  208. # define DECLARE_ASN1_FUNCTIONS_const(name) \
  209. DECLARE_ASN1_ALLOC_FUNCTIONS(name) \
  210. DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)
  211. # define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \
  212. type *name##_new(void); \
  213. void name##_free(type *a);
  214. # define DECLARE_ASN1_PRINT_FUNCTION(stname) \
  215. DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)
  216. # define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \
  217. int fname##_print_ctx(BIO *out, stname *x, int indent, \
  218. const ASN1_PCTX *pctx);
  219. # define D2I_OF(type) type *(*)(type **,const unsigned char **,long)
  220. # define I2D_OF(type) int (*)(type *,unsigned char **)
  221. # define I2D_OF_const(type) int (*)(const type *,unsigned char **)
  222. # define CHECKED_D2I_OF(type, d2i) \
  223. ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))
  224. # define CHECKED_I2D_OF(type, i2d) \
  225. ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))
  226. # define CHECKED_NEW_OF(type, xnew) \
  227. ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))
  228. # define CHECKED_PTR_OF(type, p) \
  229. ((void*) (1 ? p : (type*)0))
  230. # define CHECKED_PPTR_OF(type, p) \
  231. ((void**) (1 ? p : (type**)0))
  232. # define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)
  233. # define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)
  234. # define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)
  235. TYPEDEF_D2I2D_OF(void);
  236. /*-
  237. * The following macros and typedefs allow an ASN1_ITEM
  238. * to be embedded in a structure and referenced. Since
  239. * the ASN1_ITEM pointers need to be globally accessible
  240. * (possibly from shared libraries) they may exist in
  241. * different forms. On platforms that support it the
  242. * ASN1_ITEM structure itself will be globally exported.
  243. * Other platforms will export a function that returns
  244. * an ASN1_ITEM pointer.
  245. *
  246. * To handle both cases transparently the macros below
  247. * should be used instead of hard coding an ASN1_ITEM
  248. * pointer in a structure.
  249. *
  250. * The structure will look like this:
  251. *
  252. * typedef struct SOMETHING_st {
  253. * ...
  254. * ASN1_ITEM_EXP *iptr;
  255. * ...
  256. * } SOMETHING;
  257. *
  258. * It would be initialised as e.g.:
  259. *
  260. * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};
  261. *
  262. * and the actual pointer extracted with:
  263. *
  264. * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);
  265. *
  266. * Finally an ASN1_ITEM pointer can be extracted from an
  267. * appropriate reference with: ASN1_ITEM_rptr(X509). This
  268. * would be used when a function takes an ASN1_ITEM * argument.
  269. *
  270. */
  271. # ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION
  272. /* ASN1_ITEM pointer exported type */
  273. typedef const ASN1_ITEM ASN1_ITEM_EXP;
  274. /* Macro to obtain ASN1_ITEM pointer from exported type */
  275. # define ASN1_ITEM_ptr(iptr) (iptr)
  276. /* Macro to include ASN1_ITEM pointer from base type */
  277. # define ASN1_ITEM_ref(iptr) (&(iptr##_it))
  278. # define ASN1_ITEM_rptr(ref) (&(ref##_it))
  279. # define DECLARE_ASN1_ITEM(name) \
  280. OPENSSL_EXTERN const ASN1_ITEM name##_it;
  281. # else
  282. /*
  283. * Platforms that can't easily handle shared global variables are declared as
  284. * functions returning ASN1_ITEM pointers.
  285. */
  286. /* ASN1_ITEM pointer exported type */
  287. typedef const ASN1_ITEM *ASN1_ITEM_EXP (void);
  288. /* Macro to obtain ASN1_ITEM pointer from exported type */
  289. # define ASN1_ITEM_ptr(iptr) (iptr())
  290. /* Macro to include ASN1_ITEM pointer from base type */
  291. # define ASN1_ITEM_ref(iptr) (iptr##_it)
  292. # define ASN1_ITEM_rptr(ref) (ref##_it())
  293. # define DECLARE_ASN1_ITEM(name) \
  294. const ASN1_ITEM * name##_it(void);
  295. # endif
  296. /* Parameters used by ASN1_STRING_print_ex() */
  297. /*
  298. * These determine which characters to escape: RFC2253 special characters,
  299. * control characters and MSB set characters
  300. */
  301. # define ASN1_STRFLGS_ESC_2253 1
  302. # define ASN1_STRFLGS_ESC_CTRL 2
  303. # define ASN1_STRFLGS_ESC_MSB 4
  304. /*
  305. * This flag determines how we do escaping: normally RC2253 backslash only,
  306. * set this to use backslash and quote.
  307. */
  308. # define ASN1_STRFLGS_ESC_QUOTE 8
  309. /* These three flags are internal use only. */
  310. /* Character is a valid PrintableString character */
  311. # define CHARTYPE_PRINTABLESTRING 0x10
  312. /* Character needs escaping if it is the first character */
  313. # define CHARTYPE_FIRST_ESC_2253 0x20
  314. /* Character needs escaping if it is the last character */
  315. # define CHARTYPE_LAST_ESC_2253 0x40
  316. /*
  317. * NB the internal flags are safely reused below by flags handled at the top
  318. * level.
  319. */
  320. /*
  321. * If this is set we convert all character strings to UTF8 first
  322. */
  323. # define ASN1_STRFLGS_UTF8_CONVERT 0x10
  324. /*
  325. * If this is set we don't attempt to interpret content: just assume all
  326. * strings are 1 byte per character. This will produce some pretty odd
  327. * looking output!
  328. */
  329. # define ASN1_STRFLGS_IGNORE_TYPE 0x20
  330. /* If this is set we include the string type in the output */
  331. # define ASN1_STRFLGS_SHOW_TYPE 0x40
  332. /*
  333. * This determines which strings to display and which to 'dump' (hex dump of
  334. * content octets or DER encoding). We can only dump non character strings or
  335. * everything. If we don't dump 'unknown' they are interpreted as character
  336. * strings with 1 octet per character and are subject to the usual escaping
  337. * options.
  338. */
  339. # define ASN1_STRFLGS_DUMP_ALL 0x80
  340. # define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
  341. /*
  342. * These determine what 'dumping' does, we can dump the content octets or the
  343. * DER encoding: both use the RFC2253 #XXXXX notation.
  344. */
  345. # define ASN1_STRFLGS_DUMP_DER 0x200
  346. /*
  347. * This flag specifies that RC2254 escaping shall be performed.
  348. */
  349. #define ASN1_STRFLGS_ESC_2254 0x400
  350. /*
  351. * All the string flags consistent with RFC2253, escaping control characters
  352. * isn't essential in RFC2253 but it is advisable anyway.
  353. */
  354. # define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
  355. ASN1_STRFLGS_ESC_CTRL | \
  356. ASN1_STRFLGS_ESC_MSB | \
  357. ASN1_STRFLGS_UTF8_CONVERT | \
  358. ASN1_STRFLGS_DUMP_UNKNOWN | \
  359. ASN1_STRFLGS_DUMP_DER)
  360. DEFINE_STACK_OF(ASN1_INTEGER)
  361. DEFINE_STACK_OF(ASN1_GENERALSTRING)
  362. DEFINE_STACK_OF(ASN1_UTF8STRING)
  363. typedef struct asn1_type_st {
  364. int type;
  365. union {
  366. char *ptr;
  367. ASN1_BOOLEAN boolean;
  368. ASN1_STRING *asn1_string;
  369. ASN1_OBJECT *object;
  370. ASN1_INTEGER *integer;
  371. ASN1_ENUMERATED *enumerated;
  372. ASN1_BIT_STRING *bit_string;
  373. ASN1_OCTET_STRING *octet_string;
  374. ASN1_PRINTABLESTRING *printablestring;
  375. ASN1_T61STRING *t61string;
  376. ASN1_IA5STRING *ia5string;
  377. ASN1_GENERALSTRING *generalstring;
  378. ASN1_BMPSTRING *bmpstring;
  379. ASN1_UNIVERSALSTRING *universalstring;
  380. ASN1_UTCTIME *utctime;
  381. ASN1_GENERALIZEDTIME *generalizedtime;
  382. ASN1_VISIBLESTRING *visiblestring;
  383. ASN1_UTF8STRING *utf8string;
  384. /*
  385. * set and sequence are left complete and still contain the set or
  386. * sequence bytes
  387. */
  388. ASN1_STRING *set;
  389. ASN1_STRING *sequence;
  390. ASN1_VALUE *asn1_value;
  391. } value;
  392. } ASN1_TYPE;
  393. DEFINE_STACK_OF(ASN1_TYPE)
  394. typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;
  395. DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
  396. DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)
  397. /* This is used to contain a list of bit names */
  398. typedef struct BIT_STRING_BITNAME_st {
  399. int bitnum;
  400. const char *lname;
  401. const char *sname;
  402. } BIT_STRING_BITNAME;
  403. # define B_ASN1_TIME \
  404. B_ASN1_UTCTIME | \
  405. B_ASN1_GENERALIZEDTIME
  406. # define B_ASN1_PRINTABLE \
  407. B_ASN1_NUMERICSTRING| \
  408. B_ASN1_PRINTABLESTRING| \
  409. B_ASN1_T61STRING| \
  410. B_ASN1_IA5STRING| \
  411. B_ASN1_BIT_STRING| \
  412. B_ASN1_UNIVERSALSTRING|\
  413. B_ASN1_BMPSTRING|\
  414. B_ASN1_UTF8STRING|\
  415. B_ASN1_SEQUENCE|\
  416. B_ASN1_UNKNOWN
  417. # define B_ASN1_DIRECTORYSTRING \
  418. B_ASN1_PRINTABLESTRING| \
  419. B_ASN1_TELETEXSTRING|\
  420. B_ASN1_BMPSTRING|\
  421. B_ASN1_UNIVERSALSTRING|\
  422. B_ASN1_UTF8STRING
  423. # define B_ASN1_DISPLAYTEXT \
  424. B_ASN1_IA5STRING| \
  425. B_ASN1_VISIBLESTRING| \
  426. B_ASN1_BMPSTRING|\
  427. B_ASN1_UTF8STRING
  428. DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
  429. int ASN1_TYPE_get(const ASN1_TYPE *a);
  430. void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
  431. int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
  432. int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
  433. ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);
  434. void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);
  435. ASN1_OBJECT *ASN1_OBJECT_new(void);
  436. void ASN1_OBJECT_free(ASN1_OBJECT *a);
  437. int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp);
  438. ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,
  439. long length);
  440. DECLARE_ASN1_ITEM(ASN1_OBJECT)
  441. DEFINE_STACK_OF(ASN1_OBJECT)
  442. ASN1_STRING *ASN1_STRING_new(void);
  443. void ASN1_STRING_free(ASN1_STRING *a);
  444. void ASN1_STRING_clear_free(ASN1_STRING *a);
  445. int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);
  446. ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);
  447. ASN1_STRING *ASN1_STRING_type_new(int type);
  448. int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);
  449. /*
  450. * Since this is used to store all sorts of things, via macros, for now,
  451. * make its data void *
  452. */
  453. int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);
  454. void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);
  455. int ASN1_STRING_length(const ASN1_STRING *x);
  456. void ASN1_STRING_length_set(ASN1_STRING *x, int n);
  457. int ASN1_STRING_type(const ASN1_STRING *x);
  458. DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))
  459. const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);
  460. DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)
  461. int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);
  462. int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
  463. int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);
  464. int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,
  465. const unsigned char *flags, int flags_len);
  466. int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
  467. BIT_STRING_BITNAME *tbl, int indent);
  468. int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);
  469. int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,
  470. BIT_STRING_BITNAME *tbl);
  471. DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)
  472. ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
  473. long length);
  474. ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);
  475. int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);
  476. DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)
  477. int ASN1_UTCTIME_check(const ASN1_UTCTIME *a);
  478. ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);
  479. ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
  480. int offset_day, long offset_sec);
  481. int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);
  482. int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
  483. int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);
  484. ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,
  485. time_t t);
  486. ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
  487. time_t t, int offset_day,
  488. long offset_sec);
  489. int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);
  490. int ASN1_TIME_diff(int *pday, int *psec,
  491. const ASN1_TIME *from, const ASN1_TIME *to);
  492. DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)
  493. ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);
  494. int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,
  495. const ASN1_OCTET_STRING *b);
  496. int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,
  497. int len);
  498. DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)
  499. DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)
  500. DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)
  501. DECLARE_ASN1_FUNCTIONS(ASN1_NULL)
  502. DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)
  503. int UTF8_getc(const unsigned char *str, int len, unsigned long *val);
  504. int UTF8_putc(unsigned char *str, int len, unsigned long value);
  505. DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)
  506. DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)
  507. DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)
  508. DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)
  509. DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)
  510. DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)
  511. DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)
  512. DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)
  513. DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)
  514. DECLARE_ASN1_FUNCTIONS(ASN1_TIME)
  515. DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)
  516. ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
  517. ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
  518. int offset_day, long offset_sec);
  519. int ASN1_TIME_check(const ASN1_TIME *t);
  520. ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
  521. ASN1_GENERALIZEDTIME **out);
  522. int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
  523. int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a);
  524. int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);
  525. int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a);
  526. int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);
  527. int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a);
  528. int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);
  529. int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);
  530. int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);
  531. int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);
  532. ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,
  533. const char *sn, const char *ln);
  534. int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);
  535. int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);
  536. int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);
  537. int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);
  538. int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
  539. long ASN1_INTEGER_get(const ASN1_INTEGER *a);
  540. ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);
  541. BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);
  542. int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);
  543. int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);
  544. int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);
  545. long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);
  546. ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);
  547. BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);
  548. /* General */
  549. /* given a string, return the correct type, max is the maximum length */
  550. int ASN1_PRINTABLE_type(const unsigned char *s, int max);
  551. unsigned long ASN1_tag2bit(int tag);
  552. /* SPECIALS */
  553. int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
  554. int *pclass, long omax);
  555. int ASN1_check_infinite_end(unsigned char **p, long len);
  556. int ASN1_const_check_infinite_end(const unsigned char **p, long len);
  557. void ASN1_put_object(unsigned char **pp, int constructed, int length,
  558. int tag, int xclass);
  559. int ASN1_put_eoc(unsigned char **pp);
  560. int ASN1_object_size(int constructed, int length, int tag);
  561. /* Used to implement other functions */
  562. void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);
  563. # define ASN1_dup_of(type,i2d,d2i,x) \
  564. ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \
  565. CHECKED_D2I_OF(type, d2i), \
  566. CHECKED_PTR_OF(type, x)))
  567. # define ASN1_dup_of_const(type,i2d,d2i,x) \
  568. ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \
  569. CHECKED_D2I_OF(type, d2i), \
  570. CHECKED_PTR_OF(const type, x)))
  571. void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
  572. /* ASN1 alloc/free macros for when a type is only used internally */
  573. # define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))
  574. # define M_ASN1_free_of(x, type) \
  575. ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))
  576. # ifndef OPENSSL_NO_STDIO
  577. void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);
  578. # define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
  579. ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \
  580. CHECKED_D2I_OF(type, d2i), \
  581. in, \
  582. CHECKED_PPTR_OF(type, x)))
  583. void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
  584. int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);
  585. # define ASN1_i2d_fp_of(type,i2d,out,x) \
  586. (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \
  587. out, \
  588. CHECKED_PTR_OF(type, x)))
  589. # define ASN1_i2d_fp_of_const(type,i2d,out,x) \
  590. (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \
  591. out, \
  592. CHECKED_PTR_OF(const type, x)))
  593. int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
  594. int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);
  595. # endif
  596. int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);
  597. void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);
  598. # define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
  599. ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \
  600. CHECKED_D2I_OF(type, d2i), \
  601. in, \
  602. CHECKED_PPTR_OF(type, x)))
  603. void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
  604. int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);
  605. # define ASN1_i2d_bio_of(type,i2d,out,x) \
  606. (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \
  607. out, \
  608. CHECKED_PTR_OF(type, x)))
  609. # define ASN1_i2d_bio_of_const(type,i2d,out,x) \
  610. (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \
  611. out, \
  612. CHECKED_PTR_OF(const type, x)))
  613. int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
  614. int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);
  615. int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);
  616. int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);
  617. int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);
  618. int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);
  619. int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off);
  620. int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,
  621. unsigned char *buf, int off);
  622. int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);
  623. int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,
  624. int dump);
  625. const char *ASN1_tag2str(int tag);
  626. /* Used to load and write Netscape format cert */
  627. int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);
  628. int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);
  629. int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len);
  630. int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,
  631. unsigned char *data, int len);
  632. int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num,
  633. unsigned char *data, int max_len);
  634. void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it);
  635. ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,
  636. ASN1_OCTET_STRING **oct);
  637. void ASN1_STRING_set_default_mask(unsigned long mask);
  638. int ASN1_STRING_set_default_mask_asc(const char *p);
  639. unsigned long ASN1_STRING_get_default_mask(void);
  640. int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
  641. int inform, unsigned long mask);
  642. int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
  643. int inform, unsigned long mask,
  644. long minsize, long maxsize);
  645. ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,
  646. const unsigned char *in, int inlen,
  647. int inform, int nid);
  648. ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);
  649. int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);
  650. void ASN1_STRING_TABLE_cleanup(void);
  651. /* ASN1 template functions */
  652. /* Old API compatible functions */
  653. ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);
  654. void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);
  655. ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,
  656. long len, const ASN1_ITEM *it);
  657. int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);
  658. int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,
  659. const ASN1_ITEM *it);
  660. void ASN1_add_oid_module(void);
  661. void ASN1_add_stable_module(void);
  662. ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf);
  663. ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf);
  664. int ASN1_str2mask(const char *str, unsigned long *pmask);
  665. /* ASN1 Print flags */
  666. /* Indicate missing OPTIONAL fields */
  667. # define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001
  668. /* Mark start and end of SEQUENCE */
  669. # define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002
  670. /* Mark start and end of SEQUENCE/SET OF */
  671. # define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004
  672. /* Show the ASN1 type of primitives */
  673. # define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008
  674. /* Don't show ASN1 type of ANY */
  675. # define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010
  676. /* Don't show ASN1 type of MSTRINGs */
  677. # define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020
  678. /* Don't show field names in SEQUENCE */
  679. # define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040
  680. /* Show structure names of each SEQUENCE field */
  681. # define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080
  682. /* Don't show structure name even at top level */
  683. # define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100
  684. int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
  685. const ASN1_ITEM *it, const ASN1_PCTX *pctx);
  686. ASN1_PCTX *ASN1_PCTX_new(void);
  687. void ASN1_PCTX_free(ASN1_PCTX *p);
  688. unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p);
  689. void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);
  690. unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p);
  691. void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);
  692. unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p);
  693. void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);
  694. unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p);
  695. void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);
  696. unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p);
  697. void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);
  698. ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx));
  699. void ASN1_SCTX_free(ASN1_SCTX *p);
  700. const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p);
  701. const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p);
  702. unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p);
  703. void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data);
  704. void *ASN1_SCTX_get_app_data(ASN1_SCTX *p);
  705. const BIO_METHOD *BIO_f_asn1(void);
  706. BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);
  707. int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
  708. const ASN1_ITEM *it);
  709. int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
  710. const char *hdr, const ASN1_ITEM *it);
  711. int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
  712. int ctype_nid, int econt_nid,
  713. STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);
  714. ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);
  715. int SMIME_crlf_copy(BIO *in, BIO *out, int flags);
  716. int SMIME_text(BIO *in, BIO *out);
  717. /* BEGIN ERROR CODES */
  718. /*
  719. * The following lines are auto generated by the script mkerr.pl. Any changes
  720. * made after this point may be overwritten when the script is next run.
  721. */
  722. int ERR_load_ASN1_strings(void);
  723. /* Error codes for the ASN1 functions. */
  724. /* Function codes. */
  725. # define ASN1_F_A2D_ASN1_OBJECT 100
  726. # define ASN1_F_A2I_ASN1_INTEGER 102
  727. # define ASN1_F_A2I_ASN1_STRING 103
  728. # define ASN1_F_APPEND_EXP 176
  729. # define ASN1_F_ASN1_BIT_STRING_SET_BIT 183
  730. # define ASN1_F_ASN1_CB 177
  731. # define ASN1_F_ASN1_CHECK_TLEN 104
  732. # define ASN1_F_ASN1_COLLECT 106
  733. # define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108
  734. # define ASN1_F_ASN1_D2I_FP 109
  735. # define ASN1_F_ASN1_D2I_READ_BIO 107
  736. # define ASN1_F_ASN1_DIGEST 184
  737. # define ASN1_F_ASN1_DO_ADB 110
  738. # define ASN1_F_ASN1_DO_LOCK 233
  739. # define ASN1_F_ASN1_DUP 111
  740. # define ASN1_F_ASN1_EX_C2I 204
  741. # define ASN1_F_ASN1_FIND_END 190
  742. # define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216
  743. # define ASN1_F_ASN1_GENERATE_V3 178
  744. # define ASN1_F_ASN1_GET_INT64 224
  745. # define ASN1_F_ASN1_GET_OBJECT 114
  746. # define ASN1_F_ASN1_GET_UINT64 225
  747. # define ASN1_F_ASN1_I2D_BIO 116
  748. # define ASN1_F_ASN1_I2D_FP 117
  749. # define ASN1_F_ASN1_ITEM_D2I_FP 206
  750. # define ASN1_F_ASN1_ITEM_DUP 191
  751. # define ASN1_F_ASN1_ITEM_EMBED_D2I 120
  752. # define ASN1_F_ASN1_ITEM_EMBED_NEW 121
  753. # define ASN1_F_ASN1_ITEM_I2D_BIO 192
  754. # define ASN1_F_ASN1_ITEM_I2D_FP 193
  755. # define ASN1_F_ASN1_ITEM_PACK 198
  756. # define ASN1_F_ASN1_ITEM_SIGN 195
  757. # define ASN1_F_ASN1_ITEM_SIGN_CTX 220
  758. # define ASN1_F_ASN1_ITEM_UNPACK 199
  759. # define ASN1_F_ASN1_ITEM_VERIFY 197
  760. # define ASN1_F_ASN1_MBSTRING_NCOPY 122
  761. # define ASN1_F_ASN1_OBJECT_NEW 123
  762. # define ASN1_F_ASN1_OUTPUT_DATA 214
  763. # define ASN1_F_ASN1_PCTX_NEW 205
  764. # define ASN1_F_ASN1_SCTX_NEW 221
  765. # define ASN1_F_ASN1_SIGN 128
  766. # define ASN1_F_ASN1_STR2TYPE 179
  767. # define ASN1_F_ASN1_STRING_GET_INT64 227
  768. # define ASN1_F_ASN1_STRING_GET_UINT64 230
  769. # define ASN1_F_ASN1_STRING_SET 186
  770. # define ASN1_F_ASN1_STRING_TABLE_ADD 129
  771. # define ASN1_F_ASN1_STRING_TO_BN 228
  772. # define ASN1_F_ASN1_STRING_TYPE_NEW 130
  773. # define ASN1_F_ASN1_TEMPLATE_EX_D2I 132
  774. # define ASN1_F_ASN1_TEMPLATE_NEW 133
  775. # define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131
  776. # define ASN1_F_ASN1_TIME_ADJ 217
  777. # define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134
  778. # define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135
  779. # define ASN1_F_ASN1_UTCTIME_ADJ 218
  780. # define ASN1_F_ASN1_VERIFY 137
  781. # define ASN1_F_B64_READ_ASN1 209
  782. # define ASN1_F_B64_WRITE_ASN1 210
  783. # define ASN1_F_BIO_NEW_NDEF 208
  784. # define ASN1_F_BITSTR_CB 180
  785. # define ASN1_F_BN_TO_ASN1_STRING 229
  786. # define ASN1_F_C2I_ASN1_BIT_STRING 189
  787. # define ASN1_F_C2I_ASN1_INTEGER 194
  788. # define ASN1_F_C2I_ASN1_OBJECT 196
  789. # define ASN1_F_C2I_IBUF 226
  790. # define ASN1_F_C2I_UINT64_INT 101
  791. # define ASN1_F_COLLECT_DATA 140
  792. # define ASN1_F_D2I_ASN1_OBJECT 147
  793. # define ASN1_F_D2I_ASN1_UINTEGER 150
  794. # define ASN1_F_D2I_AUTOPRIVATEKEY 207
  795. # define ASN1_F_D2I_PRIVATEKEY 154
  796. # define ASN1_F_D2I_PUBLICKEY 155
  797. # define ASN1_F_DO_TCREATE 222
  798. # define ASN1_F_I2D_ASN1_BIO_STREAM 211
  799. # define ASN1_F_I2D_DSA_PUBKEY 161
  800. # define ASN1_F_I2D_EC_PUBKEY 181
  801. # define ASN1_F_I2D_PRIVATEKEY 163
  802. # define ASN1_F_I2D_PUBLICKEY 164
  803. # define ASN1_F_I2D_RSA_PUBKEY 165
  804. # define ASN1_F_LONG_C2I 166
  805. # define ASN1_F_OID_MODULE_INIT 174
  806. # define ASN1_F_PARSE_TAGGING 182
  807. # define ASN1_F_PKCS5_PBE2_SET_IV 167
  808. # define ASN1_F_PKCS5_PBE2_SET_SCRYPT 231
  809. # define ASN1_F_PKCS5_PBE_SET 202
  810. # define ASN1_F_PKCS5_PBE_SET0_ALGOR 215
  811. # define ASN1_F_PKCS5_PBKDF2_SET 219
  812. # define ASN1_F_PKCS5_SCRYPT_SET 232
  813. # define ASN1_F_SMIME_READ_ASN1 212
  814. # define ASN1_F_SMIME_TEXT 213
  815. # define ASN1_F_STBL_MODULE_INIT 223
  816. # define ASN1_F_UINT32_C2I 105
  817. # define ASN1_F_UINT64_C2I 112
  818. # define ASN1_F_X509_CRL_ADD0_REVOKED 169
  819. # define ASN1_F_X509_INFO_NEW 170
  820. # define ASN1_F_X509_NAME_ENCODE 203
  821. # define ASN1_F_X509_NAME_EX_D2I 158
  822. # define ASN1_F_X509_NAME_EX_NEW 171
  823. # define ASN1_F_X509_PKEY_NEW 173
  824. /* Reason codes. */
  825. # define ASN1_R_ADDING_OBJECT 171
  826. # define ASN1_R_ASN1_PARSE_ERROR 203
  827. # define ASN1_R_ASN1_SIG_PARSE_ERROR 204
  828. # define ASN1_R_AUX_ERROR 100
  829. # define ASN1_R_BAD_OBJECT_HEADER 102
  830. # define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214
  831. # define ASN1_R_BN_LIB 105
  832. # define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
  833. # define ASN1_R_BUFFER_TOO_SMALL 107
  834. # define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108
  835. # define ASN1_R_CONTEXT_NOT_INITIALISED 217
  836. # define ASN1_R_DATA_IS_WRONG 109
  837. # define ASN1_R_DECODE_ERROR 110
  838. # define ASN1_R_DEPTH_EXCEEDED 174
  839. # define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198
  840. # define ASN1_R_ENCODE_ERROR 112
  841. # define ASN1_R_ERROR_GETTING_TIME 173
  842. # define ASN1_R_ERROR_LOADING_SECTION 172
  843. # define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
  844. # define ASN1_R_EXPECTING_AN_INTEGER 115
  845. # define ASN1_R_EXPECTING_AN_OBJECT 116
  846. # define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119
  847. # define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120
  848. # define ASN1_R_FIELD_MISSING 121
  849. # define ASN1_R_FIRST_NUM_TOO_LARGE 122
  850. # define ASN1_R_HEADER_TOO_LONG 123
  851. # define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175
  852. # define ASN1_R_ILLEGAL_BOOLEAN 176
  853. # define ASN1_R_ILLEGAL_CHARACTERS 124
  854. # define ASN1_R_ILLEGAL_FORMAT 177
  855. # define ASN1_R_ILLEGAL_HEX 178
  856. # define ASN1_R_ILLEGAL_IMPLICIT_TAG 179
  857. # define ASN1_R_ILLEGAL_INTEGER 180
  858. # define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226
  859. # define ASN1_R_ILLEGAL_NESTED_TAGGING 181
  860. # define ASN1_R_ILLEGAL_NULL 125
  861. # define ASN1_R_ILLEGAL_NULL_VALUE 182
  862. # define ASN1_R_ILLEGAL_OBJECT 183
  863. # define ASN1_R_ILLEGAL_OPTIONAL_ANY 126
  864. # define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170
  865. # define ASN1_R_ILLEGAL_PADDING 221
  866. # define ASN1_R_ILLEGAL_TAGGED_ANY 127
  867. # define ASN1_R_ILLEGAL_TIME_VALUE 184
  868. # define ASN1_R_ILLEGAL_ZERO_CONTENT 222
  869. # define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
  870. # define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
  871. # define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220
  872. # define ASN1_R_INVALID_BMPSTRING_LENGTH 129
  873. # define ASN1_R_INVALID_DIGIT 130
  874. # define ASN1_R_INVALID_MIME_TYPE 205
  875. # define ASN1_R_INVALID_MODIFIER 186
  876. # define ASN1_R_INVALID_NUMBER 187
  877. # define ASN1_R_INVALID_OBJECT_ENCODING 216
  878. # define ASN1_R_INVALID_SCRYPT_PARAMETERS 227
  879. # define ASN1_R_INVALID_SEPARATOR 131
  880. # define ASN1_R_INVALID_STRING_TABLE_VALUE 218
  881. # define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133
  882. # define ASN1_R_INVALID_UTF8STRING 134
  883. # define ASN1_R_INVALID_VALUE 219
  884. # define ASN1_R_LIST_ERROR 188
  885. # define ASN1_R_MIME_NO_CONTENT_TYPE 206
  886. # define ASN1_R_MIME_PARSE_ERROR 207
  887. # define ASN1_R_MIME_SIG_PARSE_ERROR 208
  888. # define ASN1_R_MISSING_EOC 137
  889. # define ASN1_R_MISSING_SECOND_NUMBER 138
  890. # define ASN1_R_MISSING_VALUE 189
  891. # define ASN1_R_MSTRING_NOT_UNIVERSAL 139
  892. # define ASN1_R_MSTRING_WRONG_TAG 140
  893. # define ASN1_R_NESTED_ASN1_STRING 197
  894. # define ASN1_R_NESTED_TOO_DEEP 201
  895. # define ASN1_R_NON_HEX_CHARACTERS 141
  896. # define ASN1_R_NOT_ASCII_FORMAT 190
  897. # define ASN1_R_NOT_ENOUGH_DATA 142
  898. # define ASN1_R_NO_CONTENT_TYPE 209
  899. # define ASN1_R_NO_MATCHING_CHOICE_TYPE 143
  900. # define ASN1_R_NO_MULTIPART_BODY_FAILURE 210
  901. # define ASN1_R_NO_MULTIPART_BOUNDARY 211
  902. # define ASN1_R_NO_SIG_CONTENT_TYPE 212
  903. # define ASN1_R_NULL_IS_WRONG_LENGTH 144
  904. # define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191
  905. # define ASN1_R_ODD_NUMBER_OF_CHARS 145
  906. # define ASN1_R_SECOND_NUMBER_TOO_LARGE 147
  907. # define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148
  908. # define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149
  909. # define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192
  910. # define ASN1_R_SHORT_LINE 150
  911. # define ASN1_R_SIG_INVALID_MIME_TYPE 213
  912. # define ASN1_R_STREAMING_NOT_SUPPORTED 202
  913. # define ASN1_R_STRING_TOO_LONG 151
  914. # define ASN1_R_STRING_TOO_SHORT 152
  915. # define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
  916. # define ASN1_R_TIME_NOT_ASCII_FORMAT 193
  917. # define ASN1_R_TOO_LARGE 223
  918. # define ASN1_R_TOO_LONG 155
  919. # define ASN1_R_TOO_SMALL 224
  920. # define ASN1_R_TYPE_NOT_CONSTRUCTED 156
  921. # define ASN1_R_TYPE_NOT_PRIMITIVE 195
  922. # define ASN1_R_UNEXPECTED_EOC 159
  923. # define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215
  924. # define ASN1_R_UNKNOWN_FORMAT 160
  925. # define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161
  926. # define ASN1_R_UNKNOWN_OBJECT_TYPE 162
  927. # define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163
  928. # define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199
  929. # define ASN1_R_UNKNOWN_TAG 194
  930. # define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
  931. # define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
  932. # define ASN1_R_UNSUPPORTED_TYPE 196
  933. # define ASN1_R_WRONG_INTEGER_TYPE 225
  934. # define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200
  935. # define ASN1_R_WRONG_TAG 168
  936. # ifdef __cplusplus
  937. }
  938. # endif
  939. #endif