xref: /curl/lib/curl_sspi.h (revision bca9c771)
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 
27 #include "curl_setup.h"
28 
29 #ifdef USE_WINDOWS_SSPI
30 
31 #include <curl/curl.h>
32 
33 /*
34  * When including the following three headers, it is mandatory to define either
35  * SECURITY_WIN32 or SECURITY_KERNEL, indicating who is compiling the code.
36  */
37 
38 #undef SECURITY_WIN32
39 #undef SECURITY_KERNEL
40 #define SECURITY_WIN32 1
41 #include <security.h>
42 #include <sspi.h>
43 #include <rpc.h>
44 
45 CURLcode Curl_sspi_global_init(void);
46 void Curl_sspi_global_cleanup(void);
47 
48 /* This is used to populate the domain in a SSPI identity structure */
49 CURLcode Curl_override_sspi_http_realm(const char *chlg,
50                                        SEC_WINNT_AUTH_IDENTITY *identity);
51 
52 /* This is used to generate an SSPI identity structure */
53 CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
54                                    SEC_WINNT_AUTH_IDENTITY *identity);
55 
56 /* This is used to free an SSPI identity structure */
57 void Curl_sspi_free_identity(SEC_WINNT_AUTH_IDENTITY *identity);
58 
59 /* Forward-declaration of global variables defined in curl_sspi.c */
60 extern HMODULE Curl_hSecDll;
61 extern PSecurityFunctionTable Curl_pSecFn;
62 
63 /* Provide some definitions missing in old headers */
64 #define SP_NAME_DIGEST              "WDigest"
65 #define SP_NAME_NTLM                "NTLM"
66 #define SP_NAME_NEGOTIATE           "Negotiate"
67 #define SP_NAME_KERBEROS            "Kerberos"
68 
69 #ifndef ISC_REQ_USE_HTTP_STYLE
70 #define ISC_REQ_USE_HTTP_STYLE                0x01000000
71 #endif
72 
73 #ifndef SEC_E_INVALID_PARAMETER
74 # define SEC_E_INVALID_PARAMETER              ((HRESULT)0x8009035DL)
75 #endif
76 #ifndef SEC_E_DELEGATION_POLICY
77 # define SEC_E_DELEGATION_POLICY              ((HRESULT)0x8009035EL)
78 #endif
79 #ifndef SEC_E_POLICY_NLTM_ONLY
80 # define SEC_E_POLICY_NLTM_ONLY               ((HRESULT)0x8009035FL)
81 #endif
82 
83 #ifndef SEC_I_SIGNATURE_NEEDED
84 # define SEC_I_SIGNATURE_NEEDED               ((HRESULT)0x0009035CL)
85 #endif
86 
87 #ifndef CRYPT_E_REVOKED
88 # define CRYPT_E_REVOKED                      ((HRESULT)0x80092010L)
89 #endif
90 
91 #ifndef CRYPT_E_NO_REVOCATION_DLL
92 # define CRYPT_E_NO_REVOCATION_DLL            ((HRESULT)0x80092011L)
93 #endif
94 
95 #ifndef CRYPT_E_NO_REVOCATION_CHECK
96 # define CRYPT_E_NO_REVOCATION_CHECK          ((HRESULT)0x80092012L)
97 #endif
98 
99 #ifndef CRYPT_E_REVOCATION_OFFLINE
100 # define CRYPT_E_REVOCATION_OFFLINE           ((HRESULT)0x80092013L)
101 #endif
102 
103 #ifndef CRYPT_E_NOT_IN_REVOCATION_DATABASE
104 # define CRYPT_E_NOT_IN_REVOCATION_DATABASE   ((HRESULT)0x80092014L)
105 #endif
106 
107 #ifdef UNICODE
108 #  define SECFLAG_WINNT_AUTH_IDENTITY \
109      (unsigned long)SEC_WINNT_AUTH_IDENTITY_UNICODE
110 #else
111 #  define SECFLAG_WINNT_AUTH_IDENTITY \
112      (unsigned long)SEC_WINNT_AUTH_IDENTITY_ANSI
113 #endif
114 
115 /*
116  * Definitions required from ntsecapi.h are directly provided below this point
117  * to avoid including ntsecapi.h due to a conflict with OpenSSL's safestack.h
118  */
119 #define KERB_WRAP_NO_ENCRYPT 0x80000001
120 
121 #endif /* USE_WINDOWS_SSPI */
122 
123 #endif /* HEADER_CURL_SSPI_H */
124