Allow to use extended host patterns and vanilla host patterns at the same time
[privoxy.git] / ssl.h
1 #ifndef SSL_H_INCLUDED
2 #define SSL_H_INCLUDED
3 /*********************************************************************
4 *
5 * File        :  $Source: /cvsroot/ijbswa/current/ssl.h,v $
6 *
7 * Purpose     :  File with TLS/SSL extension. Contains methods for
8 *                creating, using and closing TLS/SSL connections.
9 *
10 * Copyright   :  Written by and Copyright (c) 2017 Vaclav Svec. FIT CVUT.
11 *
12 *                This program is free software; you can redistribute it
13 *                and/or modify it under the terms of the GNU General
14 *                Public License as published by the Free Software
15 *                Foundation; either version 2 of the License, or (at
16 *                your option) any later version.
17 *
18 *                This program is distributed in the hope that it will
19 *                be useful, but WITHOUT ANY WARRANTY; without even the
20 *                implied warranty of MERCHANTABILITY or FITNESS FOR A
21 *                PARTICULAR PURPOSE.  See the GNU General Public
22 *                License for more details.
23 *
24 *                The GNU General Public License should be included with
25 *                this file.  If not, you can view it at
26 *                http://www.gnu.org/copyleft/gpl.html
27 *                or write to the Free Software Foundation, Inc., 59
28 *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29 *
30 *********************************************************************/
31
32 #include "project.h"
33
34 /*
35  * Values for flag determining certificate validity.
36  * These values are compatible with return value of function
37  * mbedtls_ssl_get_verify_result(). There is no value for
38  * "invalid certificate", this value is set by the function
39  * mbedtls_ssl_get_verify_result().
40  */
41 #define SSL_CERT_VALID          0
42 #define SSL_CERT_NOT_VERIFIED   0xFFFFFFFF
43
44 /* Variables for one common RNG for all SSL use */
45 static mbedtls_ctr_drbg_context ctr_drbg;
46 static mbedtls_entropy_context  entropy;
47 static int rng_seeded;
48
49 /* Boolean functions to get information about TLS/SSL connections */
50 extern int    client_use_ssl(const struct client_state *csp);
51 extern int    server_use_ssl(const struct client_state *csp);
52 extern size_t is_ssl_pending(mbedtls_ssl_context *ssl);
53 extern int tunnel_established_successfully(const char *response, unsigned int response_len);
54
55 /* Functions for sending and receiving data over TLS/SSL connections */
56 extern int  ssl_send_data(mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len);
57 extern int ssl_send_data_delayed(mbedtls_ssl_context *ssl, const unsigned char *buf,
58                                  size_t len, unsigned int delay);
59 extern int  ssl_recv_data(mbedtls_ssl_context *ssl, unsigned char *buf, size_t maxLen);
60 extern long ssl_flush_socket(mbedtls_ssl_context *ssl, struct iob *iob);
61 extern void ssl_send_certificate_error(struct client_state *csp);
62
63 /* Functions for opening and closing TLS/SSL connections */
64 extern int  create_client_ssl_connection(struct client_state *csp);
65 extern int  create_server_ssl_connection(struct client_state *csp);
66 extern void close_client_and_server_ssl_connections(struct client_state *csp);
67 extern void close_client_ssl_connection(struct client_state *csp);
68
69 #endif /* ndef SSL_H_INCLUDED */