curl_sspi.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef HEADER_CURL_SSPI_H
  2. #define HEADER_CURL_SSPI_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #include "curl_setup.h"
  27. #ifdef USE_WINDOWS_SSPI
  28. #include <curl/curl.h>
  29. /*
  30. * When including the following three headers, it is mandatory to define either
  31. * SECURITY_WIN32 or SECURITY_KERNEL, indicating who is compiling the code.
  32. */
  33. #undef SECURITY_WIN32
  34. #undef SECURITY_KERNEL
  35. #define SECURITY_WIN32 1
  36. #include <security.h>
  37. #include <sspi.h>
  38. #include <rpc.h>
  39. CURLcode Curl_sspi_global_init(void);
  40. void Curl_sspi_global_cleanup(void);
  41. /* This is used to populate the domain in a SSPI identity structure */
  42. CURLcode Curl_override_sspi_http_realm(const char *chlg,
  43. SEC_WINNT_AUTH_IDENTITY *identity);
  44. /* This is used to generate an SSPI identity structure */
  45. CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
  46. SEC_WINNT_AUTH_IDENTITY *identity);
  47. /* This is used to free an SSPI identity structure */
  48. void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY *identity);
  49. /* Forward-declaration of global variables defined in curl_sspi.c */
  50. extern HMODULE s_hSecDll;
  51. extern PSecurityFunctionTable s_pSecFn;
  52. /* Provide some definitions missing in old headers */
  53. #define SP_NAME_DIGEST "WDigest"
  54. #define SP_NAME_NTLM "NTLM"
  55. #define SP_NAME_NEGOTIATE "Negotiate"
  56. #define SP_NAME_KERBEROS "Kerberos"
  57. #ifndef ISC_REQ_USE_HTTP_STYLE
  58. #define ISC_REQ_USE_HTTP_STYLE 0x01000000
  59. #endif
  60. #ifndef SEC_E_INVALID_PARAMETER
  61. # define SEC_E_INVALID_PARAMETER ((HRESULT)0x8009035DL)
  62. #endif
  63. #ifndef SEC_E_DELEGATION_POLICY
  64. # define SEC_E_DELEGATION_POLICY ((HRESULT)0x8009035EL)
  65. #endif
  66. #ifndef SEC_E_POLICY_NLTM_ONLY
  67. # define SEC_E_POLICY_NLTM_ONLY ((HRESULT)0x8009035FL)
  68. #endif
  69. #ifndef SEC_I_SIGNATURE_NEEDED
  70. # define SEC_I_SIGNATURE_NEEDED ((HRESULT)0x0009035CL)
  71. #endif
  72. #ifndef CRYPT_E_REVOKED
  73. # define CRYPT_E_REVOKED ((HRESULT)0x80092010L)
  74. #endif
  75. #ifdef UNICODE
  76. # define SECFLAG_WINNT_AUTH_IDENTITY \
  77. (unsigned long)SEC_WINNT_AUTH_IDENTITY_UNICODE
  78. #else
  79. # define SECFLAG_WINNT_AUTH_IDENTITY \
  80. (unsigned long)SEC_WINNT_AUTH_IDENTITY_ANSI
  81. #endif
  82. /*
  83. * Definitions required from ntsecapi.h are directly provided below this point
  84. * to avoid including ntsecapi.h due to a conflict with OpenSSL's safestack.h
  85. */
  86. #define KERB_WRAP_NO_ENCRYPT 0x80000001
  87. #endif /* USE_WINDOWS_SSPI */
  88. #endif /* HEADER_CURL_SSPI_H */