curl_ntlm_core.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 - 2021, 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. ***************************************************************************/
  24. #include "curl_setup.h"
  25. #if defined(USE_CURL_NTLM_CORE)
  26. /* If NSS is the first available SSL backend (see order in curl_ntlm_core.c)
  27. then it must be initialized to be used by NTLM. */
  28. #if !defined(USE_OPENSSL) && \
  29. !defined(USE_WOLFSSL) && \
  30. !defined(USE_GNUTLS) && \
  31. defined(USE_NSS)
  32. #define NTLM_NEEDS_NSS_INIT
  33. #endif
  34. #if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
  35. #ifdef USE_WOLFSSL
  36. # include <wolfssl/options.h>
  37. #endif
  38. # include <openssl/ssl.h>
  39. #endif
  40. /* Define USE_NTRESPONSES in order to make the type-3 message include
  41. * the NT response message. */
  42. #define USE_NTRESPONSES
  43. /* Define USE_NTLM2SESSION in order to make the type-3 message include the
  44. NTLM2Session response message, requires USE_NTRESPONSES defined to 1 */
  45. #if defined(USE_NTRESPONSES)
  46. #define USE_NTLM2SESSION
  47. #endif
  48. /* Define USE_NTLM_V2 in order to allow the type-3 message to include the
  49. LMv2 and NTLMv2 response messages, requires USE_NTRESPONSES defined to 1 */
  50. #if defined(USE_NTRESPONSES)
  51. #define USE_NTLM_V2
  52. #endif
  53. /* Helpers to generate function byte arguments in little endian order */
  54. #define SHORTPAIR(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff))
  55. #define LONGQUARTET(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff)), \
  56. ((int)(((x) >> 16) & 0xff)), ((int)(((x) >> 24) & 0xff))
  57. void Curl_ntlm_core_lm_resp(const unsigned char *keys,
  58. const unsigned char *plaintext,
  59. unsigned char *results);
  60. CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
  61. const char *password,
  62. unsigned char *lmbuffer /* 21 bytes */);
  63. #ifdef USE_NTRESPONSES
  64. CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
  65. const char *password,
  66. unsigned char *ntbuffer /* 21 bytes */);
  67. #if defined(USE_NTLM_V2) && !defined(USE_WINDOWS_SSPI)
  68. CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
  69. const unsigned char *data, unsigned int datalen,
  70. unsigned char *output);
  71. CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
  72. const char *domain, size_t domlen,
  73. unsigned char *ntlmhash,
  74. unsigned char *ntlmv2hash);
  75. CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
  76. unsigned char *challenge_client,
  77. struct ntlmdata *ntlm,
  78. unsigned char **ntresp,
  79. unsigned int *ntresp_len);
  80. CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
  81. unsigned char *challenge_client,
  82. unsigned char *challenge_server,
  83. unsigned char *lmresp);
  84. #endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */
  85. #endif /* USE_NTRESPONSES */
  86. #endif /* USE_CURL_NTLM_CORE */
  87. #endif /* HEADER_CURL_NTLM_CORE_H */