quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl_sspi.h (12653B)


      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 an 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 PSecurityFunctionTable Curl_pSecFn;
     61 
     62 /* Provide some definitions missing in old headers */
     63 #define SP_NAME_DIGEST              "WDigest"
     64 #define SP_NAME_NTLM                "NTLM"
     65 #define SP_NAME_NEGOTIATE           "Negotiate"
     66 #define SP_NAME_KERBEROS            "Kerberos"
     67 
     68 #ifndef ISC_REQ_USE_HTTP_STYLE
     69 #define ISC_REQ_USE_HTTP_STYLE                0x01000000
     70 #endif
     71 
     72 #ifdef __MINGW32CE__
     73 #ifndef ISC_RET_REPLAY_DETECT
     74 #define ISC_RET_REPLAY_DETECT                 0x00000004
     75 #endif
     76 #ifndef ISC_RET_SEQUENCE_DETECT
     77 #define ISC_RET_SEQUENCE_DETECT               0x00000008
     78 #endif
     79 #ifndef ISC_RET_CONFIDENTIALITY
     80 #define ISC_RET_CONFIDENTIALITY               0x00000010
     81 #endif
     82 #ifndef ISC_RET_ALLOCATED_MEMORY
     83 #define ISC_RET_ALLOCATED_MEMORY              0x00000100
     84 #endif
     85 #ifndef ISC_RET_STREAM
     86 #define ISC_RET_STREAM                        0x00008000
     87 #endif
     88 
     89 #ifndef SEC_E_INSUFFICIENT_MEMORY
     90 #define SEC_E_INSUFFICIENT_MEMORY             ((HRESULT)0x80090300L)
     91 #endif
     92 #ifndef SEC_E_INVALID_HANDLE
     93 #define SEC_E_INVALID_HANDLE                  ((HRESULT)0x80090301L)
     94 #endif
     95 #ifndef SEC_E_UNSUPPORTED_FUNCTION
     96 #define SEC_E_UNSUPPORTED_FUNCTION            ((HRESULT)0x80090302L)
     97 #endif
     98 #ifndef SEC_E_TARGET_UNKNOWN
     99 #define SEC_E_TARGET_UNKNOWN                  ((HRESULT)0x80090303L)
    100 #endif
    101 #ifndef SEC_E_INTERNAL_ERROR
    102 #define SEC_E_INTERNAL_ERROR                  ((HRESULT)0x80090304L)
    103 #endif
    104 #ifndef SEC_E_SECPKG_NOT_FOUND
    105 #define SEC_E_SECPKG_NOT_FOUND                ((HRESULT)0x80090305L)
    106 #endif
    107 #ifndef SEC_E_NOT_OWNER
    108 #define SEC_E_NOT_OWNER                       ((HRESULT)0x80090306L)
    109 #endif
    110 #ifndef SEC_E_CANNOT_INSTALL
    111 #define SEC_E_CANNOT_INSTALL                  ((HRESULT)0x80090307L)
    112 #endif
    113 #ifndef SEC_E_INVALID_TOKEN
    114 #define SEC_E_INVALID_TOKEN                   ((HRESULT)0x80090308L)
    115 #endif
    116 #ifndef SEC_E_CANNOT_PACK
    117 #define SEC_E_CANNOT_PACK                     ((HRESULT)0x80090309L)
    118 #endif
    119 #ifndef SEC_E_QOP_NOT_SUPPORTED
    120 #define SEC_E_QOP_NOT_SUPPORTED               ((HRESULT)0x8009030AL)
    121 #endif
    122 #ifndef SEC_E_NO_IMPERSONATION
    123 #define SEC_E_NO_IMPERSONATION                ((HRESULT)0x8009030BL)
    124 #endif
    125 #ifndef SEC_E_LOGON_DENIED
    126 #define SEC_E_LOGON_DENIED                    ((HRESULT)0x8009030CL)
    127 #endif
    128 #ifndef SEC_E_UNKNOWN_CREDENTIALS
    129 #define SEC_E_UNKNOWN_CREDENTIALS             ((HRESULT)0x8009030DL)
    130 #endif
    131 #ifndef SEC_E_NO_CREDENTIALS
    132 #define SEC_E_NO_CREDENTIALS                  ((HRESULT)0x8009030EL)
    133 #endif
    134 #ifndef SEC_E_MESSAGE_ALTERED
    135 #define SEC_E_MESSAGE_ALTERED                 ((HRESULT)0x8009030FL)
    136 #endif
    137 #ifndef SEC_E_OUT_OF_SEQUENCE
    138 #define SEC_E_OUT_OF_SEQUENCE                 ((HRESULT)0x80090310L)
    139 #endif
    140 #ifndef SEC_E_NO_AUTHENTICATING_AUTHORITY
    141 #define SEC_E_NO_AUTHENTICATING_AUTHORITY     ((HRESULT)0x80090311L)
    142 #endif
    143 #ifndef SEC_E_BAD_PKGID
    144 #define SEC_E_BAD_PKGID                       ((HRESULT)0x80090316L)
    145 #endif
    146 #ifndef SEC_E_CONTEXT_EXPIRED
    147 #define SEC_E_CONTEXT_EXPIRED                 ((HRESULT)0x80090317L)
    148 #endif
    149 #ifndef SEC_E_INCOMPLETE_MESSAGE
    150 #define SEC_E_INCOMPLETE_MESSAGE              ((HRESULT)0x80090318L)
    151 #endif
    152 #ifndef SEC_E_INCOMPLETE_CREDENTIALS
    153 #define SEC_E_INCOMPLETE_CREDENTIALS          ((HRESULT)0x80090320L)
    154 #endif
    155 #ifndef SEC_E_BUFFER_TOO_SMALL
    156 #define SEC_E_BUFFER_TOO_SMALL                ((HRESULT)0x80090321L)
    157 #endif
    158 #ifndef SEC_E_WRONG_PRINCIPAL
    159 #define SEC_E_WRONG_PRINCIPAL                 ((HRESULT)0x80090322L)
    160 #endif
    161 #ifndef SEC_E_TIME_SKEW
    162 #define SEC_E_TIME_SKEW                       ((HRESULT)0x80090324L)
    163 #endif
    164 #ifndef SEC_E_UNTRUSTED_ROOT
    165 #define SEC_E_UNTRUSTED_ROOT                  ((HRESULT)0x80090325L)
    166 #endif
    167 #ifndef SEC_E_ILLEGAL_MESSAGE
    168 #define SEC_E_ILLEGAL_MESSAGE                 ((HRESULT)0x80090326L)
    169 #endif
    170 #ifndef SEC_E_CERT_UNKNOWN
    171 #define SEC_E_CERT_UNKNOWN                    ((HRESULT)0x80090327L)
    172 #endif
    173 #ifndef SEC_E_CERT_EXPIRED
    174 #define SEC_E_CERT_EXPIRED                    ((HRESULT)0x80090328L)
    175 #endif
    176 #ifndef SEC_E_ENCRYPT_FAILURE
    177 #define SEC_E_ENCRYPT_FAILURE                 ((HRESULT)0x80090329L)
    178 #endif
    179 #ifndef SEC_E_DECRYPT_FAILURE
    180 #define SEC_E_DECRYPT_FAILURE                 ((HRESULT)0x80090330L)
    181 #endif
    182 #ifndef SEC_E_ALGORITHM_MISMATCH
    183 #define SEC_E_ALGORITHM_MISMATCH              ((HRESULT)0x80090331L)
    184 #endif
    185 #ifndef SEC_E_SECURITY_QOS_FAILED
    186 #define SEC_E_SECURITY_QOS_FAILED             ((HRESULT)0x80090332L)
    187 #endif
    188 #ifndef SEC_E_UNFINISHED_CONTEXT_DELETED
    189 #define SEC_E_UNFINISHED_CONTEXT_DELETED      ((HRESULT)0x80090333L)
    190 #endif
    191 #ifndef SEC_E_NO_TGT_REPLY
    192 #define SEC_E_NO_TGT_REPLY                    ((HRESULT)0x80090334L)
    193 #endif
    194 #ifndef SEC_E_NO_IP_ADDRESSES
    195 #define SEC_E_NO_IP_ADDRESSES                 ((HRESULT)0x80090335L)
    196 #endif
    197 #ifndef SEC_E_WRONG_CREDENTIAL_HANDLE
    198 #define SEC_E_WRONG_CREDENTIAL_HANDLE         ((HRESULT)0x80090336L)
    199 #endif
    200 #ifndef SEC_E_CRYPTO_SYSTEM_INVALID
    201 #define SEC_E_CRYPTO_SYSTEM_INVALID           ((HRESULT)0x80090337L)
    202 #endif
    203 #ifndef SEC_E_MAX_REFERRALS_EXCEEDED
    204 #define SEC_E_MAX_REFERRALS_EXCEEDED          ((HRESULT)0x80090338L)
    205 #endif
    206 #ifndef SEC_E_MUST_BE_KDC
    207 #define SEC_E_MUST_BE_KDC                     ((HRESULT)0x80090339L)
    208 #endif
    209 #ifndef SEC_E_STRONG_CRYPTO_NOT_SUPPORTED
    210 #define SEC_E_STRONG_CRYPTO_NOT_SUPPORTED     ((HRESULT)0x8009033AL)
    211 #endif
    212 #ifndef SEC_E_TOO_MANY_PRINCIPALS
    213 #define SEC_E_TOO_MANY_PRINCIPALS             ((HRESULT)0x8009033BL)
    214 #endif
    215 #ifndef SEC_E_NO_PA_DATA
    216 #define SEC_E_NO_PA_DATA                      ((HRESULT)0x8009033CL)
    217 #endif
    218 #ifndef SEC_E_PKINIT_NAME_MISMATCH
    219 #define SEC_E_PKINIT_NAME_MISMATCH            ((HRESULT)0x8009033DL)
    220 #endif
    221 #ifndef SEC_E_SMARTCARD_LOGON_REQUIRED
    222 #define SEC_E_SMARTCARD_LOGON_REQUIRED        ((HRESULT)0x8009033EL)
    223 #endif
    224 #ifndef SEC_E_SHUTDOWN_IN_PROGRESS
    225 #define SEC_E_SHUTDOWN_IN_PROGRESS            ((HRESULT)0x8009033FL)
    226 #endif
    227 #ifndef SEC_E_KDC_INVALID_REQUEST
    228 #define SEC_E_KDC_INVALID_REQUEST             ((HRESULT)0x80090340L)
    229 #endif
    230 #ifndef SEC_E_KDC_UNABLE_TO_REFER
    231 #define SEC_E_KDC_UNABLE_TO_REFER             ((HRESULT)0x80090341L)
    232 #endif
    233 #ifndef SEC_E_KDC_UNKNOWN_ETYPE
    234 #define SEC_E_KDC_UNKNOWN_ETYPE               ((HRESULT)0x80090342L)
    235 #endif
    236 #ifndef SEC_E_UNSUPPORTED_PREAUTH
    237 #define SEC_E_UNSUPPORTED_PREAUTH             ((HRESULT)0x80090343L)
    238 #endif
    239 #ifndef SEC_E_DELEGATION_REQUIRED
    240 #define SEC_E_DELEGATION_REQUIRED             ((HRESULT)0x80090345L)
    241 #endif
    242 #ifndef SEC_E_BAD_BINDINGS
    243 #define SEC_E_BAD_BINDINGS                    ((HRESULT)0x80090346L)
    244 #endif
    245 #ifndef SEC_E_MULTIPLE_ACCOUNTS
    246 #define SEC_E_MULTIPLE_ACCOUNTS               ((HRESULT)0x80090347L)
    247 #endif
    248 #ifndef SEC_E_NO_KERB_KEY
    249 #define SEC_E_NO_KERB_KEY                     ((HRESULT)0x80090348L)
    250 #endif
    251 #ifndef SEC_E_CERT_WRONG_USAGE
    252 #define SEC_E_CERT_WRONG_USAGE                ((HRESULT)0x80090349L)
    253 #endif
    254 #ifndef SEC_E_DOWNGRADE_DETECTED
    255 #define SEC_E_DOWNGRADE_DETECTED              ((HRESULT)0x80090350L)
    256 #endif
    257 #ifndef SEC_E_SMARTCARD_CERT_REVOKED
    258 #define SEC_E_SMARTCARD_CERT_REVOKED          ((HRESULT)0x80090351L)
    259 #endif
    260 #ifndef SEC_E_ISSUING_CA_UNTRUSTED
    261 #define SEC_E_ISSUING_CA_UNTRUSTED            ((HRESULT)0x80090352L)
    262 #endif
    263 #ifndef SEC_E_REVOCATION_OFFLINE_C
    264 #define SEC_E_REVOCATION_OFFLINE_C            ((HRESULT)0x80090353L)
    265 #endif
    266 #ifndef SEC_E_PKINIT_CLIENT_FAILURE
    267 #define SEC_E_PKINIT_CLIENT_FAILURE           ((HRESULT)0x80090354L)
    268 #endif
    269 #ifndef SEC_E_SMARTCARD_CERT_EXPIRED
    270 #define SEC_E_SMARTCARD_CERT_EXPIRED          ((HRESULT)0x80090355L)
    271 #endif
    272 #ifndef SEC_E_NO_S4U_PROT_SUPPORT
    273 #define SEC_E_NO_S4U_PROT_SUPPORT             ((HRESULT)0x80090356L)
    274 #endif
    275 #ifndef SEC_E_CROSSREALM_DELEGATION_FAILURE
    276 #define SEC_E_CROSSREALM_DELEGATION_FAILURE   ((HRESULT)0x80090357L)
    277 #endif
    278 #ifndef SEC_E_REVOCATION_OFFLINE_KDC
    279 #define SEC_E_REVOCATION_OFFLINE_KDC          ((HRESULT)0x80090358L)
    280 #endif
    281 #ifndef SEC_E_ISSUING_CA_UNTRUSTED_KDC
    282 #define SEC_E_ISSUING_CA_UNTRUSTED_KDC        ((HRESULT)0x80090359L)
    283 #endif
    284 #ifndef SEC_E_KDC_CERT_EXPIRED
    285 #define SEC_E_KDC_CERT_EXPIRED                ((HRESULT)0x8009035AL)
    286 #endif
    287 #ifndef SEC_E_KDC_CERT_REVOKED
    288 #define SEC_E_KDC_CERT_REVOKED                ((HRESULT)0x8009035BL)
    289 #endif
    290 #endif /* __MINGW32CE__ */
    291 #ifndef SEC_E_INVALID_PARAMETER
    292 # define SEC_E_INVALID_PARAMETER              ((HRESULT)0x8009035DL)
    293 #endif
    294 #ifndef SEC_E_DELEGATION_POLICY
    295 # define SEC_E_DELEGATION_POLICY              ((HRESULT)0x8009035EL)
    296 #endif
    297 #ifndef SEC_E_POLICY_NLTM_ONLY
    298 # define SEC_E_POLICY_NLTM_ONLY               ((HRESULT)0x8009035FL)
    299 #endif
    300 
    301 #ifdef __MINGW32CE__
    302 #ifndef SEC_I_CONTINUE_NEEDED
    303 #define SEC_I_CONTINUE_NEEDED                 ((HRESULT)0x00090312L)
    304 #endif
    305 #ifndef SEC_I_COMPLETE_NEEDED
    306 #define SEC_I_COMPLETE_NEEDED                 ((HRESULT)0x00090313L)
    307 #endif
    308 #ifndef SEC_I_COMPLETE_AND_CONTINUE
    309 #define SEC_I_COMPLETE_AND_CONTINUE           ((HRESULT)0x00090314L)
    310 #endif
    311 #ifndef SEC_I_LOCAL_LOGON
    312 #define SEC_I_LOCAL_LOGON                     ((HRESULT)0x00090315L)
    313 #endif
    314 #ifndef SEC_I_CONTEXT_EXPIRED
    315 #define SEC_I_CONTEXT_EXPIRED                 ((HRESULT)0x00090317L)
    316 #endif
    317 #ifndef SEC_I_INCOMPLETE_CREDENTIALS
    318 #define SEC_I_INCOMPLETE_CREDENTIALS          ((HRESULT)0x00090320L)
    319 #endif
    320 #ifndef SEC_I_RENEGOTIATE
    321 #define SEC_I_RENEGOTIATE                     ((HRESULT)0x00090321L)
    322 #endif
    323 #ifndef SEC_I_NO_LSA_CONTEXT
    324 #define SEC_I_NO_LSA_CONTEXT                  ((HRESULT)0x00090323L)
    325 #endif
    326 #endif /* __MINGW32CE__ */
    327 #ifndef SEC_I_SIGNATURE_NEEDED
    328 #define SEC_I_SIGNATURE_NEEDED                ((HRESULT)0x0009035CL)
    329 #endif
    330 
    331 #ifndef CRYPT_E_REVOKED
    332 #define CRYPT_E_REVOKED                       ((HRESULT)0x80092010L)
    333 #endif
    334 
    335 #ifndef CRYPT_E_NO_REVOCATION_DLL
    336 #define CRYPT_E_NO_REVOCATION_DLL             ((HRESULT)0x80092011L)
    337 #endif
    338 
    339 #ifndef CRYPT_E_NO_REVOCATION_CHECK
    340 #define CRYPT_E_NO_REVOCATION_CHECK           ((HRESULT)0x80092012L)
    341 #endif
    342 
    343 #ifndef CRYPT_E_REVOCATION_OFFLINE
    344 #define CRYPT_E_REVOCATION_OFFLINE            ((HRESULT)0x80092013L)
    345 #endif
    346 
    347 #ifndef CRYPT_E_NOT_IN_REVOCATION_DATABASE
    348 #define CRYPT_E_NOT_IN_REVOCATION_DATABASE    ((HRESULT)0x80092014L)
    349 #endif
    350 
    351 #ifdef UNICODE
    352 #  define SECFLAG_WINNT_AUTH_IDENTITY \
    353      (unsigned long)SEC_WINNT_AUTH_IDENTITY_UNICODE
    354 #else
    355 #  define SECFLAG_WINNT_AUTH_IDENTITY \
    356      (unsigned long)SEC_WINNT_AUTH_IDENTITY_ANSI
    357 #endif
    358 
    359 /*
    360  * Definitions required from ntsecapi.h are directly provided below this point
    361  * to avoid including ntsecapi.h due to a conflict with OpenSSL's safestack.h
    362  */
    363 #define KERB_WRAP_NO_ENCRYPT 0x80000001
    364 
    365 #endif /* USE_WINDOWS_SSPI */
    366 
    367 #endif /* HEADER_CURL_SSPI_H */