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.

301 lines
7.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ssl3msg.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 8-02-95 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __SSL3MSG_H__
  18. #define __SSL3MSG_H__
  19. #define CB_SSL3_CHANGE_CIPHER_SPEC (sizeof(SWRAP) + 1)
  20. #define CB_SSL3_CHANGE_CIPHER_SPEC_ONLY 1
  21. #define CB_SSL3_FINISHED_MSG (sizeof(FMWIRE))
  22. #define CB_SSL3_FINISHED_MSG_ONLY (sizeof(SHSH) + CB_MD5_DIGEST_LEN + CB_SHA_DIGEST_LEN)
  23. #define CB_SSL3_ALERT (sizeof(SWRAP) +2)
  24. #define CB_SSL3_ALERT_ONLY 2
  25. #define SSL3_CHANGE_CIPHER_MSG { 0x14, 0x03, 0x00, 0x00, 0x01, 0x01 }
  26. #define FSsl3CipherClient() (0 != pContext->wS3CipherSuiteClient)
  27. #define FSsl3CipherServer() (0 != pContext->wS3CipherSuiteServer)
  28. #define FSsl3Cipher(fClient) ((fClient ? pContext->wS3CipherSuiteClient : pContext->wS3CipherSuiteServer))
  29. #define MS24BOF(x) ((UCHAR) ((x >> 16) & 0xFF) )
  30. #define CHECK_PCT_RET_BREAK(Ret) if(PCT_ERR_OK != Ret) \
  31. { \
  32. LOG_RESULT(Ret); \
  33. break; \
  34. }
  35. typedef struct _OIDPROVMAP
  36. {
  37. LPSTR szOid;
  38. DWORD dwExchSpec;
  39. DWORD dwCertType; // used for SSL 3.0 client auth
  40. } OIDPROVMAP, *POIDPROVMAP;
  41. extern OIDPROVMAP g_CertTypes[];
  42. extern DWORD g_cCertTypes;
  43. typedef struct _shsh //Structure hand shake header
  44. {
  45. UCHAR typHS;
  46. UCHAR bcb24;
  47. UCHAR bcbMSB;
  48. UCHAR bcbLSB;
  49. } SHSH;
  50. typedef struct _swrap
  51. {
  52. UCHAR bCType;
  53. UCHAR bMajor;
  54. UCHAR bMinor;
  55. UCHAR bcbMSBSize;
  56. UCHAR bcbLSBSize;
  57. // UCHAR rgb[];
  58. } SWRAP;
  59. typedef struct _ssh
  60. {
  61. SHSH;
  62. UCHAR bMajor;
  63. UCHAR bMinor;
  64. UCHAR rgbRandom[CB_SSL3_RANDOM];
  65. UCHAR cbSessionId;
  66. UCHAR rgbSessionId[CB_SSL3_SESSION_ID];
  67. UCHAR wCipherSelectedMSB;
  68. UCHAR wCipherSelectedLSB;
  69. UCHAR bCMSelected;
  70. } SSH;
  71. typedef struct _alrt
  72. {
  73. SWRAP;
  74. UCHAR bAlertLevel;
  75. UCHAR bAlertDesc;
  76. } ALRT;
  77. typedef struct _fm
  78. {
  79. UCHAR rgbMD5[CB_MD5_DIGEST_LEN];
  80. UCHAR rgbSHA[CB_SHA_DIGEST_LEN];
  81. } FM; //finished message
  82. typedef struct _fmwire
  83. {
  84. SWRAP;
  85. SHSH;
  86. FM;
  87. } FMWIRE;
  88. typedef struct _cert
  89. {
  90. SHSH;
  91. UCHAR bcbClist24;
  92. UCHAR bcbMSBClist;
  93. UCHAR bcbLSBClist;
  94. UCHAR bcbCert24;
  95. UCHAR bcbMSBCert;
  96. UCHAR bcbLSBCert;
  97. UCHAR rgbCert[];
  98. /* followed by the real cert */
  99. } CERT;
  100. typedef struct _shwire
  101. {
  102. PUCHAR pcbCipher;
  103. PUCHAR pCiperSpec;
  104. PUCHAR pcbCompM;
  105. PUCHAR pCompM;
  106. PUCHAR pcbCert;
  107. PUCHAR pCert;
  108. PUCHAR pHelloDone;
  109. } SHWIRE ;
  110. SP_STATUS WINAPI
  111. Ssl3DecryptHandler(
  112. PSPContext pContext,
  113. PSPBuffer pCommInput,
  114. PSPBuffer pAppOutput);
  115. SP_STATUS WINAPI
  116. Ssl3GetHeaderSize(
  117. PSPContext pContext,
  118. PSPBuffer pCommInput,
  119. DWORD * pcbHeaderSize);
  120. SP_STATUS WINAPI
  121. GenerateSsl3ClientHello(
  122. PSPContext pContext,
  123. PSPBuffer pOutput);
  124. SP_STATUS WINAPI
  125. GenerateTls1ClientHello(
  126. PSPContext pContext,
  127. PSPBuffer pOutput,
  128. DWORD dwProtocol);
  129. SP_STATUS
  130. Ssl3PackClientHello(PSPContext pContext,
  131. PSsl2_Client_Hello pCanonical,
  132. PSPBuffer pCommOutput);
  133. SP_STATUS Ssl3CliHandleServerHello(PSPContext pContext,
  134. PUCHAR pSrvHello,
  135. DWORD cbMessage,
  136. PSPBuffer pCommOutput);
  137. SP_STATUS Ssl3HandleServerFinish(PSPContext pContext,
  138. PUCHAR pSrvHello );
  139. SP_STATUS Ssl3SrvHandleCMKey(PSPContext pContext,
  140. PUCHAR pCommInput,
  141. DWORD cbMsg,
  142. PSPBuffer pCommOutput);
  143. BOOL FVerifyFinishedMessage(PSPContext pContext, PUCHAR pb, BOOL fClient);
  144. SP_STATUS
  145. ParseAlertMessage(
  146. PSPContext pContext,
  147. PUCHAR pSrvHello,
  148. DWORD cbMessage);
  149. SP_STATUS
  150. Ssl3SelectCipher (
  151. PSPContext pContext,
  152. WORD wCipher
  153. );
  154. SP_STATUS
  155. Ssl3SelectCipherEx(
  156. PSPContext pContext,
  157. DWORD *pCipherSpecs,
  158. DWORD cCipherSpecs);
  159. void BuildAlertMessage(PBYTE pb, UCHAR bAlertLevel, UCHAR bAlertDesc);
  160. SP_STATUS
  161. Ssl3BuildFinishMessage(
  162. PSPContext pContext,
  163. BYTE *pbMd5Digest,
  164. BYTE *pbSHADigest,
  165. BOOL fClient);
  166. SP_STATUS
  167. Tls1BuildFinishMessage(
  168. PSPContext pContext, // in
  169. PBYTE pbVerifyData, // out
  170. DWORD cbVerifyData, // in
  171. BOOL fClient); // in
  172. SP_STATUS
  173. SPSetWrap(PSPContext pContext, PUCHAR pb, UCHAR bCType, DWORD wT, BOOL fClient, DWORD *pcbMessage);
  174. void SetHandshake(PUCHAR pb, BYTE bHandshake, PUCHAR pbData, DWORD dwSize);
  175. SP_STATUS
  176. UpdateHandshakeHash(
  177. PSPContext pContext,
  178. PUCHAR pb,
  179. DWORD dwcb,
  180. BOOL fInit);
  181. SP_STATUS
  182. SPBuildS3FinalFinish(PSPContext pContext, PSPBuffer pBuffer, BOOL fClient);
  183. SP_STATUS
  184. VerifyCCSAndFinishMsg(PSPContext pContext, PBYTE pbMsg, DWORD cbMessage, BOOL fClient);
  185. SP_STATUS
  186. Ssl3ComputeCertVerifyHashes(
  187. PSPContext pContext, // in
  188. PBYTE pbMD5, // out
  189. PBYTE pbSHA); // out
  190. SP_STATUS
  191. Tls1ComputeCertVerifyHashes(
  192. PSPContext pContext, // in
  193. PBYTE pbMD5, // out
  194. PBYTE pbSHA); // out
  195. void BuildCertificateMessage(PBYTE pb, PBYTE rgbCert, DWORD dwCert);
  196. SP_STATUS
  197. BuildCCSAndFinishMessage(
  198. PSPContext pContext,
  199. PSPBuffer pBuffer,
  200. BOOL fClient);
  201. VOID ComputeServerExchangeHashes(
  202. PSPContext pContext,
  203. PBYTE pbServerParams, // in
  204. INT iServerParamsLen, // in
  205. PBYTE pbMd5HashVal, // out
  206. PBYTE pbShaHashVal) ; // out
  207. DWORD Ssl3CiphertextLen(
  208. PSPContext pContext,
  209. DWORD cbMessage,
  210. BOOL fClientIsSender);
  211. SP_STATUS
  212. UnwrapSsl3Message(
  213. PSPContext pContext,
  214. PSPBuffer MsgInput);
  215. void SetWrapNoEncrypt(PUCHAR pb, UCHAR bCType, DWORD wT);
  216. SP_STATUS Ssl3HandleCCS(PSPContext pContext,
  217. PUCHAR pb,
  218. DWORD cbMessage);
  219. SP_STATUS
  220. VerifyFinishMsg(PSPContext pContext, PBYTE pbMsg, DWORD cbMessage, BOOL fClient);
  221. BOOL Ssl3ParseClientHello(
  222. PSPContext pContext,
  223. PBYTE pbMessage,
  224. DWORD cbMessage,
  225. BOOL fAttemptRestart,
  226. BOOL * pfRestart);
  227. SP_STATUS
  228. SPBuildTlsAlertMessage(
  229. PSPContext pContext,
  230. PSPBuffer pCommOutput);
  231. void
  232. SetTls1Alert(
  233. PSPContext pContext,
  234. BYTE bAlertLevel,
  235. BYTE bAlertNumber);
  236. SP_STATUS
  237. Ssl3CheckForExistingCred(PSPContext pContext);
  238. #endif //__SSL3MSG_H__