1 #ifndef HEADER_CURL_NTLM_CORE_H
2 #define HEADER_CURL_NTLM_CORE_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 * SPDX-License-Identifier: curl
25 ***************************************************************************/
27 #include "curl_setup.h"
29 #if defined(USE_CURL_NTLM_CORE)
31 /* If NSS is the first available SSL backend (see order in curl_ntlm_core.c)
32 then it must be initialized to be used by NTLM. */
33 #if !defined(USE_OPENSSL) && \
34 !defined(USE_WOLFSSL) && \
35 !defined(USE_GNUTLS) && \
37 #define NTLM_NEEDS_NSS_INIT
41 # include <wolfssl/options.h>
42 # include <wolfssl/openssl/ssl.h>
43 #elif defined(USE_OPENSSL)
44 # include <openssl/ssl.h>
47 /* Helpers to generate function byte arguments in little endian order */
48 #define SHORTPAIR(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff))
49 #define LONGQUARTET(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff)), \
50 ((int)(((x) >> 16) & 0xff)), ((int)(((x) >> 24) & 0xff))
52 void Curl_ntlm_core_lm_resp(const unsigned char *keys,
53 const unsigned char *plaintext,
54 unsigned char *results);
56 CURLcode Curl_ntlm_core_mk_lm_hash(const char *password,
57 unsigned char *lmbuffer /* 21 bytes */);
59 CURLcode Curl_ntlm_core_mk_nt_hash(const char *password,
60 unsigned char *ntbuffer /* 21 bytes */);
62 #if !defined(USE_WINDOWS_SSPI)
64 CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
65 const unsigned char *data, unsigned int datalen,
66 unsigned char *output);
68 CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
69 const char *domain, size_t domlen,
70 unsigned char *ntlmhash,
71 unsigned char *ntlmv2hash);
73 CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
74 unsigned char *challenge_client,
75 struct ntlmdata *ntlm,
76 unsigned char **ntresp,
77 unsigned int *ntresp_len);
79 CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
80 unsigned char *challenge_client,
81 unsigned char *challenge_server,
82 unsigned char *lmresp);
84 #endif /* !USE_WINDOWS_SSPI */
86 #endif /* USE_CURL_NTLM_CORE */
88 #endif /* HEADER_CURL_NTLM_CORE_H */