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