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.

184 lines
6.2 KiB

  1. /*-----------------------------------------------------------------------------
  2. * Copyright (C) Microsoft Corporation, 1995 - 1996.
  3. * All rights reserved.
  4. *
  5. * This file is part of the Microsoft Private Communication Technology
  6. * reference implementation, version 1.0
  7. *
  8. * The Private Communication Technology reference implementation, version 1.0
  9. * ("PCTRef"), is being provided by Microsoft to encourage the development and
  10. * enhancement of an open standard for secure general-purpose business and
  11. * personal communications on open networks. Microsoft is distributing PCTRef
  12. * at no charge irrespective of whether you use PCTRef for non-commercial or
  13. * commercial use.
  14. *
  15. * Microsoft expressly disclaims any warranty for PCTRef and all derivatives of
  16. * it. PCTRef and any related documentation is provided "as is" without
  17. * warranty of any kind, either express or implied, including, without
  18. * limitation, the implied warranties or merchantability, fitness for a
  19. * particular purpose, or noninfringement. Microsoft shall have no obligation
  20. * to provide maintenance, support, upgrades or new releases to you or to anyone
  21. * receiving from you PCTRef or your modifications. The entire risk arising out
  22. * of use or performance of PCTRef remains with you.
  23. *
  24. * Please see the file LICENSE.txt,
  25. * or http://pct.microsoft.com/pct/pctlicen.txt
  26. * for more information on licensing.
  27. *
  28. * Please see http://pct.microsoft.com/pct/pct.htm for The Private
  29. * Communication Technology Specification version 1.0 ("PCT Specification")
  30. *
  31. * 1/23/96
  32. *----------------------------------------------------------------------------*/
  33. #ifndef _ENCODE_H_
  34. #define _ENCODE_H_
  35. /* tag definitions for ASN.1 encoding decoding */
  36. #define INTEGER_TAG 0x02
  37. #define CHAR_STRING_TAG 0x16
  38. #define OCTET_STRING_TAG 0x04
  39. #define BIT_STRING_TAG 0x03
  40. #define UTCTIME_TAG 0x17
  41. #define SEQUENCE_TAG 0x30
  42. #define SET_OF_TAG 0x11
  43. #define OBJECT_ID_TAG 0x06
  44. #define NULL_TAG 0x05
  45. #define PRINTABLE_STRING_TAG 0x13
  46. #define TELETEX_STRING_TAG 0x14
  47. /* definitions of maximum lengths needed for the ASN.1 encoded
  48. form of some of the common fields in a certificate */
  49. #define MAXVALIDITYLEN 0x24
  50. #define MAXKEYINFOLEN 0x50
  51. #define MAXALGIDLEN 0x0A
  52. #define MAXOBJIDLEN 0x0A
  53. #define MAXNAMEVALUELEN 0x40
  54. #define UTCTIMELEN 0x0F
  55. #define MAXPUBKEYDATALEN 0x30
  56. #define VERSIONLEN 0x03
  57. #define MAXENCODEDSIGLEN 0x30
  58. #define MAXHEADERLEN 0x08
  59. #define MINHEADERLEN 0x03
  60. #define MAXTIMELEN 0x20
  61. /* definitions for scrubbing memory */
  62. #define ALLBITSOFF 0x00
  63. #define ALLBITSON 0xFF
  64. /* prototypes for the functions in encode.c */
  65. long EncodeLength (BYTE *pbEncoded, DWORD dwLen, BOOL Writeflag);
  66. long EncodeAlgid (BYTE *pbEncoded, DWORD Algid, BOOL Writeflag);
  67. long EncodeInteger (BYTE *pbEncoded, BYTE *pbInt, DWORD dwLen, BOOL Writeflag);
  68. long EncodeString (BYTE *pbEncoded, BYTE *pbStr, DWORD dwLen, BOOL Writeflag);
  69. long EncodeOctetString (BYTE *pbEncoded, BYTE *pbStr, DWORD dwLen, BOOL Writeflag);
  70. long EncodeBitString (BYTE *pbEncoded, BYTE *pbStr, DWORD dwLen, BOOL Writeflag);
  71. //long EncodeUTCTime (BYTE *pbEncoded, time_t Time, BOOL Writeflag);
  72. long EncodeHeader (BYTE *pbEncoded, DWORD dwLen, BOOL Writeflag);
  73. long EncodeSetOfHeader (BYTE *pbEncoded, DWORD dwLen, BOOL Writeflag);
  74. long EncodeName (BYTE *pbEncoded, BYTE *pbName, DWORD dwLen, BOOL Writeflag);
  75. long DecodeLength (DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded);
  76. long DecodeAlgid (DWORD *pAlgid, BYTE *pbEncoded, DWORD cEncoded, BOOL Writeflag);
  77. long DecodeHeader (DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded);
  78. long DecodeSetOfHeader (DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded);
  79. long DecodeInteger (BYTE *pbInt, DWORD cbBuff, DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded, BOOL Writeflag);
  80. long DecodeString (BYTE *pbStr, DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded,BOOL Writeflag);
  81. long DecodeOctetString (BYTE *pbStr, DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded, BOOL Writeflag);
  82. long DecodeBitString (BYTE *pbStr, DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded, BOOL Writeflag);
  83. long DecodeName (BYTE *pbName, DWORD *pdwLen, BYTE *pbEncoded, DWORD cEncoded, BOOL Writeflag);
  84. long
  85. EncodeAlgorithm(
  86. BYTE * pbEncoded,
  87. DWORD AlgId,
  88. BOOL WriteFlag);
  89. #define ALGTYPE_SIG_RSA_MD5 0x01
  90. #define ALGTYPE_KEYEXCH_RSA_MD5 0x02
  91. #define ALGTYPE_CIPHER_RC4_MD5 0x03
  92. long
  93. EncodeDN(
  94. BYTE * pbEncoded,
  95. PSTR pszDN,
  96. BOOL WriteFlag);
  97. long
  98. IisDecodeDN(
  99. PSTR *pValue,
  100. PSTR pBuf,
  101. BYTE * pbEncoded,
  102. DWORD cEncoded
  103. );
  104. #ifndef SECURITY_LINUX
  105. long
  106. EncodeFileTime(
  107. BYTE * pbEncoded,
  108. FILETIME Time,
  109. BOOL UTC,
  110. BOOL WriteFlag);
  111. #else /* SECURITY_LINUX */
  112. long EncodeUTCTime (BYTE *pbEncoded, time_t Time, BOOL Writeflag);
  113. #endif /* SECURITY_LINUX */
  114. #ifndef SECURITY_LINUX
  115. long
  116. DecodeFileTime(
  117. FILETIME * pTime,
  118. BYTE * pbEncoded,
  119. DWORD cEncoded,
  120. BOOL WriteFlag);
  121. #else /* SECURITY_LINUX */
  122. long DecodeUTCTime (time_t *pTime, BYTE *pbEncoded, DWORD cEncoded, BOOL Writeflag);
  123. #define DecodeFileTime DecodeUTCTime
  124. #endif /* SECURITY_LINUX */
  125. long
  126. DecodeNull(
  127. BYTE * pbEncoded, DWORD cEncoded);
  128. long
  129. DecodeDN(
  130. PSTR pName,
  131. DWORD * pdwLen,
  132. BYTE * pbEncoded,
  133. DWORD cEncoded,
  134. BOOL WriteFlag);
  135. long
  136. DecodeSigAlg(
  137. DWORD * pAlgId,
  138. PBYTE pbEncoded,
  139. DWORD cEncoded,
  140. BOOL WriteFlag);
  141. long
  142. DecodeCryptAlg(
  143. DWORD * pAlgId,
  144. DWORD * pHashid,
  145. PBYTE pbEncoded,
  146. DWORD cEncoded,
  147. BOOL WriteFlag);
  148. long
  149. DecodeKeyType(
  150. DWORD * pKeyType,
  151. PBYTE pbEncoded,
  152. DWORD cEncoded,
  153. BOOL WriteFlag);
  154. //long
  155. //DecodePrivateKeyFile(
  156. // PctPrivateKey ** ppKey,
  157. // PBYTE pbEncoded,
  158. // DWORD cbEncoded,
  159. // PSTR Password );
  160. #endif /* _ENCODE_H_ */