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.

341 lines
10 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 __PCT1MSG_H__
  34. #define __PCT1MSG_H__
  35. #define PCT_CH_OFFSET_V1 (WORD)10
  36. #define PCT_VERSION_1 (WORD)0x8001
  37. /* message type codes */
  38. #define PCT1_MSG_NOMSG 0x00
  39. #define PCT1_MSG_CLIENT_HELLO 0x01
  40. #define PCT1_MSG_SERVER_HELLO 0x02
  41. #define PCT1_MSG_CLIENT_MASTER_KEY 0x03
  42. #define PCT1_MSG_SERVER_VERIFY 0x04
  43. #define PCT1_MSG_ERROR 0x05
  44. #define PCT1_ET_OOB_DATA 0x01
  45. #define PCT1_ET_REDO_CONN 0x02
  46. #define PCT1_SESSION_ID_SIZE 32
  47. #define PCT1_CHALLENGE_SIZE 32
  48. #define PCT1_MASTER_KEY_SIZE 16
  49. #define PCT1_RESPONSE_SIZE 32
  50. #define PCT1_MAX_MESSAGE_LENGTH 0x3f00
  51. #define PCT1_MAX_CLIENT_HELLO 256
  52. #define PCT1_CERT_TYPE_FROM_CAPI2(s) X509_ASN_ENCODING
  53. /*
  54. *
  55. * Useful Macros
  56. *
  57. */
  58. #define LSBOF(x) ((UCHAR) ((x) & 0xFF))
  59. #define MSBOF(x) ((UCHAR) (((x) >> 8) & 0xFF) )
  60. #define COMBINEBYTES(Msb, Lsb) ((DWORD) (((DWORD) (Msb) << 8) | (DWORD) (Lsb)))
  61. /* external representations of algorithm specs */
  62. typedef DWORD ExtCipherSpec, *PExtCipherSpec;
  63. typedef WORD ExtHashSpec, *PExtHashSpec;
  64. typedef WORD ExtCertSpec, *PExtCertSpec;
  65. typedef WORD ExtExchSpec, *PExtExchSpec;
  66. typedef WORD ExtSigSpec, *PExtSigSpec;
  67. typedef struct _Pct1CipherMap
  68. {
  69. ALG_ID aiCipher;
  70. DWORD dwStrength;
  71. CipherSpec Spec;
  72. } Pct1CipherMap, *PPct1CipherMap;
  73. typedef struct _Pct1HashMap
  74. {
  75. ALG_ID aiHash;
  76. CipherSpec Spec;
  77. } Pct1HashMap, *PPct1HashMap;
  78. extern Pct1CipherMap Pct1CipherRank[];
  79. extern DWORD Pct1NumCipher;
  80. /* available hashes, in order of preference */
  81. extern Pct1HashMap Pct1HashRank[];
  82. extern DWORD Pct1NumHash;
  83. extern CertTypeMap aPct1CertEncodingPref[];
  84. extern DWORD cPct1CertEncodingPref;
  85. extern KeyTypeMap aPct1LocalExchKeyPref[];
  86. extern DWORD cPct1LocalExchKeyPref;
  87. extern KeyTypeMap aPct1LocalSigKeyPref[];
  88. extern DWORD cPct1LocalSigKeyPref;
  89. typedef struct _PCT1_MESSAGE_HEADER {
  90. UCHAR Byte0;
  91. UCHAR Byte1;
  92. } PCT1_MESSAGE_HEADER, * PPCT1_MESSAGE_HEADER;
  93. typedef struct _PCT1_MESSAGE_HEADER_EX {
  94. UCHAR Byte0;
  95. UCHAR Byte1;
  96. UCHAR PaddingSize;
  97. } PCT1_MESSAGE_HEADER_EX, * PPCT1_MESSAGE_HEADER_EX;
  98. typedef struct _PCT1_ERROR {
  99. PCT1_MESSAGE_HEADER Header;
  100. UCHAR MessageId;
  101. UCHAR ErrorMsb;
  102. UCHAR ErrorLsb;
  103. UCHAR ErrorInfoMsb;
  104. UCHAR ErrorInfoLsb;
  105. UCHAR VariantData[1];
  106. } PCT1_ERROR, * PPCT1_ERROR;
  107. typedef struct _PCT1_CLIENT_HELLO {
  108. PCT1_MESSAGE_HEADER Header;
  109. UCHAR MessageId;
  110. UCHAR VersionMsb;
  111. UCHAR VersionLsb;
  112. UCHAR Pad;
  113. UCHAR SessionIdData[PCT1_SESSION_ID_SIZE];
  114. UCHAR ChallengeData[PCT1_CHALLENGE_SIZE];
  115. UCHAR OffsetMsb;
  116. UCHAR OffsetLsb;
  117. UCHAR CipherSpecsLenMsb;
  118. UCHAR CipherSpecsLenLsb;
  119. UCHAR HashSpecsLenMsb;
  120. UCHAR HashSpecsLenLsb;
  121. UCHAR CertSpecsLenMsb;
  122. UCHAR CertSpecsLenLsb;
  123. UCHAR ExchSpecsLenMsb;
  124. UCHAR ExchSpecsLenLsb;
  125. UCHAR KeyArgLenMsb;
  126. UCHAR KeyArgLenLsb;
  127. UCHAR VariantData[1];
  128. } PCT1_CLIENT_HELLO, * PPCT1_CLIENT_HELLO;
  129. typedef struct _PCT1_SERVER_HELLO {
  130. PCT1_MESSAGE_HEADER Header;
  131. UCHAR MessageId;
  132. UCHAR Pad;
  133. UCHAR ServerVersionMsb;
  134. UCHAR ServerVersionLsb;
  135. UCHAR RestartSessionOK;
  136. UCHAR ClientAuthReq;
  137. ExtCipherSpec CipherSpecData;
  138. ExtHashSpec HashSpecData;
  139. ExtCertSpec CertSpecData;
  140. ExtExchSpec ExchSpecData;
  141. UCHAR ConnectionIdData[PCT1_SESSION_ID_SIZE];
  142. UCHAR CertificateLenMsb;
  143. UCHAR CertificateLenLsb;
  144. UCHAR CertSpecsLenMsb;
  145. UCHAR CertSpecsLenLsb;
  146. UCHAR ClientSigSpecsLenMsb;
  147. UCHAR ClientSigSpecsLenLsb;
  148. UCHAR ResponseLenMsb;
  149. UCHAR ResponseLenLsb;
  150. UCHAR VariantData[1];
  151. } PCT1_SERVER_HELLO, * PPCT1_SERVER_HELLO;
  152. typedef struct _PCT1_CLIENT_MASTER_KEY {
  153. PCT1_MESSAGE_HEADER Header;
  154. UCHAR MessageId;
  155. UCHAR Pad;
  156. ExtCertSpec ClientCertSpecData;
  157. ExtSigSpec ClientSigSpecData;
  158. UCHAR ClearKeyLenMsb;
  159. UCHAR ClearKeyLenLsb;
  160. UCHAR EncryptedKeyLenMsb;
  161. UCHAR EncryptedKeyLenLsb;
  162. UCHAR KeyArgLenMsb;
  163. UCHAR KeyArgLenLsb;
  164. UCHAR VerifyPreludeLenMsb;
  165. UCHAR VerifyPreludeLenLsb;
  166. UCHAR ClientCertLenMsb;
  167. UCHAR ClientCertLenLsb;
  168. UCHAR ResponseLenMsb;
  169. UCHAR ResponseLenLsb;
  170. UCHAR VariantData[1];
  171. } PCT1_CLIENT_MASTER_KEY, * PPCT1_CLIENT_MASTER_KEY;
  172. typedef struct _PCT1_SERVER_VERIFY {
  173. PCT1_MESSAGE_HEADER Header;
  174. UCHAR MessageId;
  175. UCHAR Pad;
  176. UCHAR SessionIdData[PCT1_SESSION_ID_SIZE];
  177. UCHAR ResponseLenMsb;
  178. UCHAR ResponseLenLsb;
  179. UCHAR VariantData[1];
  180. } PCT1_SERVER_VERIFY, * PPCT1_SERVER_VERIFY;
  181. /*
  182. *
  183. * Expanded Form Messages:
  184. *
  185. */
  186. typedef struct _Pct1_Error {
  187. DWORD Error;
  188. DWORD ErrInfoLen;
  189. BYTE *ErrInfo;
  190. } Pct1Error, *PPct1_Error;
  191. typedef struct _Pct1_Client_Hello {
  192. DWORD cCipherSpecs;
  193. DWORD cHashSpecs;
  194. DWORD cCertSpecs;
  195. DWORD cExchSpecs;
  196. DWORD cbKeyArgSize;
  197. DWORD cbSessionID;
  198. DWORD cbChallenge;
  199. PUCHAR pKeyArg;
  200. CipherSpec * pCipherSpecs;
  201. HashSpec * pHashSpecs;
  202. CertSpec * pCertSpecs;
  203. ExchSpec * pExchSpecs;
  204. UCHAR SessionID[PCT1_SESSION_ID_SIZE];
  205. UCHAR Challenge[PCT1_CHALLENGE_SIZE];
  206. } Pct1_Client_Hello, * PPct1_Client_Hello;
  207. typedef struct _Pct1_Server_Hello {
  208. DWORD RestartOk;
  209. DWORD ClientAuthReq;
  210. DWORD CertificateLen;
  211. DWORD ResponseLen;
  212. DWORD cSigSpecs;
  213. DWORD cCertSpecs;
  214. DWORD cbConnectionID;
  215. UCHAR * pCertificate;
  216. CipherSpec SrvCipherSpec;
  217. HashSpec SrvHashSpec;
  218. CertSpec SrvCertSpec;
  219. ExchSpec SrvExchSpec;
  220. SigSpec * pClientSigSpecs;
  221. CertSpec * pClientCertSpecs;
  222. UCHAR ConnectionID[PCT1_SESSION_ID_SIZE];
  223. UCHAR Response[PCT1_RESPONSE_SIZE];
  224. } Pct1_Server_Hello, * PPct1_Server_Hello;
  225. typedef struct _Pct1_Client_Master_Key {
  226. DWORD ClearKeyLen;
  227. DWORD EncryptedKeyLen;
  228. DWORD KeyArgLen;
  229. DWORD VerifyPreludeLen;
  230. DWORD ClientCertLen;
  231. DWORD ResponseLen;
  232. CertSpec ClientCertSpec;
  233. SigSpec ClientSigSpec;
  234. UCHAR ClearKey[PCT1_MASTER_KEY_SIZE];
  235. PBYTE pbEncryptedKey;
  236. UCHAR KeyArg[PCT1_MASTER_KEY_SIZE];
  237. PUCHAR pClientCert;
  238. PBYTE pbResponse;
  239. UCHAR VerifyPrelude[PCT1_RESPONSE_SIZE];
  240. } Pct1_Client_Master_Key, * PPct1_Client_Master_Key;
  241. typedef struct _Pct1_Server_Verify {
  242. UCHAR SessionIdData[PCT1_SESSION_ID_SIZE];
  243. DWORD ResponseLen;
  244. UCHAR Response[PCT1_RESPONSE_SIZE];
  245. } Pct1_Server_Verify, * PPct1_Server_Verify;
  246. /*
  247. *
  248. * Pickling Prototypes
  249. *
  250. */
  251. SP_STATUS
  252. Pct1PackClientHello(
  253. PPct1_Client_Hello pCanonical,
  254. PSPBuffer pCommOutput);
  255. SP_STATUS
  256. Pct1UnpackClientHello(
  257. PSPBuffer pInput,
  258. PPct1_Client_Hello * ppClient);
  259. SP_STATUS
  260. Pct1PackServerHello(
  261. PPct1_Server_Hello pCanonical,
  262. PSPBuffer pCommOutput);
  263. SP_STATUS
  264. Pct1UnpackServerHello(
  265. PSPBuffer pInput,
  266. PPct1_Server_Hello * ppServer);
  267. SP_STATUS
  268. Pct1PackClientMasterKey(
  269. PPct1_Client_Master_Key pCanonical,
  270. PSPBuffer pCommOutput);
  271. SP_STATUS
  272. Pct1UnpackClientMasterKey(
  273. PSPBuffer pInput,
  274. PPct1_Client_Master_Key * ppClient);
  275. SP_STATUS
  276. Pct1PackServerVerify(
  277. PPct1_Server_Verify pCanonical,
  278. PSPBuffer pCommOutput);
  279. SP_STATUS
  280. Pct1UnpackServerVerify(
  281. PSPBuffer pInput,
  282. PPct1_Server_Verify * ppServer);
  283. SP_STATUS
  284. Pct1PackError(
  285. PPct1_Error pCanonical,
  286. PSPBuffer pCommOutput);
  287. #endif /* __PCT1MSG_H__ */