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.

186 lines
3.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 2000
  6. //
  7. // File: encode.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _ENCODE_H_
  11. #define _ENCODE_H_
  12. #include <wtypes.h>
  13. #include "csber.h"
  14. // definitions of maximum lengths needed for the ASN.1 encoded form of some of
  15. // the common fields in a certificate
  16. #define MAXVALIDITYLEN 0x24
  17. #define MAXKEYINFOLEN 0x40
  18. #define MAXALGIDLEN 0x0a
  19. #define MAXOBJIDLEN 20
  20. #define MAXNAMEVALUELEN 0x40
  21. #define UTCTIMELEN 0x0f
  22. #define MAXPUBKEYDATALEN 0x30
  23. #define VERSIONLEN 0x03
  24. #define MAXENCODEDSIGLEN 0x30
  25. #define MAXHEADERLEN 0x08
  26. #define MINHEADERLEN 0x03
  27. #define MAXTIMELEN 0x20
  28. #define MAXNAMELEN 0x40
  29. // definitions for scrubbing memory
  30. #define ALLBITSOFF 0x00
  31. #define ALLBITSON 0xff
  32. typedef struct _PctPrivateKey {
  33. DWORD Type;
  34. DWORD cbKey;
  35. BYTE pKey[1];
  36. } PctPrivateKey, *PPctPrivateKey;
  37. typedef struct _OIDTRANSLATE {
  38. char const *pszObjId;
  39. BYTE abOIDEncoded[MAXOBJIDLEN]; // ASN.1 encoded OID
  40. BYTE cbOIDEncoded; // ASN.1 encoded OID length
  41. } OIDTRANSLATE;
  42. typedef struct _ALGIDTRANSLATE {
  43. DWORD AlgId;
  44. char const *pszObjId;
  45. } ALGIDTRANSLATE;
  46. typedef struct _RDNENTRY {
  47. char const *pszObjId;
  48. char const *pszShortName;
  49. BYTE BerTag; // ASN.1 type of string
  50. DWORD cbMaxString;
  51. DWORD cbMaxConcatenated;
  52. DWORD cbRemain;
  53. } RDNENTRY;
  54. typedef struct _NAMEENTRY {
  55. char const *pszObjId;
  56. BYTE BerTag; // ASN.1 type of string
  57. DWORD cbData;
  58. BYTE *pbData;
  59. DWORD iRDN;
  60. } NAMEENTRY;
  61. typedef struct _NAMETABLE {
  62. DWORD cnt;
  63. NAMEENTRY *pNameEntry;
  64. } NAMETABLE;
  65. extern const ALGIDTRANSLATE g_aAlgIdTranslate[];
  66. extern const DWORD g_cAlgIdTranslate;
  67. extern const OIDTRANSLATE g_aOidTranslate[];
  68. extern const DWORD g_cOidTranslate;
  69. extern RDNENTRY g_ardnSubject[];
  70. extern const DWORD g_crdnSubject;
  71. // prototypes for the functions in enc.cpp:
  72. OIDTRANSLATE const *
  73. LookupOidTranslate(
  74. IN CHAR const *pszObjId);
  75. long
  76. EncodeObjId(
  77. OPTIONAL OUT BYTE *pbEncoded,
  78. IN CHAR const *pszObjId);
  79. long
  80. EncodeLength(
  81. OPTIONAL OUT BYTE *pbEncoded,
  82. IN DWORD dwLen);
  83. long
  84. EncodeAlgid(
  85. OPTIONAL OUT BYTE *pbEncoded,
  86. IN DWORD Algid);
  87. long
  88. EncodeInteger(
  89. OPTIONAL OUT BYTE *pbEncoded,
  90. IN BYTE const *pbInt,
  91. IN DWORD dwLen);
  92. long
  93. EncodeUnicodeString(
  94. OPTIONAL OUT BYTE *pbEncoded,
  95. IN WCHAR const *pwsz);
  96. long
  97. EncodeIA5String(
  98. OPTIONAL OUT BYTE *pbEncoded,
  99. IN BYTE const *pbStr,
  100. IN DWORD dwLen);
  101. long
  102. EncodeOctetString(
  103. OPTIONAL OUT BYTE *pbEncoded,
  104. IN BYTE const *pbStr,
  105. IN DWORD dwLen);
  106. long
  107. EncodeBitString(
  108. OPTIONAL OUT BYTE *pbEncoded,
  109. IN BYTE const *pbStr,
  110. IN DWORD dwLen);
  111. long
  112. EncodeHeader(
  113. OPTIONAL OUT BYTE *pbEncoded,
  114. IN DWORD dwLen);
  115. long
  116. EncodeSetHeader(
  117. OPTIONAL OUT BYTE *pbEncoded,
  118. IN DWORD dwLen);
  119. long
  120. EncodeAttributeHeader(
  121. OPTIONAL OUT BYTE *pbEncoded,
  122. IN DWORD dwLen);
  123. long
  124. EncodeName(
  125. OPTIONAL OUT BYTE *pbEncoded,
  126. IN BYTE const *pbName,
  127. IN DWORD dwLen);
  128. long
  129. EncodeAlgorithm(
  130. OPTIONAL OUT BYTE *pbEncoded,
  131. IN DWORD AlgId);
  132. #define ALGTYPE_SIG_RSA_MD5 0x01
  133. #define ALGTYPE_KEYEXCH_RSA_MD5 0x02
  134. #define ALGTYPE_CIPHER_RC4_MD5 0x03
  135. long
  136. EncodeDN(
  137. OPTIONAL OUT BYTE *pbEncoded,
  138. IN NAMETABLE const *pNameTable);
  139. long
  140. EncodeFileTime(
  141. OPTIONAL OUT BYTE *pbEncoded,
  142. IN FILETIME Time,
  143. IN BOOL UTC);
  144. #endif // _ENCODE_H_