ircu2.10.12 pk910 fork
[ircu2.10.12-pk.git] / include / ssl.h
1 /*
2  * IRC - Internet Relay Chat, include/ssl.h
3  * Written by David Herrmann.
4  */
5
6
7 #ifndef INCLUDED_ssl_h
8 #define INCLUDED_ssl_h
9
10
11 /* config.h is always included, but we also need "ircd_osdep.h"
12  * to get the IOResult type.
13  */
14 #include "config.h"
15 #include "ircd_osdep.h"
16
17
18 /* Forward declarations.
19  * Including "listener.h" or "msgq.h" breaks other dependencies.
20  */
21 struct Listener;
22 struct MsgQ;
23 struct Client;
24 struct ssl_session_t;
25 struct ssl_cred_t;
26 typedef struct ssl_session_t ssl_session_t;
27 typedef struct ssl_cred_t ssl_cred_t;
28
29
30 /* If an SSL backend is available, we declare HAVE_SSL. */
31 #if defined(HAVE_OPENSSL) || defined(HAVE_GNUTLS)
32     #define HAVE_SSL
33 #endif
34
35
36 /* Defines whether the fd is a client or server SSL handle. */
37 #define SSL_CLIENT 0
38 #define SSL_SERVER 1
39
40
41 /* Diffie-Hellman bits. */
42 #define SSL_DH_BITS 1024 /* We support ~ bits. */
43 #define SSL_DH_RBITS 1024 /* We require the other server to use at least ~ bits. */
44
45
46 /* Set certificate and trusted CAs. */
47 extern void ssl_setcert(const char *cert);
48 extern void ssl_clearcert();
49 extern void ssl_addtrust(const char *trust);
50 extern void ssl_cleartrusts();
51
52
53 extern void ssl_init(void);
54 extern void ssl_deinit(void);
55
56 extern ssl_cred_t *ssl_cred_new(unsigned int mode, char *cert, char **trusts);
57 extern void ssl_cred_free(ssl_cred_t *cred);
58
59 extern ssl_session_t *ssl_session_new(unsigned int mode);
60 extern void ssl_session_shutdown(ssl_session_t *ssl);
61 extern void ssl_session_free(ssl_session_t *ssl);
62
63 extern void ssl_accept(struct Listener *listener, signed int fd);
64 extern signed int ssl_connect(struct Client *cptr);
65 extern void ssl_close(signed int fd, ssl_session_t *ssl, const char *buf, unsigned int len);
66
67 extern signed int ssl_send(signed int fd, ssl_session_t *ssl, const char *buf, unsigned int len);
68 extern IOResult ssl_recv(signed int fd, ssl_session_t *ssl, char *buf, unsigned int len, unsigned int *count_out);
69 extern IOResult ssl_sendv(signed int fd, ssl_session_t *ssl, struct MsgQ *buf, unsigned int *count_in, unsigned int *count_out);
70
71 extern const char *ssl_cipherstr(ssl_session_t *ssl);
72
73
74 #endif /* INCLUDED_ssl_h */
75