| 1 |
michael |
7106 |
/* |
| 2 |
|
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
|
* |
| 4 |
michael |
7149 |
* Copyright (c) 2015 Attila Molnar <attilamolnar@hush.com> |
| 5 |
|
|
* Copyright (c) 2015 Adam <Adam@anope.org> |
| 6 |
michael |
7163 |
* Copyright (c) 2015-2016 ircd-hybrid development team |
| 7 |
michael |
7106 |
* |
| 8 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 9 |
|
|
* it under the terms of the GNU General Public License as published by |
| 10 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 11 |
|
|
* (at your option) any later version. |
| 12 |
|
|
* |
| 13 |
|
|
* This program is distributed in the hope that it will be useful, |
| 14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
|
|
* GNU General Public License for more details. |
| 17 |
|
|
* |
| 18 |
|
|
* You should have received a copy of the GNU General Public License |
| 19 |
|
|
* along with this program; if not, write to the Free Software |
| 20 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 21 |
|
|
* USA |
| 22 |
|
|
*/ |
| 23 |
|
|
|
| 24 |
|
|
/*! \file tls.h |
| 25 |
|
|
* \brief A header for generic TLS functions |
| 26 |
|
|
* \version $Id$ |
| 27 |
|
|
*/ |
| 28 |
|
|
|
| 29 |
|
|
#ifndef INCLUDED_tls_h |
| 30 |
|
|
#define INCLUDED_tls_h |
| 31 |
|
|
|
| 32 |
|
|
#ifdef HAVE_LIBCRYPTO |
| 33 |
|
|
#include "tls_openssl.h" |
| 34 |
|
|
#elif defined(HAVE_LIBGNUTLS) |
| 35 |
|
|
#include "tls_gnutls.h" |
| 36 |
|
|
#else |
| 37 |
|
|
#include "tls_none.h" |
| 38 |
|
|
#endif |
| 39 |
|
|
|
| 40 |
|
|
typedef enum _tls_role |
| 41 |
|
|
{ |
| 42 |
|
|
TLS_ROLE_SERVER, |
| 43 |
|
|
TLS_ROLE_CLIENT |
| 44 |
|
|
} tls_role_t; |
| 45 |
|
|
|
| 46 |
|
|
typedef enum _tls_handshake_status |
| 47 |
|
|
{ |
| 48 |
|
|
TLS_HANDSHAKE_DONE, |
| 49 |
|
|
TLS_HANDSHAKE_WANT_READ, |
| 50 |
|
|
TLS_HANDSHAKE_WANT_WRITE, |
| 51 |
|
|
TLS_HANDSHAKE_ERROR |
| 52 |
|
|
} tls_handshake_status_t; |
| 53 |
|
|
|
| 54 |
michael |
7272 |
extern int tls_is_initialized(void); |
| 55 |
michael |
7106 |
extern void tls_init(void); |
| 56 |
|
|
extern int tls_new_cred(void); |
| 57 |
|
|
|
| 58 |
|
|
extern const char *tls_get_cipher(const tls_data_t *); |
| 59 |
|
|
|
| 60 |
|
|
extern int tls_isusing(tls_data_t *); |
| 61 |
|
|
extern int tls_new(tls_data_t *, int, tls_role_t); |
| 62 |
|
|
extern void tls_free(tls_data_t *); |
| 63 |
|
|
|
| 64 |
|
|
extern tls_handshake_status_t tls_handshake(tls_data_t *, tls_role_t, const char **); |
| 65 |
|
|
extern int tls_read(tls_data_t *, char *, size_t, int *); |
| 66 |
|
|
extern int tls_write(tls_data_t *, const char *, size_t, int *); |
| 67 |
|
|
|
| 68 |
|
|
extern void tls_shutdown(tls_data_t *); |
| 69 |
|
|
|
| 70 |
|
|
extern int tls_set_ciphers(tls_data_t *, const char *); |
| 71 |
|
|
|
| 72 |
michael |
7143 |
extern int tls_verify_cert(tls_data_t *, tls_md_t, char **); |
| 73 |
michael |
7106 |
|
| 74 |
|
|
#endif /* INCLUDED_tls_h */ |