vauth.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #ifndef HEADER_CURL_VAUTH_H
  2. #define HEADER_CURL_VAUTH_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2014 - 2020, 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.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 *authzid,
  54. const char *authcid,
  55. const char *passwd,
  56. char **outptr, size_t *outlen);
  57. /* This is used to generate a base64 encoded LOGIN cleartext message */
  58. CURLcode Curl_auth_create_login_message(struct Curl_easy *data,
  59. const char *valuep, char **outptr,
  60. size_t *outlen);
  61. /* This is used to generate a base64 encoded EXTERNAL cleartext message */
  62. CURLcode Curl_auth_create_external_message(struct Curl_easy *data,
  63. const char *user, char **outptr,
  64. size_t *outlen);
  65. #if !defined(CURL_DISABLE_CRYPTO_AUTH)
  66. /* This is used to decode a CRAM-MD5 challenge message */
  67. CURLcode Curl_auth_decode_cram_md5_message(const char *chlg64, char **outptr,
  68. size_t *outlen);
  69. /* This is used to generate a CRAM-MD5 response message */
  70. CURLcode Curl_auth_create_cram_md5_message(struct Curl_easy *data,
  71. const char *chlg,
  72. const char *userp,
  73. const char *passwdp,
  74. char **outptr, size_t *outlen);
  75. /* This is used to evaluate if DIGEST is supported */
  76. bool Curl_auth_is_digest_supported(void);
  77. /* This is used to generate a base64 encoded DIGEST-MD5 response message */
  78. CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
  79. const char *chlg64,
  80. const char *userp,
  81. const char *passwdp,
  82. const char *service,
  83. char **outptr, size_t *outlen);
  84. /* This is used to decode a HTTP DIGEST challenge message */
  85. CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
  86. struct digestdata *digest);
  87. /* This is used to generate a HTTP DIGEST response message */
  88. CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
  89. const char *userp,
  90. const char *passwdp,
  91. const unsigned char *request,
  92. const unsigned char *uri,
  93. struct digestdata *digest,
  94. char **outptr, size_t *outlen);
  95. /* This is used to clean up the digest specific data */
  96. void Curl_auth_digest_cleanup(struct digestdata *digest);
  97. #endif /* !CURL_DISABLE_CRYPTO_AUTH */
  98. #if defined(USE_NTLM)
  99. /* This is used to evaluate if NTLM is supported */
  100. bool Curl_auth_is_ntlm_supported(void);
  101. /* This is used to generate a base64 encoded NTLM type-1 message */
  102. CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
  103. const char *userp,
  104. const char *passwdp,
  105. const char *service,
  106. const char *host,
  107. struct ntlmdata *ntlm,
  108. char **outptr,
  109. size_t *outlen);
  110. /* This is used to decode a base64 encoded NTLM type-2 message */
  111. CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
  112. const char *type2msg,
  113. struct ntlmdata *ntlm);
  114. /* This is used to generate a base64 encoded NTLM type-3 message */
  115. CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
  116. const char *userp,
  117. const char *passwdp,
  118. struct ntlmdata *ntlm,
  119. char **outptr, size_t *outlen);
  120. /* This is used to clean up the NTLM specific data */
  121. void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm);
  122. #endif /* USE_NTLM */
  123. /* This is used to generate a base64 encoded OAuth 2.0 message */
  124. CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
  125. const char *user,
  126. const char *host,
  127. const long port,
  128. const char *bearer,
  129. char **outptr, size_t *outlen);
  130. /* This is used to generate a base64 encoded XOAuth 2.0 message */
  131. CURLcode Curl_auth_create_xoauth_bearer_message(struct Curl_easy *data,
  132. const char *user,
  133. const char *bearer,
  134. char **outptr, size_t *outlen);
  135. #if defined(USE_KERBEROS5)
  136. /* This is used to evaluate if GSSAPI (Kerberos V5) is supported */
  137. bool Curl_auth_is_gssapi_supported(void);
  138. /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token
  139. message */
  140. CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
  141. const char *userp,
  142. const char *passwdp,
  143. const char *service,
  144. const char *host,
  145. const bool mutual,
  146. const char *chlg64,
  147. struct kerberos5data *krb5,
  148. char **outptr, size_t *outlen);
  149. /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security
  150. token message */
  151. CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
  152. const char *input,
  153. struct kerberos5data *krb5,
  154. char **outptr,
  155. size_t *outlen);
  156. /* This is used to clean up the GSSAPI specific data */
  157. void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5);
  158. #endif /* USE_KERBEROS5 */
  159. #if defined(USE_SPNEGO)
  160. /* This is used to evaluate if SPNEGO (Negotiate) is supported */
  161. bool Curl_auth_is_spnego_supported(void);
  162. /* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge
  163. message */
  164. CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
  165. const char *user,
  166. const char *passwood,
  167. const char *service,
  168. const char *host,
  169. const char *chlg64,
  170. struct negotiatedata *nego);
  171. /* This is used to generate a base64 encoded SPNEGO (Negotiate) response
  172. message */
  173. CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
  174. struct negotiatedata *nego,
  175. char **outptr, size_t *outlen);
  176. /* This is used to clean up the SPNEGO specifiec data */
  177. void Curl_auth_cleanup_spnego(struct negotiatedata *nego);
  178. #endif /* USE_SPNEGO */
  179. #endif /* HEADER_CURL_VAUTH_H */