1 #ifndef HEADER_CURL_NTLM_CORE_H 2 #define HEADER_CURL_NTLM_CORE_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 1998 - 2015, 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.haxx.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 ***************************************************************************/ 24 25 #include "curl_setup.h" 26 27 #if defined(USE_NTLM) 28 29 #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO) 30 31 #ifdef USE_OPENSSL 32 # if !defined(OPENSSL_VERSION_NUMBER) && \ 33 !defined(HEADER_SSL_H) && !defined(HEADER_MD5_H) 34 # error "curl_ntlm_core.h shall not be included before OpenSSL headers." 35 # endif 36 # ifdef OPENSSL_NO_MD4 37 # define USE_NTRESPONSES 0 38 # define USE_NTLM2SESSION 0 39 # define USE_NTLM_V2 0 40 # endif 41 #endif 42 43 /* Define USE_NTRESPONSES to 1 in order to make the type-3 message include 44 * the NT response message. */ 45 #ifndef USE_NTRESPONSES 46 #define USE_NTRESPONSES 1 47 #endif 48 49 /* Define USE_NTLM2SESSION to 1 in order to make the type-3 message include the 50 NTLM2Session response message, requires USE_NTRESPONSES defined to 1 and a 51 Crypto engine that we have curl_ssl_md5sum() for. */ 52 #if !defined(USE_NTLM2SESSION) && USE_NTRESPONSES && !defined(USE_WIN32_CRYPTO) 53 #define USE_NTLM2SESSION 1 54 #endif 55 56 /* Define USE_NTLM_V2 to 1 in order to allow the type-3 message to include the 57 LMv2 and NTLMv2 response messages, requires USE_NTRESPONSES defined to 1 58 and support for 64-bit integers. */ 59 #if !defined(USE_NTLM_V2) && USE_NTRESPONSES && (CURL_SIZEOF_CURL_OFF_T > 4) 60 #define USE_NTLM_V2 1 61 #endif 62 63 void Curl_ntlm_core_lm_resp(const unsigned char *keys, 64 const unsigned char *plaintext, 65 unsigned char *results); 66 67 CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data, 68 const char *password, 69 unsigned char *lmbuffer /* 21 bytes */); 70 71 #if USE_NTRESPONSES 72 CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data, 73 const char *password, 74 unsigned char *ntbuffer /* 21 bytes */); 75 76 #if USE_NTLM_V2 && !defined(USE_WINDOWS_SSPI) 77 78 CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen, 79 const unsigned char *data, unsigned int datalen, 80 unsigned char *output); 81 82 CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, 83 const char *domain, size_t domlen, 84 unsigned char *ntlmhash, 85 unsigned char *ntlmv2hash); 86 87 CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, 88 unsigned char *challenge_client, 89 struct ntlmdata *ntlm, 90 unsigned char **ntresp, 91 unsigned int *ntresp_len); 92 93 CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, 94 unsigned char *challenge_client, 95 unsigned char *challenge_server, 96 unsigned char *lmresp); 97 98 #endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */ 99 100 #endif /* USE_NTRESPONSES */ 101 102 #endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */ 103 104 #endif /* USE_NTLM */ 105 106 #endif /* HEADER_CURL_NTLM_CORE_H */ 107