mbedtls.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef HEADER_CURL_MBEDTLS_H
  2. #define HEADER_CURL_MBEDTLS_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2012 - 2016, Daniel Stenberg, <[email protected]>, et al.
  11. * Copyright (C) 2010, Hoi-Ho Chan, <[email protected]>
  12. *
  13. * This software is licensed as described in the file COPYING, which
  14. * you should have received as part of this distribution. The terms
  15. * are also available at https://curl.haxx.se/docs/copyright.html.
  16. *
  17. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  18. * copies of the Software, and permit persons to whom the Software is
  19. * furnished to do so, under the terms of the COPYING file.
  20. *
  21. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  22. * KIND, either express or implied.
  23. *
  24. ***************************************************************************/
  25. #include "curl_setup.h"
  26. #ifdef USE_MBEDTLS
  27. #include <mbedtls/sha256.h>
  28. /* Called on first use mbedTLS, setup threading if supported */
  29. int Curl_mbedtls_init(void);
  30. void Curl_mbedtls_cleanup(void);
  31. int Curl_mbedtls_data_pending(const struct connectdata *conn, int sockindex);
  32. CURLcode Curl_mbedtls_connect(struct connectdata *conn, int sockindex);
  33. CURLcode Curl_mbedtls_connect_nonblocking(struct connectdata *conn,
  34. int sockindex,
  35. bool *done);
  36. /* tell mbedTLS to close down all open information regarding connections (and
  37. thus session ID caching etc) */
  38. void Curl_mbedtls_close_all(struct Curl_easy *data);
  39. /* close a SSL connection */
  40. void Curl_mbedtls_close(struct connectdata *conn, int sockindex);
  41. void Curl_mbedtls_session_free(void *ptr);
  42. size_t Curl_mbedtls_version(char *buffer, size_t size);
  43. int Curl_mbedtls_shutdown(struct connectdata *conn, int sockindex);
  44. /* this backends supports CURLOPT_PINNEDPUBLICKEY */
  45. #define have_curlssl_pinnedpubkey 1
  46. /* API setup for mbedTLS */
  47. #define curlssl_init() Curl_mbedtls_init()
  48. #define curlssl_cleanup() Curl_mbedtls_cleanup()
  49. #define curlssl_connect Curl_mbedtls_connect
  50. #define curlssl_connect_nonblocking Curl_mbedtls_connect_nonblocking
  51. #define curlssl_session_free(x) Curl_mbedtls_session_free(x)
  52. #define curlssl_close_all Curl_mbedtls_close_all
  53. #define curlssl_close Curl_mbedtls_close
  54. #define curlssl_shutdown(x,y) 0
  55. #define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN)
  56. #define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN)
  57. #define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL)
  58. #define curlssl_version Curl_mbedtls_version
  59. #define curlssl_check_cxn(x) (x=x, -1)
  60. #define curlssl_data_pending(x,y) Curl_mbedtls_data_pending(x, y)
  61. #define CURL_SSL_BACKEND CURLSSLBACKEND_MBEDTLS
  62. #define curlssl_sha256sum(a,b,c,d) mbedtls_sha256(a,b,c,0)
  63. /* This might cause libcurl to use a weeker random!
  64. TODO: implement proper use of Polarssl's CTR-DRBG or HMAC-DRBG and use that
  65. */
  66. #define curlssl_random(x,y,z) (x=x, y=y, z=z, CURLE_NOT_BUILT_IN)
  67. #endif /* USE_MBEDTLS */
  68. #endif /* HEADER_CURL_MBEDTLS_H */