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.

176 lines
6.5 KiB

  1. #ifndef _PROTOCOL_H_
  2. #define _PROTOCOL_H_
  3. typedef struct _SPContext SPContext, *PSPContext;
  4. typedef struct _UNICipherMap {
  5. DWORD CipherKind;
  6. DWORD fProt;
  7. ALG_ID aiHash;
  8. ALG_ID aiCipher;
  9. DWORD dwStrength;
  10. ExchSpec KeyExch;
  11. ALG_ID aiExch;
  12. DWORD dwFlags;
  13. } UNICipherMap, *PUNICipherMap;
  14. // cipher map flag values
  15. #define DOMESTIC_CIPHER_SUITE 0x00000001
  16. #define EXPORT40_CIPHER_SUITE 0x00000002
  17. #define EXPORT56_CIPHER_SUITE 0x00000004
  18. extern DWORD g_ProtEnabled;
  19. extern UNICipherMap UniAvailableCiphers[];
  20. extern DWORD UniNumCiphers;
  21. SP_STATUS WINAPI
  22. ServerProtocolHandler(PSPContext pContext,
  23. PSPBuffer pCommInput,
  24. PSPBuffer pCommOutput);
  25. SP_STATUS WINAPI
  26. ClientProtocolHandler(PSPContext pContext,
  27. PSPBuffer pCommInput,
  28. PSPBuffer pCommOutput);
  29. SP_STATUS
  30. GetSupportedCapiAlgs(
  31. HCRYPTPROV hProv,
  32. PROV_ENUMALGS_EX ** ppAlgInfo,
  33. DWORD * pcAlgInfo);
  34. SP_STATUS WINAPI
  35. GenerateHello(
  36. PSPContext pContext,
  37. PSPBuffer pOutput,
  38. BOOL fCache);
  39. SP_STATUS WINAPI
  40. GenerateUniHello(
  41. PSPContext pContext,
  42. PSPBuffer pOutput,
  43. DWORD fProtocol
  44. );
  45. typedef SP_STATUS ( WINAPI * SPInitiateHelloFn)(
  46. PSPContext pContext,
  47. PSPBuffer pOutput,
  48. BOOL fCache);
  49. typedef SP_STATUS ( WINAPI * SPProtocolHandlerFn)(PSPContext pContext,
  50. PSPBuffer pCommInput,
  51. PSPBuffer pCommOutput);
  52. typedef SP_STATUS ( WINAPI * SPDecryptHandlerFn)(PSPContext pContext,
  53. PSPBuffer pCommInput,
  54. PSPBuffer pAppOutput);
  55. typedef SP_STATUS ( WINAPI * SPDecryptMessageFn)(PSPContext pContext,
  56. PSPBuffer pCommInput,
  57. PSPBuffer pAppOutput);
  58. typedef SP_STATUS ( WINAPI * SPEncryptMessageFn)(PSPContext pContext,
  59. PSPBuffer pAppInput,
  60. PSPBuffer pCommOutput);
  61. typedef SP_STATUS ( WINAPI * SPGetHeaderSizeFn)(PSPContext pContext,
  62. PSPBuffer pCommInput,
  63. DWORD * pcbHeader);
  64. /* State machine states */
  65. #define SP_STATE_NONE 0x00
  66. #define PCT1_STATE_CLIENT_HELLO 0x01
  67. #define PCT1_STATE_SERVER_HELLO 0x02
  68. #define PCT1_STATE_CLIENT_MASTER_KEY 0x03
  69. #define PCT1_STATE_SERVER_VERIFY 0x04
  70. #define PCT1_STATE_ERROR 0x05
  71. #define PCT1_STATE_RENEGOTIATE 0x06
  72. #define SSL2_STATE_CLIENT_HELLO 0x11
  73. #define SSL2_STATE_SERVER_HELLO 0x12
  74. #define SSL2_STATE_CLIENT_MASTER_KEY 0x13
  75. #define SSL2_STATE_CLIENT_FINISH 0x14
  76. #define SSL2_STATE_SERVER_VERIFY 0x15
  77. #define SSL2_STATE_SERVER_FINISH 0x16
  78. #define SSL2_STATE_REQUEST_CERTIFICATE 0x17
  79. #define SSL2_STATE_CLIENT_CERTIFICATE 0x18
  80. #define SSL2_STATE_SERVER_RESTART 0x19
  81. #define SSL2_STATE_CLIENT_RESTART 0x1a
  82. #define SSL3_STATE_CLIENT_HELLO 0x1b
  83. #define SSL3_STATE_CHANGE_CIPHER_SPEC 0x1c
  84. #define SSL3_STATE_RESTART_CCS 0x1d
  85. #define SSL3_STATE_RESTART_SERVER_FINISH 0x1e
  86. #define SSL3_STATE_SERVER_FINISH 0x1f
  87. #define UNI_STATE_RECVD_UNIHELLO 0xfe
  88. #define UNI_STATE_CLIENT_HELLO 0xff
  89. #define SSL3_STATE_CLIENT_FINISH 0x21
  90. #define SSL3_STATE_RESTART_CLI_FINISH 0x22
  91. #define SSL3_STATE_REDO_RESTART 0x24
  92. #define SSL3_STATE_SERVER_CERTIFICATE 0x25
  93. #define SSL3_STATE_SERVER_KEY_XCHANGE 0x26
  94. #define SSL3_STATE_SERVER_CERTREQ 0x27
  95. #define SSL3_STATE_SERVER_HELLO 0x29
  96. #define SSL3_STATE_CLIENT_KEY_XCHANGE 0x31
  97. #define SSL3_STATE_CERT_VERIFY 0x32
  98. #define SSL3_STATE_FINISHED 0x33
  99. #define SSL3_STATE_RESTART_SER_HELLO 0x36
  100. #define SSL3_STATE_SER_RESTART_CHANGE_CIPHER_SPEC 0x37
  101. #define SSL3_STATE_CHANGE_CIPHER_SPEC_CLIENT 0x38
  102. #define SSL3_STATE_CHANGE_CIPHER_SPEC_SERVER 0x39
  103. #define SSL3_STATE_NO_CERT_ALERT 0x3a
  104. #define SSL3_STATE_RENEGOTIATE 0x3b
  105. #define SSL3_STATE_SGC_CERTIFICATE 0x3c
  106. //these defines must not be touched... Please do not in this section...
  107. // PROTECTED BY SSL3 SPECEFIC states
  108. #define SSL3_STATE_GEN_START 0x80
  109. #define SSL3_STATE_GEN_SERVER_HELLORESP (SSL3_STATE_GEN_START + 1)
  110. #define SSL3_STATE_GEN_SERVER_HELLO (SSL3_STATE_GEN_START + 2)
  111. #define SSL3_STATE_GEN_SERVER_HELLO_RESTART (SSL3_STATE_GEN_START + 3)
  112. #define SSL3_STATE_GEN_SERVER_FINISH (SSL3_STATE_GEN_START + 4)
  113. #define SSL3_STATE_GEN_CLIENT_FINISH (SSL3_STATE_GEN_START + 5)
  114. #define SSL3_STATE_GEN_REDO (SSL3_STATE_GEN_START + 6)
  115. #define SSL3_STATE_GEN_HELLO_REQUEST (SSL3_STATE_GEN_START + 7)
  116. #define SSL3_STATE_CONNECTED_SERVER (SSL3_STATE_GEN_START + 8)
  117. #define TLS1_STATE_ERROR (SSL3_STATE_GEN_START + 9)
  118. #define SSL3_STATE_GEN_END (SSL3_STATE_GEN_START + 10)
  119. //PROTECTED AREA ENDS.................
  120. #define SP_STATE_SHUTDOWN_PENDING 0x0000fffd // We're building a CloseNotify alert.
  121. #define SP_STATE_SHUTDOWN 0x0000fffe // We're shutting down.
  122. #define SP_STATE_CONNECTED 0x0000ffff /* We are connected, and are
  123. * expecting data packets, otherwise
  124. * we are performing a protocol
  125. * negotiation lower word contains
  126. * last message sent, implying what
  127. * the next word will be */
  128. // UNIHELLO codes.
  129. #define PCT_SSL_COMPAT 0x8f
  130. #define PCT_SSL_CERT_TYPE 0x80
  131. #define PCT_SSL_HASH_TYPE 0x81
  132. #define PCT_SSL_EXCH_TYPE 0x82
  133. #define PCT_SSL_CIPHER_TYPE_1ST_HALF 0x83
  134. #define PCT_SSL_CIPHER_TYPE_2ND_HALF 0x84
  135. #define UNI_CK_PCT SSL_MKFAST(PCT_SSL_COMPAT, MSBOF(PCT_VERSION_1), LSBOF(PCT_VERSION_1))
  136. #define PCT_SSL_CERT_X509 SSL_MKFAST(0x80, 0x00, 0x00)
  137. #define PCT_SSL_CERT_PKCS7 SSL_MKFAST(0x80, 0x00, 0x01)
  138. #endif /* _PROTOCOL_H_ */