1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2015 Attila Molnar <attilamolnar@hush.com> |
5 |
* Copyright (c) 2015 Adam <Adam@anope.org> |
6 |
* Copyright (c) 2015-2018 ircd-hybrid development team |
7 |
* |
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 |
extern int tls_is_initialized(void); |
55 |
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 |
extern const char *tls_get_version(void); |
60 |
|
61 |
extern int tls_isusing(tls_data_t *); |
62 |
extern int tls_new(tls_data_t *, int, tls_role_t); |
63 |
extern void tls_free(tls_data_t *); |
64 |
|
65 |
extern tls_handshake_status_t tls_handshake(tls_data_t *, tls_role_t, const char **); |
66 |
extern int tls_read(tls_data_t *, char *, size_t, int *); |
67 |
extern int tls_write(tls_data_t *, const char *, size_t, int *); |
68 |
|
69 |
extern void tls_shutdown(tls_data_t *); |
70 |
|
71 |
extern int tls_set_ciphers(tls_data_t *, const char *); |
72 |
|
73 |
extern int tls_verify_cert(tls_data_t *, tls_md_t, char **); |
74 |
|
75 |
#endif /* INCLUDED_tls_h */ |