]> jfr.im git - solanum.git/blame - libratbox/src/nossl.c
libratbox sync - r25796
[solanum.git] / libratbox / src / nossl.c
CommitLineData
db137867
AC
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>
fc8711d1 29#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS)
db137867 30
a9fb3ed0
VY
31#include "arc4random.h"
32
db137867
AC
33#include <commio-int.h>
34#include <commio-ssl.h>
35
36int
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
a9fb3ed0
VY
58static void
59rb_stir_arc4random(void *unused)
60{
61 arc4random_stir();
62}
63
64
db137867
AC
65int rb_init_prng(const char *path, prng_seed_t seed_type)
66{
a9fb3ed0
VY
67 /* xxx this ignores the parameters above */
68 arc4random_stir();
69 rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300);
70 return 1;
db137867
AC
71}
72
73int
74rb_get_random(void *buf, size_t length)
75{
a9fb3ed0
VY
76 uint32_t rnd = 0, i;
77 uint8_t *xbuf = buf;
78 for (i = 0; i < sizeof(length); i++)
79 {
80 if(i % 4 == 0)
81 rnd = arc4random();
82 xbuf[i] = rnd;
83 rnd >>= 8;
84 }
85 return 1;
86}
87
88int
89rb_get_pseudo_random(void *buf, size_t length)
90{
91 return rb_get_random(buf, length);
db137867
AC
92}
93
a9fb3ed0 94
db137867
AC
95const char *
96rb_get_ssl_strerror(rb_fde_t *F)
97{
98 static const char *nosupport = "SSL/TLS not supported";
99 return nosupport;
100}
101
102void
103rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout)
104{
105 return;
106}
107
108void
109rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout)
110{
111 return;
112}
113
114void
115rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
116 struct sockaddr *clocal, int socklen, CNCB *callback, void *data, int timeout)
117{
118 return;
119}
120
121int
122rb_supports_ssl(void)
123{
124 return 0;
125}
126
127void
128rb_ssl_shutdown(rb_fde_t * F)
129{
130 return;
131}
a8f0b117
AC
132
133void
a9fb3ed0 134rb_ssl_accept_setup(rb_fde_t * F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
a8f0b117
AC
135{
136 return;
137}
138
139ssize_t
140rb_ssl_read(rb_fde_t * F, void *buf, size_t count)
141{
c2ac22cc
VY
142 errno = ENOSYS;
143 return -1;
a8f0b117
AC
144}
145
146ssize_t
147rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
148{
c2ac22cc
VY
149 errno = ENOSYS;
150 return -1;
a8f0b117
AC
151}
152
c2ac22cc
VY
153unsigned int
154rb_ssl_handshake_count(rb_fde_t *F)
155{
156 return 0;
157}
158
159void
160rb_ssl_clear_handshake_count(rb_fde_t *F)
161{
162 return;
163}
164
db137867
AC
165#endif /* !HAVE_OPENSSL */
166