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.

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