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