vtls.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef HEADER_CURL_VTLS_H
  2. #define HEADER_CURL_VTLS_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2015, Daniel Stenberg, <[email protected]>, 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 http://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_setup.h"
  25. #include "openssl.h" /* OpenSSL versions */
  26. #include "gtls.h" /* GnuTLS versions */
  27. #include "nssg.h" /* NSS versions */
  28. #include "gskit.h" /* Global Secure ToolKit versions */
  29. #include "polarssl.h" /* PolarSSL versions */
  30. #include "axtls.h" /* axTLS versions */
  31. #include "cyassl.h" /* CyaSSL versions */
  32. #include "schannel.h" /* Schannel SSPI version */
  33. #include "darwinssl.h" /* SecureTransport (Darwin) version */
  34. #ifndef MAX_PINNED_PUBKEY_SIZE
  35. #define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
  36. #endif
  37. #ifndef MD5_DIGEST_LENGTH
  38. #define MD5_DIGEST_LENGTH 16 /* fixed size */
  39. #endif
  40. #ifndef SHA256_DIGEST_LENGTH
  41. #define SHA256_DIGEST_LENGTH 32 /* fixed size */
  42. #endif
  43. /* see http://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */
  44. #define ALPN_HTTP_1_1_LENGTH 8
  45. #define ALPN_HTTP_1_1 "http/1.1"
  46. bool Curl_ssl_config_matches(struct ssl_config_data* data,
  47. struct ssl_config_data* needle);
  48. bool Curl_clone_ssl_config(struct ssl_config_data* source,
  49. struct ssl_config_data* dest);
  50. void Curl_free_ssl_config(struct ssl_config_data* sslc);
  51. unsigned int Curl_rand(struct SessionHandle *);
  52. int Curl_ssl_backend(void);
  53. #ifdef USE_SSL
  54. int Curl_ssl_init(void);
  55. void Curl_ssl_cleanup(void);
  56. CURLcode Curl_ssl_connect(struct connectdata *conn, int sockindex);
  57. CURLcode Curl_ssl_connect_nonblocking(struct connectdata *conn,
  58. int sockindex,
  59. bool *done);
  60. /* tell the SSL stuff to close down all open information regarding
  61. connections (and thus session ID caching etc) */
  62. void Curl_ssl_close_all(struct SessionHandle *data);
  63. void Curl_ssl_close(struct connectdata *conn, int sockindex);
  64. CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex);
  65. CURLcode Curl_ssl_set_engine(struct SessionHandle *data, const char *engine);
  66. /* Sets engine as default for all SSL operations */
  67. CURLcode Curl_ssl_set_engine_default(struct SessionHandle *data);
  68. struct curl_slist *Curl_ssl_engines_list(struct SessionHandle *data);
  69. /* init the SSL session ID cache */
  70. CURLcode Curl_ssl_initsessions(struct SessionHandle *, size_t);
  71. size_t Curl_ssl_version(char *buffer, size_t size);
  72. bool Curl_ssl_data_pending(const struct connectdata *conn,
  73. int connindex);
  74. int Curl_ssl_check_cxn(struct connectdata *conn);
  75. /* Certificate information list handling. */
  76. void Curl_ssl_free_certinfo(struct SessionHandle *data);
  77. CURLcode Curl_ssl_init_certinfo(struct SessionHandle * data, int num);
  78. CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle * data, int certnum,
  79. const char * label, const char * value,
  80. size_t valuelen);
  81. CURLcode Curl_ssl_push_certinfo(struct SessionHandle * data, int certnum,
  82. const char * label, const char * value);
  83. /* Functions to be used by SSL library adaptation functions */
  84. /* extract a session ID */
  85. bool Curl_ssl_getsessionid(struct connectdata *conn,
  86. void **ssl_sessionid,
  87. size_t *idsize) /* set 0 if unknown */;
  88. /* add a new session ID */
  89. CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
  90. void *ssl_sessionid,
  91. size_t idsize);
  92. /* Kill a single session ID entry in the cache */
  93. void Curl_ssl_kill_session(struct curl_ssl_session *session);
  94. /* delete a session from the cache */
  95. void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
  96. /* get N random bytes into the buffer, return 0 if a find random is filled
  97. in */
  98. int Curl_ssl_random(struct SessionHandle *data, unsigned char *buffer,
  99. size_t length);
  100. CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
  101. size_t tmplen,
  102. unsigned char *md5sum, /* output */
  103. size_t md5len);
  104. /* Check pinned public key. */
  105. CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey,
  106. const unsigned char *pubkey, size_t pubkeylen);
  107. bool Curl_ssl_cert_status_request(void);
  108. bool Curl_ssl_false_start(void);
  109. #define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
  110. #else
  111. /* Set the API backend definition to none */
  112. #define CURL_SSL_BACKEND CURLSSLBACKEND_NONE
  113. /* When SSL support is not present, just define away these function calls */
  114. #define Curl_ssl_init() 1
  115. #define Curl_ssl_cleanup() Curl_nop_stmt
  116. #define Curl_ssl_connect(x,y) CURLE_NOT_BUILT_IN
  117. #define Curl_ssl_close_all(x) Curl_nop_stmt
  118. #define Curl_ssl_close(x,y) Curl_nop_stmt
  119. #define Curl_ssl_shutdown(x,y) CURLE_NOT_BUILT_IN
  120. #define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN
  121. #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN
  122. #define Curl_ssl_engines_list(x) NULL
  123. #define Curl_ssl_send(a,b,c,d,e) -1
  124. #define Curl_ssl_recv(a,b,c,d,e) -1
  125. #define Curl_ssl_initsessions(x,y) CURLE_OK
  126. #define Curl_ssl_version(x,y) 0
  127. #define Curl_ssl_data_pending(x,y) 0
  128. #define Curl_ssl_check_cxn(x) 0
  129. #define Curl_ssl_free_certinfo(x) Curl_nop_stmt
  130. #define Curl_ssl_connect_nonblocking(x,y,z) CURLE_NOT_BUILT_IN
  131. #define Curl_ssl_kill_session(x) Curl_nop_stmt
  132. #define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
  133. #define Curl_ssl_cert_status_request() FALSE
  134. #define Curl_ssl_false_start() FALSE
  135. #endif
  136. #endif /* HEADER_CURL_VTLS_H */