]> jfr.im git - solanum.git/blob - librb/src/nossl.c
Clean up the provider status logic.
[solanum.git] / librb / src / nossl.c
1 /*
2 * librb: 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 */
24
25
26 #include <librb_config.h>
27 #include <rb_lib.h>
28 #if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_MBEDTLS)
29
30 #include "arc4random.h"
31
32 #include <commio-int.h>
33 #include <commio-ssl.h>
34
35 int
36 rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile, const char *cipher_list)
37 {
38 errno = ENOSYS;
39 return 0;
40 }
41
42 int
43 rb_init_ssl(void)
44 {
45 errno = ENOSYS;
46 return -1;
47
48 }
49
50 int
51 rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept)
52 {
53 errno = ENOSYS;
54 return -1;
55 }
56
57 static void
58 rb_stir_arc4random(void *unused)
59 {
60 arc4random_stir();
61 }
62
63
64 int
65 rb_init_prng(const char *path, prng_seed_t seed_type)
66 {
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;
71 }
72
73 int
74 rb_get_random(void *buf, size_t length)
75 {
76 uint32_t rnd = 0, i;
77 uint8_t *xbuf = buf;
78 for(i = 0; i < length; i++)
79 {
80 if(i % 4 == 0)
81 rnd = arc4random();
82 xbuf[i] = rnd;
83 rnd >>= 8;
84 }
85 return 1;
86 }
87
88 const char *
89 rb_get_ssl_strerror(rb_fde_t *F)
90 {
91 static const char *nosupport = "SSL/TLS not supported";
92 return nosupport;
93 }
94
95 int
96 rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN], int method)
97 {
98 return 0;
99 }
100
101 void
102 rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
103 {
104 return;
105 }
106
107 void
108 rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
109 {
110 return;
111 }
112
113 void
114 rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
115 struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout)
116 {
117 return;
118 }
119
120 int
121 rb_supports_ssl(void)
122 {
123 return 0;
124 }
125
126 void
127 rb_ssl_shutdown(rb_fde_t *F)
128 {
129 return;
130 }
131
132 void
133 rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
134 {
135 return;
136 }
137
138 ssize_t
139 rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
140 {
141 errno = ENOSYS;
142 return -1;
143 }
144
145 ssize_t
146 rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
147 {
148 errno = ENOSYS;
149 return -1;
150 }
151
152 unsigned int
153 rb_ssl_handshake_count(rb_fde_t *F)
154 {
155 return 0;
156 }
157
158 void
159 rb_ssl_clear_handshake_count(rb_fde_t *F)
160 {
161 return;
162 }
163
164 void
165 rb_get_ssl_info(char *buf, size_t len)
166 {
167 snprintf(buf, len, "Not compiled with SSL support");
168 }
169
170 int
171 rb_ssl_get_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN])
172 {
173 errno = ENOSYS;
174 return -1;
175 }
176
177 const char *
178 rb_ssl_get_cipher(rb_fde_t *F)
179 {
180 errno = ENOSYS;
181 return NULL;
182 }
183
184 #endif /* !HAVE_OPENSSL */