2
0

curl_ntlm_core.h 3.4 KB

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