Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

763 lines
24 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation 1997-1998, All rights reserved. */
  3. #ifndef __MS_ASN1_H__
  4. #define __MS_ASN1_H__
  5. #include <pshpack8.h> /* Assume 8 byte packing throughout */
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. /* ------ Basic integer types ------ */
  10. typedef unsigned char ASN1uint8_t;
  11. typedef signed char ASN1int8_t;
  12. typedef unsigned short ASN1uint16_t;
  13. typedef signed short ASN1int16_t;
  14. typedef unsigned long ASN1uint32_t;
  15. typedef signed long ASN1int32_t;
  16. /* ------ Function modifiers ------ */
  17. #ifdef ASN1LIB
  18. #define ASN1_PUBLIC
  19. #elif defined(ASN1C)
  20. #define ASN1_PUBLIC
  21. #else
  22. #define ASN1_PUBLIC __declspec(dllimport)
  23. #endif
  24. #define ASN1API __stdcall
  25. #define ASN1CALL __stdcall
  26. /* ------ Basic ASN.1 types ------ */
  27. typedef ASN1uint8_t ASN1octet_t;
  28. typedef ASN1uint8_t ASN1bool_t;
  29. typedef struct tagASN1intx_t
  30. {
  31. ASN1uint32_t length;
  32. ASN1octet_t *value;
  33. }
  34. ASN1intx_t;
  35. typedef struct tagASN1octetstring_t
  36. {
  37. ASN1uint32_t length;
  38. ASN1octet_t *value;
  39. }
  40. ASN1octetstring_t;
  41. typedef struct tagASN1octetstring2_t
  42. {
  43. ASN1uint32_t length;
  44. ASN1octet_t value[1];
  45. }
  46. ASN1octetstring2_t;
  47. typedef struct ASN1iterator_s
  48. {
  49. struct ASN1iterator_s *next;
  50. void *value;
  51. }
  52. ASN1iterator_t;
  53. typedef struct tagASN1bitstring_t
  54. {
  55. ASN1uint32_t length;
  56. ASN1octet_t *value;
  57. }
  58. ASN1bitstring_t;
  59. typedef char ASN1char_t;
  60. typedef struct tagASN1charstring_t
  61. {
  62. ASN1uint32_t length;
  63. ASN1char_t *value;
  64. }
  65. ASN1charstring_t;
  66. typedef ASN1uint16_t ASN1char16_t;
  67. typedef struct tagASN1char16string_t
  68. {
  69. ASN1uint32_t length;
  70. ASN1char16_t *value;
  71. }
  72. ASN1char16string_t;
  73. typedef ASN1uint32_t ASN1char32_t;
  74. typedef struct tagASN1char32string_t
  75. {
  76. ASN1uint32_t length;
  77. ASN1char32_t *value;
  78. }
  79. ASN1char32string_t;
  80. typedef ASN1char_t *ASN1ztcharstring_t;
  81. typedef ASN1char16_t *ASN1ztchar16string_t;
  82. typedef ASN1char32_t *ASN1ztchar32string_t;
  83. typedef struct tagASN1wstring_t
  84. {
  85. ASN1uint32_t length;
  86. WCHAR *value;
  87. }
  88. ASN1wstring_t;
  89. typedef struct ASN1objectidentifier_s
  90. {
  91. struct ASN1objectidentifier_s *next;
  92. ASN1uint32_t value;
  93. }
  94. *ASN1objectidentifier_t;
  95. typedef struct tagASN1objectidentifier2_t
  96. {
  97. ASN1uint16_t count;
  98. ASN1uint32_t value[16];
  99. }
  100. ASN1objectidentifier2_t;
  101. typedef struct tagASN1encodedOID_t
  102. {
  103. ASN1uint16_t length;
  104. ASN1octet_t *value;
  105. }
  106. ASN1encodedOID_t;
  107. typedef struct tagASN1stringtableentry_t
  108. {
  109. ASN1char32_t lower;
  110. ASN1char32_t upper;
  111. ASN1uint32_t value;
  112. }
  113. ASN1stringtableentry_t;
  114. typedef struct tagASN1stringtable_t
  115. {
  116. ASN1uint32_t length;
  117. ASN1stringtableentry_t *values;
  118. }
  119. ASN1stringtable_t;
  120. typedef ASN1ztcharstring_t ASN1objectdescriptor_t;
  121. typedef struct tagASN1generalizedtime_t
  122. {
  123. ASN1uint16_t year;
  124. ASN1uint8_t month;
  125. ASN1uint8_t day;
  126. ASN1uint8_t hour;
  127. ASN1uint8_t minute;
  128. ASN1uint8_t second;
  129. ASN1uint16_t millisecond;
  130. ASN1bool_t universal;
  131. ASN1int16_t diff;
  132. }
  133. ASN1generalizedtime_t;
  134. typedef struct tagASN1utctime_t
  135. {
  136. ASN1uint8_t year;
  137. ASN1uint8_t month;
  138. ASN1uint8_t day;
  139. ASN1uint8_t hour;
  140. ASN1uint8_t minute;
  141. ASN1uint8_t second;
  142. ASN1bool_t universal;
  143. ASN1int16_t diff;
  144. }
  145. ASN1utctime_t;
  146. typedef struct tagASN1open_t
  147. {
  148. // encoded
  149. ASN1uint32_t length;
  150. union
  151. {
  152. void *encoded;
  153. void *value;
  154. };
  155. }
  156. ASN1open_t;
  157. typedef enum tagASN1blocktype_e
  158. {
  159. ASN1_DER_SET_OF_BLOCK,
  160. }
  161. ASN1blocktype_e;
  162. typedef ASN1int32_t ASN1enum_t; // enumerated type
  163. typedef ASN1uint16_t ASN1choice_t; // choice
  164. typedef ASN1uint32_t ASN1magic_t;
  165. /* ------ Current version of this ASN.1 software ------ */
  166. #define ASN1_MAKE_VERSION(major,minor) (((major) << 16) | (minor))
  167. #define ASN1_THIS_VERSION ASN1_MAKE_VERSION(1,0)
  168. enum
  169. {
  170. ASN1_CHOICE_BASE = 1,
  171. ASN1_CHOICE_INVALID = -1, // invalid choice
  172. ASN1_CHOICE_EXTENSION = 0, // extension choice
  173. };
  174. /*
  175. Error codes for decoding functions:
  176. - err == 0: data has been successfully decoded
  177. - err < 0: fatal error has occured, no data has been generated
  178. err contains the error number
  179. - err > 0: non-fatal event has occured, data has been generated
  180. err is a bit set of occured events
  181. */
  182. typedef enum tagASN1error_e
  183. {
  184. ASN1_SUCCESS = 0, /* success */
  185. // Teles specific error codes
  186. ASN1_ERR_INTERNAL = (-1001), /* internal error */
  187. ASN1_ERR_EOD = (-1002), /* unexpected end of data */
  188. ASN1_ERR_CORRUPT = (-1003), /* corrupted data */
  189. ASN1_ERR_LARGE = (-1004), /* value too large */
  190. ASN1_ERR_CONSTRAINT = (-1005), /* constraint violated */
  191. ASN1_ERR_MEMORY = (-1006), /* out of memory */
  192. ASN1_ERR_OVERFLOW = (-1007), /* buffer overflow */
  193. ASN1_ERR_BADPDU = (-1008), /* function not supported for this pdu*/
  194. ASN1_ERR_BADARGS = (-1009), /* bad arguments to function call */
  195. ASN1_ERR_BADREAL = (-1010), /* bad real value */
  196. ASN1_ERR_BADTAG = (-1011), /* bad tag value met */
  197. ASN1_ERR_CHOICE = (-1012), /* bad choice value */
  198. ASN1_ERR_RULE = (-1013), /* bad encoding rule */
  199. ASN1_ERR_UTF8 = (-1014), /* bad unicode (utf8) */
  200. // New error codes
  201. ASN1_ERR_PDU_TYPE = (-1051), /* bad pdu type */
  202. ASN1_ERR_NYI = (-1052), /* not yet implemented */
  203. // Teles specific warning codes
  204. ASN1_WRN_EXTENDED = 1001, /* skipped unknown extension(s) */
  205. ASN1_WRN_NOEOD = 1002, /* end of data expected */
  206. }
  207. ASN1error_e;
  208. #define ASN1_SUCCEEDED(ret) (((int) (ret)) >= 0)
  209. #define ASN1_FAILED(ret) (((int) (ret)) < 0)
  210. /* ------ Encoding rules ------ */
  211. typedef enum
  212. {
  213. ASN1_PER_RULE_ALIGNED = 0x0001,
  214. ASN1_PER_RULE_UNALIGNED = 0x0002, // not supported
  215. ASN1_PER_RULE = ASN1_PER_RULE_ALIGNED | ASN1_PER_RULE_UNALIGNED,
  216. ASN1_BER_RULE_BER = 0x0100,
  217. ASN1_BER_RULE_CER = 0x0200,
  218. ASN1_BER_RULE_DER = 0x0400,
  219. ASN1_BER_RULE = ASN1_BER_RULE_BER | ASN1_BER_RULE_CER | ASN1_BER_RULE_DER,
  220. }
  221. ASN1encodingrule_e;
  222. /* ------ public structures ------ */
  223. typedef struct ASN1encoding_s *ASN1encoding_t;
  224. typedef struct ASN1decoding_s *ASN1decoding_t;
  225. typedef ASN1int32_t (ASN1CALL *ASN1PerEncFun_t)(ASN1encoding_t enc, void *data);
  226. typedef ASN1int32_t (ASN1CALL *ASN1PerDecFun_t)(ASN1decoding_t enc, void *data);
  227. typedef struct tagASN1PerFunArr_t
  228. {
  229. const ASN1PerEncFun_t *apfnEncoder;
  230. const ASN1PerDecFun_t *apfnDecoder;
  231. }
  232. ASN1PerFunArr_t;
  233. typedef ASN1int32_t (ASN1CALL *ASN1BerEncFun_t)(ASN1encoding_t enc, ASN1uint32_t tag, void *data);
  234. typedef ASN1int32_t (ASN1CALL *ASN1BerDecFun_t)(ASN1decoding_t enc, ASN1uint32_t tag, void *data);
  235. typedef struct tagASN1BerFunArr_t
  236. {
  237. const ASN1BerEncFun_t *apfnEncoder;
  238. const ASN1BerDecFun_t *apfnDecoder;
  239. }
  240. ASN1BerFunArr_t;
  241. typedef void (ASN1CALL *ASN1GenericFun_t)(void);
  242. typedef void (ASN1CALL *ASN1FreeFun_t)(void *data);
  243. typedef struct tagASN1module_t
  244. {
  245. ASN1magic_t nModuleName;
  246. ASN1encodingrule_e eRule;
  247. ASN1uint32_t dwFlags;
  248. ASN1uint32_t cPDUs;
  249. const ASN1FreeFun_t *apfnFreeMemory;
  250. const ASN1uint32_t *acbStructSize;
  251. union
  252. {
  253. ASN1PerFunArr_t PER;
  254. ASN1BerFunArr_t BER;
  255. };
  256. }
  257. *ASN1module_t;
  258. struct ASN1encoding_s
  259. {
  260. ASN1magic_t magic; /* magic for this structure */
  261. ASN1uint32_t version;/* version number of this library */
  262. ASN1module_t module; /* module this encoding_t depends to */
  263. ASN1octet_t *buf; /* buffer to encode into */
  264. ASN1uint32_t size; /* current size of buffer */
  265. ASN1uint32_t len; /* len of encoded data in buffer */
  266. ASN1error_e err; /* error code for last encoding */
  267. ASN1uint32_t bit;
  268. ASN1octet_t *pos;
  269. ASN1uint32_t cbExtraHeader;
  270. ASN1encodingrule_e eRule;
  271. ASN1uint32_t dwFlags;
  272. };
  273. struct ASN1decoding_s
  274. {
  275. ASN1magic_t magic; /* magic for this structure */
  276. ASN1uint32_t version;/* version number of this library */
  277. ASN1module_t module; /* module this decoding_t depends to */
  278. ASN1octet_t *buf; /* buffer to decode from */
  279. ASN1uint32_t size; /* size of buffer */
  280. ASN1uint32_t len; /* len of decoded data in buffer */
  281. ASN1error_e err; /* error code for last decoding */
  282. ASN1uint32_t bit;
  283. ASN1octet_t *pos;
  284. ASN1encodingrule_e eRule;
  285. ASN1uint32_t dwFlags;
  286. };
  287. /* --- flags for functions --- */
  288. #define ASN1DECFREE_NON_PDU_ID ((ASN1uint32_t) -1)
  289. enum
  290. {
  291. ASN1FLAGS_NONE = 0x00000000L, /* no flags */
  292. ASN1FLAGS_NOASSERT = 0x00001000L, /* no asertion */
  293. };
  294. enum
  295. {
  296. ASN1ENCODE_APPEND = 0x00000001L, /* append to current buffer*/
  297. ASN1ENCODE_REUSEBUFFER = 0x00000004L, /* empty destination buffer */
  298. ASN1ENCODE_SETBUFFER = 0x00000008L, /* use a user-given destination buffer */
  299. ASN1ENCODE_ALLOCATEBUFFER = 0x00000010L, /* do not free/reuse buffer */
  300. ASN1ENCODE_NOASSERT = ASN1FLAGS_NOASSERT, /* no asertion */
  301. };
  302. enum
  303. {
  304. ASN1DECODE_APPENDED = 0x00000001L, /* continue behind last pdu*/
  305. ASN1DECODE_REWINDBUFFER = 0x00000004L, /* rescan from buffer start*/
  306. ASN1DECODE_SETBUFFER = 0x00000008L, /* use a user-given src buffer */
  307. ASN1DECODE_AUTOFREEBUFFER = 0x00000010L, /* Assume responsibility for allocated buffer */
  308. ASN1DECODE_NOASSERT = ASN1FLAGS_NOASSERT, /* no asertion */
  309. };
  310. /* ------ public basic ASN.1 API ------ */
  311. extern ASN1_PUBLIC ASN1module_t ASN1API ASN1_CreateModule
  312. (
  313. ASN1uint32_t nVersion,
  314. ASN1encodingrule_e eRule,
  315. ASN1uint32_t dwFlags, /* ASN1FLAGS_NONE or ASN1FLAGS_NOASSERT */
  316. ASN1uint32_t cPDU,
  317. const ASN1GenericFun_t apfnEncoder[],
  318. const ASN1GenericFun_t apfnDecoder[],
  319. const ASN1FreeFun_t apfnFreeMemory[],
  320. const ASN1uint32_t acbStructSize[],
  321. ASN1magic_t nModuleName
  322. );
  323. extern ASN1_PUBLIC void ASN1API ASN1_CloseModule
  324. (
  325. ASN1module_t pModule
  326. );
  327. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_CreateEncoder
  328. (
  329. ASN1module_t pModule,
  330. ASN1encoding_t *ppEncoderInfo,
  331. ASN1octet_t *pbBuf,
  332. ASN1uint32_t cbBufSize,
  333. ASN1encoding_t pParent
  334. );
  335. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_Encode
  336. (
  337. ASN1encoding_t pEncoderInfo,
  338. void *pDataStruct,
  339. ASN1uint32_t nPduNum,
  340. ASN1uint32_t dwFlags,
  341. ASN1octet_t *pbBuf,
  342. ASN1uint32_t cbBufSize
  343. );
  344. extern ASN1_PUBLIC void ASN1API ASN1_CloseEncoder
  345. (
  346. ASN1encoding_t pEncoderInfo
  347. );
  348. extern ASN1_PUBLIC void ASN1API ASN1_CloseEncoder2
  349. (
  350. ASN1encoding_t pEncoderInfo
  351. );
  352. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_CreateDecoder
  353. (
  354. ASN1module_t pModule,
  355. ASN1decoding_t *ppDecoderInfo,
  356. ASN1octet_t *pbBuf,
  357. ASN1uint32_t cbBufSize,
  358. ASN1decoding_t pParent
  359. );
  360. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_CreateDecoderEx
  361. (
  362. ASN1module_t pModule,
  363. ASN1decoding_t *ppDecoderInfo,
  364. ASN1octet_t *pbBuf,
  365. ASN1uint32_t cbBufSize,
  366. ASN1decoding_t pParent,
  367. ASN1uint32_t dwFlags
  368. );
  369. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_Decode
  370. (
  371. ASN1decoding_t pDecoderInfo,
  372. void **ppDataStruct,
  373. ASN1uint32_t nPduNum,
  374. ASN1uint32_t dwFlags,
  375. ASN1octet_t *pbBuf,
  376. ASN1uint32_t cbBufSize
  377. );
  378. extern ASN1_PUBLIC void ASN1API ASN1_CloseDecoder
  379. (
  380. ASN1decoding_t pDecoderInfo
  381. );
  382. extern ASN1_PUBLIC void ASN1API ASN1_FreeEncoded
  383. (
  384. ASN1encoding_t pEncoderInfo,
  385. void *pBuf
  386. );
  387. extern ASN1_PUBLIC void ASN1API ASN1_FreeDecoded
  388. (
  389. ASN1decoding_t pDecoderInfo,
  390. void *pDataStruct,
  391. ASN1uint32_t nPduNum
  392. );
  393. /* ------ public advanced ASN.1 API ------ */
  394. typedef enum
  395. {
  396. // common set option
  397. ASN1OPT_CHANGE_RULE = 0x101,
  398. // common get option
  399. ASN1OPT_GET_RULE = 0x201,
  400. // set encoder option
  401. ASN1OPT_NOT_REUSE_BUFFER = 0x301,
  402. ASN1OPT_REWIND_BUFFER = 0x302,
  403. // get encoder option
  404. // set decoder option
  405. ASN1OPT_SET_DECODED_BUFFER = 0x501,
  406. ASN1OPT_DEL_DECODED_BUFFER = 0x502,
  407. // get decoder option
  408. ASN1OPT_GET_DECODED_BUFFER_SIZE = 0x601,
  409. }
  410. ASN1option_e;
  411. typedef struct tagASN1optionparam_t
  412. {
  413. ASN1option_e eOption;
  414. union
  415. {
  416. ASN1encodingrule_e eRule;
  417. ASN1uint32_t cbRequiredDecodedBufSize;
  418. struct
  419. {
  420. ASN1octet_t *pbBuf;
  421. ASN1uint32_t cbBufSize;
  422. } Buffer;
  423. };
  424. }
  425. ASN1optionparam_t, ASN1optionparam_s;
  426. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_SetEncoderOption
  427. (
  428. ASN1encoding_t pEncoderInfo,
  429. ASN1optionparam_t *pOptParam
  430. );
  431. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_GetEncoderOption
  432. (
  433. ASN1encoding_t pEncoderInfo,
  434. ASN1optionparam_t *pOptParam
  435. );
  436. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_SetDecoderOption
  437. (
  438. ASN1decoding_t pDecoderInfo,
  439. ASN1optionparam_t *pOptParam
  440. );
  441. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1_GetDecoderOption
  442. (
  443. ASN1decoding_t pDecoderInfo,
  444. ASN1optionparam_t *pOptParam
  445. );
  446. /* ------ internal ASN.1 API ------ */
  447. extern ASN1_PUBLIC void ASN1API ASN1bitstring_free(ASN1bitstring_t *);
  448. extern ASN1_PUBLIC void ASN1API ASN1octetstring_free(ASN1octetstring_t *);
  449. extern ASN1_PUBLIC void ASN1API ASN1objectidentifier_free(ASN1objectidentifier_t *);
  450. extern ASN1_PUBLIC void ASN1API ASN1charstring_free(ASN1charstring_t *);
  451. extern ASN1_PUBLIC void ASN1API ASN1char16string_free(ASN1char16string_t *);
  452. extern ASN1_PUBLIC void ASN1API ASN1char32string_free(ASN1char32string_t *);
  453. extern ASN1_PUBLIC void ASN1API ASN1ztcharstring_free(ASN1ztcharstring_t);
  454. extern ASN1_PUBLIC void ASN1API ASN1ztchar16string_free(ASN1ztchar16string_t);
  455. extern ASN1_PUBLIC void ASN1API ASN1ztchar32string_free(ASN1ztchar32string_t);
  456. extern ASN1_PUBLIC void ASN1API ASN1open_free(ASN1open_t *);
  457. extern ASN1_PUBLIC void ASN1API ASN1utf8string_free(ASN1wstring_t *);
  458. extern ASN1_PUBLIC void * ASN1API ASN1DecAlloc(ASN1decoding_t dec, ASN1uint32_t size);
  459. extern ASN1_PUBLIC void * ASN1API ASN1DecRealloc(ASN1decoding_t dec, void *ptr, ASN1uint32_t size);
  460. extern ASN1_PUBLIC void ASN1API ASN1Free(void *ptr);
  461. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1EncSetError(ASN1encoding_t enc, ASN1error_e err);
  462. extern ASN1_PUBLIC ASN1error_e ASN1API ASN1DecSetError(ASN1decoding_t dec, ASN1error_e err);
  463. extern ASN1_PUBLIC void ASN1API ASN1intx_sub(ASN1intx_t *, ASN1intx_t *, ASN1intx_t *);
  464. extern ASN1_PUBLIC ASN1uint32_t ASN1API ASN1intx_uoctets(ASN1intx_t *);
  465. extern ASN1_PUBLIC void ASN1API ASN1intx_free(ASN1intx_t *);
  466. extern ASN1_PUBLIC void ASN1API ASN1intx_add(ASN1intx_t *, ASN1intx_t *, ASN1intx_t *);
  467. extern ASN1_PUBLIC ASN1int32_t ASN1intx2int32(ASN1intx_t *val);
  468. extern ASN1_PUBLIC ASN1uint32_t ASN1intx2uint32(ASN1intx_t *val);
  469. extern ASN1_PUBLIC int ASN1intxisuint32(ASN1intx_t *val);
  470. extern ASN1_PUBLIC void ASN1intx_setuint32(ASN1intx_t *dst, ASN1uint32_t val);
  471. extern ASN1_PUBLIC void ASN1API ASN1DbgMemTrackDumpCurrent ( ASN1uint32_t nModuleName );
  472. extern ASN1_PUBLIC ASN1uint32_t ASN1API ASN1uint32_uoctets(ASN1uint32_t);
  473. extern ASN1_PUBLIC int ASN1API ASN1objectidentifier_cmp(ASN1objectidentifier_t *v1, ASN1objectidentifier_t *v2);
  474. extern ASN1_PUBLIC int ASN1API ASN1objectidentifier2_cmp(ASN1objectidentifier2_t *v1, ASN1objectidentifier2_t *v2);
  475. extern ASN1_PUBLIC int ASN1API ASN1bitstring_cmp(ASN1bitstring_t *, ASN1bitstring_t *, int);
  476. extern ASN1_PUBLIC int ASN1API ASN1octetstring_cmp(ASN1octetstring_t *, ASN1octetstring_t *);
  477. extern ASN1_PUBLIC int ASN1API ASN1objectidentifier_cmp(ASN1objectidentifier_t *, ASN1objectidentifier_t *);
  478. extern ASN1_PUBLIC int ASN1API ASN1charstring_cmp(ASN1charstring_t *, ASN1charstring_t *);
  479. extern ASN1_PUBLIC int ASN1API ASN1char16string_cmp(ASN1char16string_t *, ASN1char16string_t *);
  480. extern ASN1_PUBLIC int ASN1API ASN1char32string_cmp(ASN1char32string_t *, ASN1char32string_t *);
  481. extern ASN1_PUBLIC int ASN1API ASN1ztcharstring_cmp(ASN1ztcharstring_t, ASN1ztcharstring_t);
  482. extern ASN1_PUBLIC int ASN1API ASN1ztchar16string_cmp(ASN1ztchar16string_t, ASN1ztchar16string_t);
  483. extern ASN1_PUBLIC int ASN1API ASN1open_cmp(ASN1open_t *, ASN1open_t *);
  484. extern ASN1_PUBLIC int ASN1API ASN1generalizedtime_cmp(ASN1generalizedtime_t *, ASN1generalizedtime_t *);
  485. extern ASN1_PUBLIC int ASN1API ASN1utctime_cmp(ASN1utctime_t *, ASN1utctime_t *);
  486. /* --------------------------------------------------------- */
  487. /* The following is not supported. */
  488. /* --------------------------------------------------------- */
  489. typedef enum tagASN1real_e
  490. {
  491. eReal_Normal,
  492. eReal_PlusInfinity,
  493. eReal_MinusInfinity
  494. }
  495. ASN1real_e;
  496. typedef struct tagASN1real_t
  497. {
  498. ASN1real_e type;
  499. ASN1intx_t mantissa;
  500. ASN1uint32_t base;
  501. ASN1intx_t exponent;
  502. }
  503. ASN1real_t;
  504. typedef struct tagASN1external_t
  505. {
  506. # define ASN1external_data_value_descriptor_o 0
  507. ASN1octet_t o[1];
  508. struct ASN1external_identification_s
  509. {
  510. ASN1uint8_t o;
  511. union
  512. {
  513. # define ASN1external_identification_syntax_o 1
  514. ASN1objectidentifier_t syntax;
  515. # define ASN1external_identification_presentation_context_id_o 2
  516. ASN1uint32_t presentation_context_id;
  517. # define ASN1external_identification_context_negotiation_o 3
  518. struct ASN1external_identification_context_negotiation_s
  519. {
  520. ASN1uint32_t presentation_context_id;
  521. ASN1objectidentifier_t transfer_syntax;
  522. } context_negotiation;
  523. } u;
  524. } identification;
  525. ASN1objectdescriptor_t data_value_descriptor;
  526. struct ASN1external_data_value_s
  527. {
  528. ASN1uint8_t o;
  529. union
  530. {
  531. # define ASN1external_data_value_notation_o 0
  532. ASN1open_t notation;
  533. # define ASN1external_data_value_encoded_o 1
  534. ASN1bitstring_t encoded;
  535. } u;
  536. } data_value;
  537. }
  538. ASN1external_t;
  539. typedef struct ASN1external_identification_s ASN1external_identification_t;
  540. typedef struct ASN1external_identification_context_negotiation_s ASN1external_identification_context_negotiation_t;
  541. typedef struct ASN1external_data_value_s ASN1external_data_value_t;
  542. typedef struct tagASN1embeddedpdv_t
  543. {
  544. struct ASN1embeddedpdv_identification_s
  545. {
  546. ASN1uint8_t o;
  547. union
  548. {
  549. # define ASN1embeddedpdv_identification_syntaxes_o 0
  550. struct ASN1embeddedpdv_identification_syntaxes_s
  551. {
  552. ASN1objectidentifier_t abstract;
  553. ASN1objectidentifier_t transfer;
  554. } syntaxes;
  555. # define ASN1embeddedpdv_identification_syntax_o 1
  556. ASN1objectidentifier_t syntax;
  557. # define ASN1embeddedpdv_identification_presentation_context_id_o 2
  558. ASN1uint32_t presentation_context_id;
  559. # define ASN1embeddedpdv_identification_context_negotiation_o 3
  560. struct ASN1embeddedpdv_identification_context_negotiation_s
  561. {
  562. ASN1uint32_t presentation_context_id;
  563. ASN1objectidentifier_t transfer_syntax;
  564. } context_negotiation;
  565. # define ASN1embeddedpdv_identification_transfer_syntax_o 4
  566. ASN1objectidentifier_t transfer_syntax;
  567. # define ASN1embeddedpdv_identification_fixed_o 5
  568. } u;
  569. } identification;
  570. struct ASN1embeddedpdv_data_value_s
  571. {
  572. ASN1uint8_t o;
  573. union
  574. {
  575. # define ASN1embeddedpdv_data_value_notation_o 0
  576. ASN1open_t notation;
  577. # define ASN1embeddedpdv_data_value_encoded_o 1
  578. ASN1bitstring_t encoded;
  579. } u;
  580. } data_value;
  581. }
  582. ASN1embeddedpdv_t;
  583. typedef struct ASN1embeddedpdv_identification_s ASN1embeddedpdv_identification_t;
  584. typedef struct ASN1embeddedpdv_identification_syntaxes_s ASN1embeddedpdv_identification_syntaxes_t;
  585. typedef struct ASN1embeddedpdv_identification_context_negotiation_s ASN1embeddedpdv_identification_context_negotiation_t;
  586. typedef struct ASN1embeddedpdv_data_value_s ASN1embeddedpdv_data_value_t;
  587. typedef struct tagASN1characterstring_t
  588. {
  589. struct ASN1characterstring_identification_s
  590. {
  591. ASN1uint8_t o;
  592. union
  593. {
  594. # define ASN1characterstring_identification_syntaxes_o 0
  595. struct ASN1characterstring_identification_syntaxes_s
  596. {
  597. ASN1objectidentifier_t abstract;
  598. ASN1objectidentifier_t transfer;
  599. } syntaxes;
  600. # define ASN1characterstring_identification_syntax_o 1
  601. ASN1objectidentifier_t syntax;
  602. # define ASN1characterstring_identification_presentation_context_id_o 2
  603. ASN1uint32_t presentation_context_id;
  604. # define ASN1characterstring_identification_context_negotiation_o 3
  605. struct ASN1characterstring_identification_context_negotiation_s
  606. {
  607. ASN1uint32_t presentation_context_id;
  608. ASN1objectidentifier_t transfer_syntax;
  609. } context_negotiation;
  610. # define ASN1characterstring_identification_transfer_syntax_o 4
  611. ASN1objectidentifier_t transfer_syntax;
  612. # define ASN1characterstring_identification_fixed_o 5
  613. } u;
  614. } identification;
  615. struct ASN1characterstring_data_value_s
  616. {
  617. ASN1uint8_t o;
  618. union
  619. {
  620. # define ASN1characterstring_data_value_notation_o 0
  621. ASN1open_t notation;
  622. # define ASN1characterstring_data_value_encoded_o 1
  623. ASN1octetstring_t encoded;
  624. } u;
  625. } data_value;
  626. } ASN1characterstring_t;
  627. typedef struct ASN1characterstring_identification_s ASN1characterstring_identification_t;
  628. typedef struct ASN1characterstring_identification_syntaxes_s ASN1characterstring_identification_syntaxes_t;
  629. typedef struct ASN1characterstring_identification_context_negotiation_s ASN1characterstring_identification_context_negotiation_t;
  630. typedef struct ASN1characterstring_data_value_s ASN1characterstring_data_value_t;
  631. extern ASN1_PUBLIC void ASN1API ASN1real_free(ASN1real_t *);
  632. extern ASN1_PUBLIC void ASN1API ASN1external_free(ASN1external_t *);
  633. extern ASN1_PUBLIC void ASN1API ASN1embeddedpdv_free(ASN1embeddedpdv_t *);
  634. extern ASN1_PUBLIC void ASN1API ASN1characterstring_free(ASN1characterstring_t *);
  635. #ifdef __cplusplus
  636. }
  637. #endif
  638. #include <poppack.h> /* End 8-byte packing */
  639. #endif // __MS_ASN1_H__