16f9cba8fSJoseph Mingrone /* 26f9cba8fSJoseph Mingrone * Copyright (c) 2002 - 2003 36f9cba8fSJoseph Mingrone * NetGroup, Politecnico di Torino (Italy) 46f9cba8fSJoseph Mingrone * All rights reserved. 56f9cba8fSJoseph Mingrone * 66f9cba8fSJoseph Mingrone * Redistribution and use in source and binary forms, with or without 76f9cba8fSJoseph Mingrone * modification, are permitted provided that the following conditions 86f9cba8fSJoseph Mingrone * are met: 96f9cba8fSJoseph Mingrone * 106f9cba8fSJoseph Mingrone * 1. Redistributions of source code must retain the above copyright 116f9cba8fSJoseph Mingrone * notice, this list of conditions and the following disclaimer. 126f9cba8fSJoseph Mingrone * 2. Redistributions in binary form must reproduce the above copyright 136f9cba8fSJoseph Mingrone * notice, this list of conditions and the following disclaimer in the 146f9cba8fSJoseph Mingrone * documentation and/or other materials provided with the distribution. 156f9cba8fSJoseph Mingrone * 3. Neither the name of the Politecnico di Torino nor the names of its 166f9cba8fSJoseph Mingrone * contributors may be used to endorse or promote products derived from 176f9cba8fSJoseph Mingrone * this software without specific prior written permission. 186f9cba8fSJoseph Mingrone * 196f9cba8fSJoseph Mingrone * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 206f9cba8fSJoseph Mingrone * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 216f9cba8fSJoseph Mingrone * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 226f9cba8fSJoseph Mingrone * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 236f9cba8fSJoseph Mingrone * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 246f9cba8fSJoseph Mingrone * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 256f9cba8fSJoseph Mingrone * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 266f9cba8fSJoseph Mingrone * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 276f9cba8fSJoseph Mingrone * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 286f9cba8fSJoseph Mingrone * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 296f9cba8fSJoseph Mingrone * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 306f9cba8fSJoseph Mingrone * 316f9cba8fSJoseph Mingrone */ 326f9cba8fSJoseph Mingrone 336f9cba8fSJoseph Mingrone #ifndef __SSLUTILS_H__ 346f9cba8fSJoseph Mingrone #define __SSLUTILS_H__ 356f9cba8fSJoseph Mingrone 366f9cba8fSJoseph Mingrone #ifdef HAVE_OPENSSL 37*afdbf109SJoseph Mingrone #include "pcap/socket.h" // for PCAP_SOCKET 38*afdbf109SJoseph Mingrone // If this is OpenSSL 1.0, at least one header may trigger a -Wdocumentation 39*afdbf109SJoseph Mingrone // in Clang, which should not be a problem of this header or a file that 40*afdbf109SJoseph Mingrone // includes it. 41*afdbf109SJoseph Mingrone #include "diag-control.h" 42*afdbf109SJoseph Mingrone DIAG_OFF_DOCUMENTATION 436f9cba8fSJoseph Mingrone #include <openssl/ssl.h> 446f9cba8fSJoseph Mingrone #include <openssl/err.h> 45*afdbf109SJoseph Mingrone DIAG_ON_DOCUMENTATION 466f9cba8fSJoseph Mingrone 476f9cba8fSJoseph Mingrone /* 486f9cba8fSJoseph Mingrone * Utility functions 496f9cba8fSJoseph Mingrone */ 506f9cba8fSJoseph Mingrone 516f9cba8fSJoseph Mingrone void ssl_set_certfile(const char *certfile); 526f9cba8fSJoseph Mingrone void ssl_set_keyfile(const char *keyfile); 536f9cba8fSJoseph Mingrone int ssl_init_once(int is_server, int enable_compression, char *errbuf, size_t errbuflen); 54*afdbf109SJoseph Mingrone SSL *ssl_promotion(int is_server, PCAP_SOCKET s, char *errbuf, size_t errbuflen); 556f9cba8fSJoseph Mingrone void ssl_finish(SSL *ssl); 566f9cba8fSJoseph Mingrone int ssl_send(SSL *, char const *buffer, int size, char *errbuf, size_t errbuflen); 576f9cba8fSJoseph Mingrone int ssl_recv(SSL *, char *buffer, int size, char *errbuf, size_t errbuflen); 586f9cba8fSJoseph Mingrone 596f9cba8fSJoseph Mingrone // The SSL parameters are used 606f9cba8fSJoseph Mingrone #define _U_NOSSL_ 616f9cba8fSJoseph Mingrone 626f9cba8fSJoseph Mingrone #else // HAVE_OPENSSL 636f9cba8fSJoseph Mingrone 646f9cba8fSJoseph Mingrone // This saves us from a lot of ifdefs: 656f9cba8fSJoseph Mingrone #define SSL void const 666f9cba8fSJoseph Mingrone 676f9cba8fSJoseph Mingrone // The SSL parameters are unused 686f9cba8fSJoseph Mingrone #define _U_NOSSL_ _U_ 696f9cba8fSJoseph Mingrone 706f9cba8fSJoseph Mingrone #endif // HAVE_OPENSSL 716f9cba8fSJoseph Mingrone 726f9cba8fSJoseph Mingrone #endif // __SSLUTILS_H__ 73