xref: /dflybsd-src/contrib/libpcap/sslutils.h (revision e75ef36f1332e115895388cede9dfd24ca1a806c)
1*ea16f64eSAntonio Huete Jimenez /*
2*ea16f64eSAntonio Huete Jimenez  * Copyright (c) 2002 - 2003
3*ea16f64eSAntonio Huete Jimenez  * NetGroup, Politecnico di Torino (Italy)
4*ea16f64eSAntonio Huete Jimenez  * All rights reserved.
5*ea16f64eSAntonio Huete Jimenez  *
6*ea16f64eSAntonio Huete Jimenez  * Redistribution and use in source and binary forms, with or without
7*ea16f64eSAntonio Huete Jimenez  * modification, are permitted provided that the following conditions
8*ea16f64eSAntonio Huete Jimenez  * are met:
9*ea16f64eSAntonio Huete Jimenez  *
10*ea16f64eSAntonio Huete Jimenez  * 1. Redistributions of source code must retain the above copyright
11*ea16f64eSAntonio Huete Jimenez  * notice, this list of conditions and the following disclaimer.
12*ea16f64eSAntonio Huete Jimenez  * 2. Redistributions in binary form must reproduce the above copyright
13*ea16f64eSAntonio Huete Jimenez  * notice, this list of conditions and the following disclaimer in the
14*ea16f64eSAntonio Huete Jimenez  * documentation and/or other materials provided with the distribution.
15*ea16f64eSAntonio Huete Jimenez  * 3. Neither the name of the Politecnico di Torino nor the names of its
16*ea16f64eSAntonio Huete Jimenez  * contributors may be used to endorse or promote products derived from
17*ea16f64eSAntonio Huete Jimenez  * this software without specific prior written permission.
18*ea16f64eSAntonio Huete Jimenez  *
19*ea16f64eSAntonio Huete Jimenez  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20*ea16f64eSAntonio Huete Jimenez  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21*ea16f64eSAntonio Huete Jimenez  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22*ea16f64eSAntonio Huete Jimenez  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23*ea16f64eSAntonio Huete Jimenez  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24*ea16f64eSAntonio Huete Jimenez  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25*ea16f64eSAntonio Huete Jimenez  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26*ea16f64eSAntonio Huete Jimenez  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27*ea16f64eSAntonio Huete Jimenez  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28*ea16f64eSAntonio Huete Jimenez  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29*ea16f64eSAntonio Huete Jimenez  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*ea16f64eSAntonio Huete Jimenez  *
31*ea16f64eSAntonio Huete Jimenez  */
32*ea16f64eSAntonio Huete Jimenez 
33*ea16f64eSAntonio Huete Jimenez #ifndef __SSLUTILS_H__
34*ea16f64eSAntonio Huete Jimenez #define __SSLUTILS_H__
35*ea16f64eSAntonio Huete Jimenez 
36*ea16f64eSAntonio Huete Jimenez #ifdef HAVE_OPENSSL
37*ea16f64eSAntonio Huete Jimenez #include "pcap/socket.h"  // for SOCKET
38*ea16f64eSAntonio Huete Jimenez #include <openssl/ssl.h>
39*ea16f64eSAntonio Huete Jimenez #include <openssl/err.h>
40*ea16f64eSAntonio Huete Jimenez 
41*ea16f64eSAntonio Huete Jimenez /*
42*ea16f64eSAntonio Huete Jimenez  * Utility functions
43*ea16f64eSAntonio Huete Jimenez  */
44*ea16f64eSAntonio Huete Jimenez 
45*ea16f64eSAntonio Huete Jimenez void ssl_set_certfile(const char *certfile);
46*ea16f64eSAntonio Huete Jimenez void ssl_set_keyfile(const char *keyfile);
47*ea16f64eSAntonio Huete Jimenez int ssl_init_once(int is_server, int enable_compression, char *errbuf, size_t errbuflen);
48*ea16f64eSAntonio Huete Jimenez SSL *ssl_promotion(int is_server, SOCKET s, char *errbuf, size_t errbuflen);
49*ea16f64eSAntonio Huete Jimenez void ssl_finish(SSL *ssl);
50*ea16f64eSAntonio Huete Jimenez int ssl_send(SSL *, char const *buffer, int size, char *errbuf, size_t errbuflen);
51*ea16f64eSAntonio Huete Jimenez int ssl_recv(SSL *, char *buffer, int size, char *errbuf, size_t errbuflen);
52*ea16f64eSAntonio Huete Jimenez 
53*ea16f64eSAntonio Huete Jimenez // The SSL parameters are used
54*ea16f64eSAntonio Huete Jimenez #define _U_NOSSL_
55*ea16f64eSAntonio Huete Jimenez 
56*ea16f64eSAntonio Huete Jimenez #else   // HAVE_OPENSSL
57*ea16f64eSAntonio Huete Jimenez 
58*ea16f64eSAntonio Huete Jimenez // This saves us from a lot of ifdefs:
59*ea16f64eSAntonio Huete Jimenez #define SSL void const
60*ea16f64eSAntonio Huete Jimenez 
61*ea16f64eSAntonio Huete Jimenez // The SSL parameters are unused
62*ea16f64eSAntonio Huete Jimenez #define _U_NOSSL_	_U_
63*ea16f64eSAntonio Huete Jimenez 
64*ea16f64eSAntonio Huete Jimenez #endif  // HAVE_OPENSSL
65*ea16f64eSAntonio Huete Jimenez 
66*ea16f64eSAntonio Huete Jimenez #endif  // __SSLUTILS_H__
67