vauth.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #ifndef HEADER_CURL_VAUTH_H
  2. #define HEADER_CURL_VAUTH_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2014 - 2017, Steve Holme, <steve_holme@hotmail.com>.
  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. #include <curl/curl.h>
  25. struct Curl_easy;
  26. #if !defined(CURL_DISABLE_CRYPTO_AUTH)
  27. struct digestdata;
  28. #endif
  29. #if defined(USE_NTLM)
  30. struct ntlmdata;
  31. #endif
  32. #if defined(USE_KERBEROS5)
  33. struct kerberos5data;
  34. #endif
  35. #if (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) && defined(USE_SPNEGO)
  36. struct negotiatedata;
  37. #endif
  38. #if defined(USE_WINDOWS_SSPI)
  39. #define GSS_ERROR(status) (status & 0x80000000)
  40. #endif
  41. /* This is used to build a SPN string */
  42. #if !defined(USE_WINDOWS_SSPI)
  43. char *Curl_auth_build_spn(const char *service, const char *host,
  44. const char *realm);
  45. #else
  46. TCHAR *Curl_auth_build_spn(const char *service, const char *host,
  47. const char *realm);
  48. #endif
  49. /* This is used to test if the user contains a Windows domain name */
  50. bool Curl_auth_user_contains_domain(const char *user);
  51. /* This is used to generate a base64 encoded PLAIN cleartext message */
  52. CURLcode Curl_auth_create_plain_message(struct Curl_easy *data,
  53. const char *userp,
  54. const char *passwdp,
  55. char **outptr, size_t *outlen);
  56. /* This is used to generate a base64 encoded LOGIN cleartext message */
  57. CURLcode Curl_auth_create_login_message(struct Curl_easy *data,
  58. const char *valuep, char **outptr,
  59. size_t *outlen);
  60. /* This is used to generate a base64 encoded EXTERNAL cleartext message */
  61. CURLcode Curl_auth_create_external_message(struct Curl_easy *data,
  62. const char *user, char **outptr,
  63. size_t *outlen);
  64. #if !defined(CURL_DISABLE_CRYPTO_AUTH)
  65. /* This is used to decode a CRAM-MD5 challenge message */
  66. CURLcode Curl_auth_decode_cram_md5_message(const char *chlg64, char **outptr,
  67. size_t *outlen);
  68. /* This is used to generate a CRAM-MD5 response message */
  69. CURLcode Curl_auth_create_cram_md5_message(struct Curl_easy *data,
  70. const char *chlg,
  71. const char *userp,
  72. const char *passwdp,
  73. char **outptr, size_t *outlen);
  74. /* This is used to evaluate if DIGEST is supported */
  75. bool Curl_auth_is_digest_supported(void);
  76. /* This is used to generate a base64 encoded DIGEST-MD5 response message */
  77. CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
  78. const char *chlg64,
  79. const char *userp,
  80. const char *passwdp,
  81. const char *service,
  82. char **outptr, size_t *outlen);
  83. /* This is used to decode a HTTP DIGEST challenge message */
  84. CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
  85. struct digestdata *digest);
  86. /* This is used to generate a HTTP DIGEST response message */
  87. CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
  88. const char *userp,
  89. const char *passwdp,
  90. const unsigned char *request,
  91. const unsigned char *uri,
  92. struct digestdata *digest,
  93. char **outptr, size_t *outlen);
  94. /* This is used to clean up the digest specific data */
  95. void Curl_auth_digest_cleanup(struct digestdata *digest);
  96. #endif /* !CURL_DISABLE_CRYPTO_AUTH */
  97. #if defined(USE_NTLM)
  98. /* This is used to evaluate if NTLM is supported */
  99. bool Curl_auth_is_ntlm_supported(void);
  100. /* This is used to generate a base64 encoded NTLM type-1 message */
  101. CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
  102. const char *userp,
  103. const char *passwdp,
  104. struct ntlmdata *ntlm,
  105. char **outptr,
  106. size_t *outlen);
  107. /* This is used to decode a base64 encoded NTLM type-2 message */
  108. CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
  109. const char *type2msg,
  110. struct ntlmdata *ntlm);
  111. /* This is used to generate a base64 encoded NTLM type-3 message */
  112. CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
  113. const char *userp,
  114. const char *passwdp,
  115. struct ntlmdata *ntlm,
  116. char **outptr, size_t *outlen);
  117. /* This is used to clean up the NTLM specific data */
  118. void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm);
  119. #endif /* USE_NTLM */
  120. /* This is used to generate a base64 encoded OAuth 2.0 message */
  121. CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
  122. const char *user,
  123. const char *host,
  124. const long port,
  125. const char *bearer,
  126. char **outptr, size_t *outlen);
  127. #if defined(USE_KERBEROS5)
  128. /* This is used to evaluate if GSSAPI (Kerberos V5) is supported */
  129. bool Curl_auth_is_gssapi_supported(void);
  130. /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token
  131. message */
  132. CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
  133. const char *userp,
  134. const char *passwdp,
  135. const char *service,
  136. const char *host,
  137. const bool mutual,
  138. const char *chlg64,
  139. struct kerberos5data *krb5,
  140. char **outptr, size_t *outlen);
  141. /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security
  142. token message */
  143. CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
  144. const char *input,
  145. struct kerberos5data *krb5,
  146. char **outptr,
  147. size_t *outlen);
  148. /* This is used to clean up the GSSAPI specific data */
  149. void Curl_auth_gssapi_cleanup(struct kerberos5data *krb5);
  150. #endif /* USE_KERBEROS5 */
  151. #if defined(USE_SPNEGO)
  152. /* This is used to evaluate if SPNEGO (Negotiate) is supported */
  153. bool Curl_auth_is_spnego_supported(void);
  154. /* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge
  155. message */
  156. CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
  157. const char *user,
  158. const char *passwood,
  159. const char *service,
  160. const char *host,
  161. const char *chlg64,
  162. struct negotiatedata *nego);
  163. /* This is used to generate a base64 encoded SPNEGO (Negotiate) response
  164. message */
  165. CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
  166. struct negotiatedata *nego,
  167. char **outptr, size_t *outlen);
  168. /* This is used to clean up the SPNEGO specifiec data */
  169. void Curl_auth_spnego_cleanup(struct negotiatedata *nego);
  170. #endif /* USE_SPNEGO */
  171. #endif /* HEADER_CURL_VAUTH_H */