]> jfr.im git - irc/rqf/shadowircd.git/blame - libratbox/src/nossl.c
Copied libratbox and related stuff from shadowircd upstream.
[irc/rqf/shadowircd.git] / libratbox / src / nossl.c
CommitLineData
b57f37fb
WP
1/*
2 * libratbox: a library used by ircd-ratbox and other things
3 * nossl.c: ssl stub code
4 *
5 * Copyright (C) 2007-2008 ircd-ratbox development team
6 * Copyright (C) 2007-2008 Aaron Sethman <androsyn@ratbox.org>
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 * $Id: commio.c 24808 2008-01-02 08:17:05Z androsyn $
24 */
25
26
27#include <libratbox_config.h>
28#include <ratbox_lib.h>
af6f5d47 29#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS)
b57f37fb 30
4414eb3c
VY
31#include "arc4random.h"
32
b57f37fb
WP
33#include <commio-int.h>
34#include <commio-ssl.h>
35
94b4fbf9 36int
b57f37fb
WP
37rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
38{
39 errno = ENOSYS;
40 return 0;
41}
42
43int
44rb_init_ssl(void)
45{
46 errno = ENOSYS;
47 return -1;
48
49}
50
51int
52rb_ssl_listen(rb_fde_t *F, int backlog)
53{
54 errno = ENOSYS;
55 return -1;
56}
57
4414eb3c
VY
58static void
59rb_stir_arc4random(void *unused)
60{
61 arc4random_stir();
62}
4414eb3c 63
94b4fbf9
VY
64
65int
66rb_init_prng(const char *path, prng_seed_t seed_type)
b57f37fb 67{
4414eb3c
VY
68 /* xxx this ignores the parameters above */
69 arc4random_stir();
70 rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300);
71 return 1;
b57f37fb
WP
72}
73
74int
75rb_get_random(void *buf, size_t length)
76{
4414eb3c 77 uint32_t rnd = 0, i;
94b4fbf9
VY
78 uint8_t *xbuf = buf;
79 for(i = 0; i < length; i++)
4414eb3c
VY
80 {
81 if(i % 4 == 0)
82 rnd = arc4random();
83 xbuf[i] = rnd;
84 rnd >>= 8;
85 }
86 return 1;
87}
88
89int
90rb_get_pseudo_random(void *buf, size_t length)
91{
94b4fbf9 92 return rb_get_random(buf, length);
b57f37fb
WP
93}
94
4414eb3c 95
b57f37fb
WP
96const char *
97rb_get_ssl_strerror(rb_fde_t *F)
98{
99 static const char *nosupport = "SSL/TLS not supported";
100 return nosupport;
101}
102
94b4fbf9
VY
103void
104rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
b57f37fb
WP
105{
106 return;
107}
108
94b4fbf9
VY
109void
110rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
b57f37fb
WP
111{
112 return;
113}
114
115void
94b4fbf9
VY
116rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
117 struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout)
b57f37fb
WP
118{
119 return;
120}
121
122int
123rb_supports_ssl(void)
124{
125 return 0;
126}
127
128void
94b4fbf9
VY
129rb_ssl_shutdown(rb_fde_t *F)
130{
b57f37fb 131 return;
94b4fbf9 132}
1ac65021
WP
133
134void
94b4fbf9 135rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
1ac65021
WP
136{
137 return;
138}
139
140ssize_t
94b4fbf9 141rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
1ac65021 142{
033be687
VY
143 errno = ENOSYS;
144 return -1;
1ac65021
WP
145}
146
147ssize_t
94b4fbf9 148rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
1ac65021 149{
033be687
VY
150 errno = ENOSYS;
151 return -1;
1ac65021
WP
152}
153
033be687
VY
154unsigned int
155rb_ssl_handshake_count(rb_fde_t *F)
156{
157 return 0;
158}
94b4fbf9
VY
159
160void
033be687
VY
161rb_ssl_clear_handshake_count(rb_fde_t *F)
162{
163 return;
164}
b57f37fb 165
94b4fbf9 166#endif /* !HAVE_OPENSSL */