schannel_int.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef HEADER_CURL_SCHANNEL_INT_H
  2. #define HEADER_CURL_SCHANNEL_INT_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Marc Hoersken, <info@marc-hoersken.de>, et al.
  11. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  12. *
  13. * This software is licensed as described in the file COPYING, which
  14. * you should have received as part of this distribution. The terms
  15. * are also available at https://curl.se/docs/copyright.html.
  16. *
  17. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  18. * copies of the Software, and permit persons to whom the Software is
  19. * furnished to do so, under the terms of the COPYING file.
  20. *
  21. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  22. * KIND, either express or implied.
  23. *
  24. * SPDX-License-Identifier: curl
  25. *
  26. ***************************************************************************/
  27. #include "curl_setup.h"
  28. #ifdef USE_SCHANNEL
  29. #if defined(__MINGW32__) || defined(CERT_CHAIN_REVOCATION_CHECK_CHAIN)
  30. #define HAS_MANUAL_VERIFY_API
  31. #endif
  32. #if defined(CryptStringToBinary) && defined(CRYPT_STRING_HEX) \
  33. && !defined(DISABLE_SCHANNEL_CLIENT_CERT)
  34. #define HAS_CLIENT_CERT_PATH
  35. #endif
  36. #ifndef CRYPT_DECODE_NOCOPY_FLAG
  37. #define CRYPT_DECODE_NOCOPY_FLAG 0x1
  38. #endif
  39. #ifndef CRYPT_DECODE_ALLOC_FLAG
  40. #define CRYPT_DECODE_ALLOC_FLAG 0x8000
  41. #endif
  42. #ifndef CERT_ALT_NAME_DNS_NAME
  43. #define CERT_ALT_NAME_DNS_NAME 3
  44. #endif
  45. #ifndef CERT_ALT_NAME_IP_ADDRESS
  46. #define CERT_ALT_NAME_IP_ADDRESS 8
  47. #endif
  48. #ifndef SCH_CREDENTIALS_VERSION
  49. #define SCH_CREDENTIALS_VERSION 0x00000005
  50. typedef enum _eTlsAlgorithmUsage
  51. {
  52. TlsParametersCngAlgUsageKeyExchange,
  53. TlsParametersCngAlgUsageSignature,
  54. TlsParametersCngAlgUsageCipher,
  55. TlsParametersCngAlgUsageDigest,
  56. TlsParametersCngAlgUsageCertSig
  57. } eTlsAlgorithmUsage;
  58. typedef struct _CRYPTO_SETTINGS
  59. {
  60. eTlsAlgorithmUsage eAlgorithmUsage;
  61. UNICODE_STRING strCngAlgId;
  62. DWORD cChainingModes;
  63. PUNICODE_STRING rgstrChainingModes;
  64. DWORD dwMinBitLength;
  65. DWORD dwMaxBitLength;
  66. } CRYPTO_SETTINGS, * PCRYPTO_SETTINGS;
  67. typedef struct _TLS_PARAMETERS
  68. {
  69. DWORD cAlpnIds;
  70. PUNICODE_STRING rgstrAlpnIds;
  71. DWORD grbitDisabledProtocols;
  72. DWORD cDisabledCrypto;
  73. PCRYPTO_SETTINGS pDisabledCrypto;
  74. DWORD dwFlags;
  75. } TLS_PARAMETERS, * PTLS_PARAMETERS;
  76. typedef struct _SCH_CREDENTIALS
  77. {
  78. DWORD dwVersion;
  79. DWORD dwCredFormat;
  80. DWORD cCreds;
  81. PCCERT_CONTEXT* paCred;
  82. HCERTSTORE hRootStore;
  83. DWORD cMappers;
  84. struct _HMAPPER **aphMappers;
  85. DWORD dwSessionLifespan;
  86. DWORD dwFlags;
  87. DWORD cTlsParameters;
  88. PTLS_PARAMETERS pTlsParameters;
  89. } SCH_CREDENTIALS, * PSCH_CREDENTIALS;
  90. #define SCH_CRED_MAX_SUPPORTED_PARAMETERS 16
  91. #define SCH_CRED_MAX_SUPPORTED_ALPN_IDS 16
  92. #define SCH_CRED_MAX_SUPPORTED_CRYPTO_SETTINGS 16
  93. #define SCH_CRED_MAX_SUPPORTED_CHAINING_MODES 16
  94. #endif /* SCH_CREDENTIALS_VERSION */
  95. struct Curl_schannel_cred {
  96. CredHandle cred_handle;
  97. TimeStamp time_stamp;
  98. TCHAR *sni_hostname;
  99. #ifdef HAS_CLIENT_CERT_PATH
  100. HCERTSTORE client_cert_store;
  101. #endif
  102. int refcount;
  103. };
  104. struct Curl_schannel_ctxt {
  105. CtxtHandle ctxt_handle;
  106. TimeStamp time_stamp;
  107. };
  108. struct schannel_ssl_backend_data {
  109. struct Curl_schannel_cred *cred;
  110. struct Curl_schannel_ctxt *ctxt;
  111. SecPkgContext_StreamSizes stream_sizes;
  112. size_t encdata_length, decdata_length;
  113. size_t encdata_offset, decdata_offset;
  114. unsigned char *encdata_buffer, *decdata_buffer;
  115. /* encdata_is_incomplete: if encdata contains only a partial record that
  116. can't be decrypted without another recv() (that is, status is
  117. SEC_E_INCOMPLETE_MESSAGE) then set this true. after an recv() adds
  118. more bytes into encdata then set this back to false. */
  119. bool encdata_is_incomplete;
  120. unsigned long req_flags, ret_flags;
  121. CURLcode recv_unrecoverable_err; /* schannel_recv had an unrecoverable err */
  122. bool recv_sspi_close_notify; /* true if connection closed by close_notify */
  123. bool recv_connection_closed; /* true if connection closed, regardless how */
  124. bool recv_renegotiating; /* true if recv is doing renegotiation */
  125. bool use_alpn; /* true if ALPN is used for this connection */
  126. #ifdef HAS_MANUAL_VERIFY_API
  127. bool use_manual_cred_validation; /* true if manual cred validation is used */
  128. #endif
  129. };
  130. #endif /* USE_SCHANNEL */
  131. #endif /* HEADER_CURL_SCHANNEL_INT_H */