curl_ntlm_core.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. ***************************************************************************/
  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. /* Helpers to generate function byte arguments in little endian order */
  41. #define SHORTPAIR(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff))
  42. #define LONGQUARTET(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff)), \
  43. ((int)(((x) >> 16) & 0xff)), ((int)(((x) >> 24) & 0xff))
  44. void Curl_ntlm_core_lm_resp(const unsigned char *keys,
  45. const unsigned char *plaintext,
  46. unsigned char *results);
  47. CURLcode Curl_ntlm_core_mk_lm_hash(const char *password,
  48. unsigned char *lmbuffer /* 21 bytes */);
  49. CURLcode Curl_ntlm_core_mk_nt_hash(const char *password,
  50. unsigned char *ntbuffer /* 21 bytes */);
  51. #if !defined(USE_WINDOWS_SSPI)
  52. CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
  53. const unsigned char *data, unsigned int datalen,
  54. unsigned char *output);
  55. CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
  56. const char *domain, size_t domlen,
  57. unsigned char *ntlmhash,
  58. unsigned char *ntlmv2hash);
  59. CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
  60. unsigned char *challenge_client,
  61. struct ntlmdata *ntlm,
  62. unsigned char **ntresp,
  63. unsigned int *ntresp_len);
  64. CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
  65. unsigned char *challenge_client,
  66. unsigned char *challenge_server,
  67. unsigned char *lmresp);
  68. #endif /* !USE_WINDOWS_SSPI */
  69. #endif /* USE_CURL_NTLM_CORE */
  70. #endif /* HEADER_CURL_NTLM_CORE_H */