Source code of Windows XP (NT5)
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.

139 lines
5.9 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation 1997-1998, All rights reserved. */
  3. #ifndef __LIB_ASN1_H__
  4. #define __LIB_ASN1_H__
  5. #include <msasn1.h>
  6. #include <msper.h>
  7. #include <msber.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. // THE FOLLOWING IS FROM MS_CORE.H
  12. /*
  13. * This file contains operating system specific defines:
  14. *
  15. * Dynamic link library support:
  16. * Define DllExport as declspec for exported functions and
  17. * DllImport as declspec for imported functions.
  18. *
  19. * Floating point encoding support:
  20. * For encoding floating point values either
  21. * - finite()+isinf()+copysign()+frexp() or
  22. * - finite()+fpclass()+FP_PINF+FP_NINF+frexp()
  23. * is needed. Define HAS_ISINF for the former case or HAS_FPCLASS for
  24. * the latter case.
  25. * Define HAS_IEEEFP_H for inclusion of <ieeefp.h> or HAS_FLOAT_H for
  26. * inclusion of <float.h> if required.
  27. *
  28. * Integer type support
  29. * [u]int{8,16,32}_t must specify an integral (unsigned iff u-prefixed)
  30. * type of the specified size (in bits).
  31. */
  32. /* MS-Windows 95/MS-Windows NT */
  33. #define THIRTYTWO_BITS 1
  34. // #define HAS_SIXTYFOUR_BITS 1
  35. #define HAS_FLOAT_H 1
  36. #define HAS_FPCLASS 1
  37. #define fpclass(_d) _fpclass(_d)
  38. #define finite(_d) _finite(_d)
  39. #define isnan(_d) _isnan(_d)
  40. #define FP_PINF _FPCLASS_PINF
  41. #define FP_NINF _FPCLASS_NINF
  42. // #define HAS_STRICMP 1
  43. #define DBL_PINF {0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f}
  44. #define DBL_MINF {0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff}
  45. extern ASN1intx_t ASN1intx_0, ASN1intx_1, ASN1intx_2, ASN1intx_16, ASN1intx_256, ASN1intx_64K, ASN1intx_1G;
  46. extern void ASN1API ASN1intx_addoctet(ASN1intx_t *, ASN1intx_t *, ASN1octet_t);
  47. extern void ASN1API ASN1intx_suboctet(ASN1intx_t *, ASN1intx_t *, ASN1octet_t);
  48. extern void ASN1API ASN1intx_muloctet(ASN1intx_t *, ASN1intx_t *, ASN1octet_t);
  49. extern void ASN1API ASN1intx_inc(ASN1intx_t *);
  50. extern void ASN1API ASN1intx_dec(ASN1intx_t *);
  51. extern void ASN1API ASN1intx_neg(ASN1intx_t *, ASN1intx_t *);
  52. extern ASN1uint32_t ASN1API ASN1intx_log2(ASN1intx_t *);
  53. extern ASN1uint32_t ASN1API ASN1intx_log256(ASN1intx_t *);
  54. extern ASN1int32_t ASN1API ASN1intx_cmp(ASN1intx_t *, ASN1intx_t *);
  55. extern ASN1int32_t ASN1API ASN1intx_dup(ASN1intx_t *, ASN1intx_t *);
  56. // extern void ASN1API ASN1intx_free(ASN1intx_t *);
  57. extern void ASN1API ASN1intx_setuint32(ASN1intx_t *, ASN1uint32_t);
  58. extern void ASN1API ASN1intx_setint32(ASN1intx_t *, ASN1int32_t);
  59. extern int ASN1API ASN1intxisuint64(ASN1intx_t *);
  60. extern int ASN1API ASN1intxisint64(ASN1intx_t *);
  61. extern int ASN1API ASN1intxisuint32(ASN1intx_t *);
  62. extern int ASN1API ASN1intxisint32(ASN1intx_t *);
  63. extern int ASN1API ASN1intxisuint16(ASN1intx_t *);
  64. extern int ASN1API ASN1intxisint16(ASN1intx_t *);
  65. extern int ASN1API ASN1intxisuint8(ASN1intx_t *);
  66. extern int ASN1API ASN1intxisint8(ASN1intx_t *);
  67. #ifdef HAS_SIXTYFOUR_BITS
  68. extern ASN1uint64_t ASN1API ASN1intx2uint64(ASN1intx_t *);
  69. extern ASN1int64_t ASN1API ASN1intx2int64(ASN1intx_t *);
  70. #endif
  71. extern ASN1uint32_t ASN1API ASN1intx2uint32(ASN1intx_t *);
  72. extern ASN1int32_t ASN1API ASN1intx2int32(ASN1intx_t *);
  73. extern ASN1uint16_t ASN1API ASN1intx2uint16(ASN1intx_t *);
  74. extern ASN1int16_t ASN1API ASN1intx2int16(ASN1intx_t *);
  75. extern ASN1uint8_t ASN1API ASN1intx2uint8(ASN1intx_t *);
  76. extern ASN1int8_t ASN1API ASN1intx2int8(ASN1intx_t *);
  77. extern ASN1uint32_t ASN1API ASN1intx_octets(ASN1intx_t *);
  78. extern ASN1uint32_t ASN1API ASN1uint32_log2(ASN1uint32_t);
  79. extern ASN1uint32_t ASN1API ASN1uint32_log256(ASN1uint32_t);
  80. extern ASN1uint32_t ASN1API ASN1uint32_octets(ASN1uint32_t);
  81. extern ASN1uint32_t ASN1API ASN1uint32_uoctets(ASN1uint32_t);
  82. extern ASN1uint32_t ASN1API ASN1int32_octets(ASN1int32_t);
  83. extern double ASN1API ASN1intx2double(ASN1intx_t *);
  84. extern double ASN1API ASN1real2double(ASN1real_t *);
  85. extern double ASN1API ASN1double_minf();
  86. extern double ASN1API ASN1double_pinf();
  87. extern int ASN1API ASN1double_isminf(double);
  88. extern int ASN1API ASN1double_ispinf(double);
  89. extern int ASN1API ASN1generalizedtime2string(char *, ASN1generalizedtime_t *);
  90. extern int ASN1API ASN1utctime2string(char *, ASN1utctime_t *);
  91. extern int ASN1API ASN1string2generalizedtime(ASN1generalizedtime_t *, char *);
  92. extern int ASN1API ASN1string2utctime(ASN1utctime_t *, char *);
  93. /* ------ Comparison APIs ------ */
  94. extern int ASN1API ASN1ztchar32string_cmp(ASN1ztchar32string_t, ASN1ztchar32string_t);
  95. extern int ASN1API ASN1double_cmp(double, double);
  96. extern int ASN1API ASN1real_cmp(ASN1real_t *, ASN1real_t *);
  97. extern int ASN1API ASN1external_cmp(ASN1external_t *, ASN1external_t *);
  98. extern int ASN1API ASN1embeddedpdv_cmp(ASN1embeddedpdv_t *, ASN1embeddedpdv_t *);
  99. extern int ASN1API ASN1characterstring_cmp(ASN1characterstring_t *, ASN1characterstring_t *);
  100. extern int ASN1API ASN1sequenceoflengthpointer_cmp(ASN1uint32_t, void *, ASN1uint32_t, void *, ASN1uint32_t, int (*)(void *, void *));
  101. extern int ASN1API ASN1sequenceofsinglylinkedlist_cmp(void *, void *, ASN1uint32_t, int (*)(void *, void *));
  102. extern int ASN1API ASN1sequenceofdoublylinkedlist_cmp(void *, void *, ASN1uint32_t, int (*)(void *, void *));
  103. extern int ASN1API ASN1setoflengthpointer_cmp(ASN1uint32_t, void *, ASN1uint32_t, void *, ASN1uint32_t, int (*)(void *, void *));
  104. extern int ASN1API ASN1setofsinglylinkedlist_cmp(void *, void *, ASN1uint32_t, int (*)(void *, void *));
  105. extern int ASN1API ASN1setofdoublylinkedlist_cmp(void *, void *, ASN1uint32_t, int (*)(void *, void *));
  106. #define ASN1BITSET(_val, _bitnr) \
  107. ((_val)[(_bitnr) >> 3] |= 0x80 >> ((_bitnr) & 7))
  108. #define ASN1BITCLR(_val, _bitnr) \
  109. ((_val)[(_bitnr) >> 3] &= ~(0x80 >> ((_bitnr) & 7)))
  110. #define ASN1BITTEST(_val, _bitnr) \
  111. ((_val)[(_bitnr) >> 3] & (0x80 >> ((_bitnr) & 7)))
  112. // internal functions
  113. int _BERDecConstructed(ASN1decoding_t dec, ASN1uint32_t len, ASN1uint32_t infinite, ASN1decoding_t *dd, ASN1octet_t **di);
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif // __LIB_ASN1_H__