1 #ifndef HEADER_CURL_GTLS_H 2 #define HEADER_CURL_GTLS_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 27 #include "curl_setup.h" 28 #include <curl/curl.h> 29 30 #ifdef USE_GNUTLS 31 32 #include <gnutls/gnutls.h> 33 #include "timeval.h" 34 35 #ifdef HAVE_GNUTLS_SRP 36 /* the function exists */ 37 #ifdef USE_TLS_SRP 38 /* the functionality is not disabled */ 39 #define USE_GNUTLS_SRP 40 #endif 41 #endif 42 43 struct Curl_easy; 44 struct Curl_cfilter; 45 struct ssl_primary_config; 46 struct ssl_config_data; 47 struct ssl_peer; 48 struct ssl_connect_data; 49 50 int Curl_glts_get_ietf_proto(gnutls_session_t session); 51 52 struct gtls_shared_creds { 53 gnutls_certificate_credentials_t creds; 54 char *CAfile; /* CAfile path used to generate X509 store */ 55 struct curltime time; /* when the shared creds was created */ 56 size_t refcount; 57 BIT(trust_setup); /* x509 anchors + CRLs have been set up */ 58 }; 59 60 CURLcode Curl_gtls_shared_creds_create(struct Curl_easy *data, 61 struct gtls_shared_creds **pcreds); 62 CURLcode Curl_gtls_shared_creds_up_ref(struct gtls_shared_creds *creds); 63 void Curl_gtls_shared_creds_free(struct gtls_shared_creds **pcreds); 64 65 struct gtls_ctx { 66 gnutls_session_t session; 67 struct gtls_shared_creds *shared_creds; 68 #ifdef USE_GNUTLS_SRP 69 gnutls_srp_client_credentials_t srp_client_cred; 70 #endif 71 CURLcode io_result; /* result of last IO cfilter operation */ 72 BIT(sent_shutdown); 73 }; 74 75 size_t Curl_gtls_version(char *buffer, size_t size); 76 77 typedef CURLcode Curl_gtls_ctx_setup_cb(struct Curl_cfilter *cf, 78 struct Curl_easy *data, 79 void *user_data); 80 81 CURLcode Curl_gtls_ctx_init(struct gtls_ctx *gctx, 82 struct Curl_cfilter *cf, 83 struct Curl_easy *data, 84 struct ssl_peer *peer, 85 const unsigned char *alpn, size_t alpn_len, 86 struct ssl_connect_data *connssl, 87 Curl_gtls_ctx_setup_cb *cb_setup, 88 void *cb_user_data, 89 void *ssl_user_data); 90 91 CURLcode Curl_gtls_client_trust_setup(struct Curl_cfilter *cf, 92 struct Curl_easy *data, 93 struct gtls_ctx *gtls); 94 95 CURLcode Curl_gtls_verifyserver(struct Curl_easy *data, 96 gnutls_session_t session, 97 struct ssl_primary_config *config, 98 struct ssl_config_data *ssl_config, 99 struct ssl_peer *peer, 100 const char *pinned_key); 101 102 /* Extract TLS session and place in cache, if configured. */ 103 CURLcode Curl_gtls_cache_session(struct Curl_cfilter *cf, 104 struct Curl_easy *data, 105 const char *ssl_peer_key, 106 gnutls_session_t session, 107 int lifetime_secs, 108 const char *alpn); 109 110 extern const struct Curl_ssl Curl_ssl_gnutls; 111 112 #endif /* USE_GNUTLS */ 113 #endif /* HEADER_CURL_GTLS_H */ 114