vtls_int.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #ifndef HEADER_CURL_VTLS_INT_H
  2. #define HEADER_CURL_VTLS_INT_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 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. #include "cfilters.h"
  28. #include "urldata.h"
  29. #ifdef USE_SSL
  30. /* Information in each SSL cfilter context: cf->ctx */
  31. struct ssl_connect_data {
  32. ssl_connection_state state;
  33. ssl_connect_state connecting_state;
  34. char *hostname; /* hostname for verification */
  35. char *dispname; /* display version of hostname */
  36. int port; /* remote port at origin */
  37. const struct alpn_spec *alpn; /* ALPN to use or NULL for none */
  38. struct ssl_backend_data *backend; /* vtls backend specific props */
  39. struct cf_call_data call_data; /* data handle used in current call */
  40. struct curltime handshake_done; /* time when handshake finished */
  41. };
  42. #define CF_CTX_CALL_DATA(cf) \
  43. ((struct ssl_connect_data *)(cf)->ctx)->call_data
  44. /* Definitions for SSL Implementations */
  45. struct Curl_ssl {
  46. /*
  47. * This *must* be the first entry to allow returning the list of available
  48. * backends in curl_global_sslset().
  49. */
  50. curl_ssl_backend info;
  51. unsigned int supports; /* bitfield, see above */
  52. size_t sizeof_ssl_backend_data;
  53. int (*init)(void);
  54. void (*cleanup)(void);
  55. size_t (*version)(char *buffer, size_t size);
  56. int (*check_cxn)(struct Curl_cfilter *cf, struct Curl_easy *data);
  57. int (*shut_down)(struct Curl_cfilter *cf,
  58. struct Curl_easy *data);
  59. bool (*data_pending)(struct Curl_cfilter *cf,
  60. const struct Curl_easy *data);
  61. /* return 0 if a find random is filled in */
  62. CURLcode (*random)(struct Curl_easy *data, unsigned char *entropy,
  63. size_t length);
  64. bool (*cert_status_request)(void);
  65. CURLcode (*connect_blocking)(struct Curl_cfilter *cf,
  66. struct Curl_easy *data);
  67. CURLcode (*connect_nonblocking)(struct Curl_cfilter *cf,
  68. struct Curl_easy *data,
  69. bool *done);
  70. /* If the SSL backend wants to read or write on this connection during a
  71. handshake, set socks[0] to the connection's FIRSTSOCKET, and return
  72. a bitmap indicating read or write with GETSOCK_WRITESOCK(0) or
  73. GETSOCK_READSOCK(0). Otherwise return GETSOCK_BLANK.
  74. Mandatory. */
  75. int (*get_select_socks)(struct Curl_cfilter *cf, struct Curl_easy *data,
  76. curl_socket_t *socks);
  77. void *(*get_internals)(struct ssl_connect_data *connssl, CURLINFO info);
  78. void (*close)(struct Curl_cfilter *cf, struct Curl_easy *data);
  79. void (*close_all)(struct Curl_easy *data);
  80. void (*session_free)(void *ptr);
  81. CURLcode (*set_engine)(struct Curl_easy *data, const char *engine);
  82. CURLcode (*set_engine_default)(struct Curl_easy *data);
  83. struct curl_slist *(*engines_list)(struct Curl_easy *data);
  84. bool (*false_start)(void);
  85. CURLcode (*sha256sum)(const unsigned char *input, size_t inputlen,
  86. unsigned char *sha256sum, size_t sha256sumlen);
  87. bool (*attach_data)(struct Curl_cfilter *cf, struct Curl_easy *data);
  88. void (*detach_data)(struct Curl_cfilter *cf, struct Curl_easy *data);
  89. void (*free_multi_ssl_backend_data)(struct multi_ssl_backend_data *mbackend);
  90. ssize_t (*recv_plain)(struct Curl_cfilter *cf, struct Curl_easy *data,
  91. char *buf, size_t len, CURLcode *code);
  92. ssize_t (*send_plain)(struct Curl_cfilter *cf, struct Curl_easy *data,
  93. const void *mem, size_t len, CURLcode *code);
  94. };
  95. extern const struct Curl_ssl *Curl_ssl;
  96. int Curl_none_init(void);
  97. void Curl_none_cleanup(void);
  98. int Curl_none_shutdown(struct Curl_cfilter *cf, struct Curl_easy *data);
  99. int Curl_none_check_cxn(struct Curl_cfilter *cf, struct Curl_easy *data);
  100. CURLcode Curl_none_random(struct Curl_easy *data, unsigned char *entropy,
  101. size_t length);
  102. void Curl_none_close_all(struct Curl_easy *data);
  103. void Curl_none_session_free(void *ptr);
  104. bool Curl_none_data_pending(struct Curl_cfilter *cf,
  105. const struct Curl_easy *data);
  106. bool Curl_none_cert_status_request(void);
  107. CURLcode Curl_none_set_engine(struct Curl_easy *data, const char *engine);
  108. CURLcode Curl_none_set_engine_default(struct Curl_easy *data);
  109. struct curl_slist *Curl_none_engines_list(struct Curl_easy *data);
  110. bool Curl_none_false_start(void);
  111. int Curl_ssl_get_select_socks(struct Curl_cfilter *cf, struct Curl_easy *data,
  112. curl_socket_t *socks);
  113. /**
  114. * Get the ssl_config_data in `data` that is relevant for cfilter `cf`.
  115. */
  116. struct ssl_config_data *Curl_ssl_cf_get_config(struct Curl_cfilter *cf,
  117. struct Curl_easy *data);
  118. /**
  119. * Get the primary config relevant for the filter from its connection.
  120. */
  121. struct ssl_primary_config *
  122. Curl_ssl_cf_get_primary_config(struct Curl_cfilter *cf);
  123. /**
  124. * Get the first SSL filter in the chain starting with `cf`, or NULL.
  125. */
  126. struct Curl_cfilter *Curl_ssl_cf_get_ssl(struct Curl_cfilter *cf);
  127. /**
  128. * Get the SSL filter below the given one or NULL if there is none.
  129. */
  130. bool Curl_ssl_cf_is_proxy(struct Curl_cfilter *cf);
  131. /* extract a session ID
  132. * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
  133. * Caller must make sure that the ownership of returned sessionid object
  134. * is properly taken (e.g. its refcount is incremented
  135. * under sessionid mutex).
  136. */
  137. bool Curl_ssl_getsessionid(struct Curl_cfilter *cf,
  138. struct Curl_easy *data,
  139. void **ssl_sessionid,
  140. size_t *idsize); /* set 0 if unknown */
  141. /* add a new session ID
  142. * Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
  143. * Caller must ensure that it has properly shared ownership of this sessionid
  144. * object with cache (e.g. incrementing refcount on success)
  145. */
  146. CURLcode Curl_ssl_addsessionid(struct Curl_cfilter *cf,
  147. struct Curl_easy *data,
  148. void *ssl_sessionid,
  149. size_t idsize,
  150. bool *added);
  151. #include "openssl.h" /* OpenSSL versions */
  152. #include "gtls.h" /* GnuTLS versions */
  153. #include "nssg.h" /* NSS versions */
  154. #include "gskit.h" /* Global Secure ToolKit versions */
  155. #include "wolfssl.h" /* wolfSSL versions */
  156. #include "schannel.h" /* Schannel SSPI version */
  157. #include "sectransp.h" /* SecureTransport (Darwin) version */
  158. #include "mbedtls.h" /* mbedTLS versions */
  159. #include "bearssl.h" /* BearSSL versions */
  160. #include "rustls.h" /* rustls versions */
  161. #endif /* USE_SSL */
  162. #endif /* HEADER_CURL_VTLS_INT_H */