2014-03-03 05:25:47 +01:00
|
|
|
/*
|
2016-03-06 10:49:27 +01:00
|
|
|
* librb: a library used by ircd-ratbox and other things
|
2008-04-01 18:52:26 +02:00
|
|
|
* nossl.c: ssl stub code
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2008 ircd-ratbox development team
|
|
|
|
* Copyright (C) 2007-2008 Aaron Sethman <androsyn@ratbox.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-03-03 05:25:47 +01:00
|
|
|
*
|
2008-04-01 18:52:26 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
|
|
|
* USA
|
2014-03-03 05:25:47 +01:00
|
|
|
*
|
2008-04-01 18:52:26 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-07-01 05:04:00 +02:00
|
|
|
#include <rb/rb.h>
|
2008-04-01 18:52:26 +02:00
|
|
|
|
2016-07-01 05:04:00 +02:00
|
|
|
#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_MBEDTLS)
|
2008-07-30 00:41:27 +02:00
|
|
|
#include "arc4random.h"
|
2016-07-01 05:04:00 +02:00
|
|
|
#include <rb/commio_int.h>
|
|
|
|
#include <rb/ssl.h>
|
2008-04-01 18:52:26 +02:00
|
|
|
|
2008-12-03 00:49:39 +01:00
|
|
|
int
|
2015-12-12 14:50:48 +01:00
|
|
|
rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile, const char *cipher_list)
|
2008-04-01 18:52:26 +02:00
|
|
|
{
|
|
|
|
errno = ENOSYS;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rb_init_ssl(void)
|
|
|
|
{
|
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-03-17 15:48:25 +01:00
|
|
|
rb_ssl_listen(rb_fde_t *F, int backlog, int defer_accept)
|
2008-04-01 18:52:26 +02:00
|
|
|
{
|
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-07-30 00:41:27 +02:00
|
|
|
static void
|
|
|
|
rb_stir_arc4random(void *unused)
|
|
|
|
{
|
|
|
|
arc4random_stir();
|
|
|
|
}
|
|
|
|
|
2008-12-03 00:49:39 +01:00
|
|
|
|
|
|
|
int
|
|
|
|
rb_init_prng(const char *path, prng_seed_t seed_type)
|
2008-04-01 18:52:26 +02:00
|
|
|
{
|
2008-07-30 00:41:27 +02:00
|
|
|
/* xxx this ignores the parameters above */
|
|
|
|
arc4random_stir();
|
|
|
|
rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300);
|
|
|
|
return 1;
|
2008-04-01 18:52:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rb_get_random(void *buf, size_t length)
|
|
|
|
{
|
2008-07-30 00:41:27 +02:00
|
|
|
uint32_t rnd = 0, i;
|
2008-12-03 00:49:39 +01:00
|
|
|
uint8_t *xbuf = buf;
|
|
|
|
for(i = 0; i < length; i++)
|
2008-07-30 00:41:27 +02:00
|
|
|
{
|
|
|
|
if(i % 4 == 0)
|
|
|
|
rnd = arc4random();
|
|
|
|
xbuf[i] = rnd;
|
|
|
|
rnd >>= 8;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-01 18:52:26 +02:00
|
|
|
const char *
|
|
|
|
rb_get_ssl_strerror(rb_fde_t *F)
|
|
|
|
{
|
|
|
|
static const char *nosupport = "SSL/TLS not supported";
|
|
|
|
return nosupport;
|
|
|
|
}
|
|
|
|
|
2010-01-31 19:04:20 +01:00
|
|
|
int
|
2015-05-27 23:46:46 +02:00
|
|
|
rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN], int method)
|
2010-01-31 19:04:20 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-26 21:21:23 +02:00
|
|
|
int
|
|
|
|
rb_get_ssl_certfp_file(const char *filename, uint8_t certfp[RB_SSL_CERTFP_LEN], int method)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-03 00:49:39 +01:00
|
|
|
void
|
|
|
|
rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
|
2008-04-01 18:52:26 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-03 00:49:39 +01:00
|
|
|
void
|
|
|
|
rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
|
2008-04-01 18:52:26 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-12-03 00:49:39 +01:00
|
|
|
rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
|
2016-04-24 18:11:20 +02:00
|
|
|
struct sockaddr *clocal, CNCB * callback, void *data, int timeout)
|
2008-04-01 18:52:26 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rb_supports_ssl(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-12-03 00:49:39 +01:00
|
|
|
rb_ssl_shutdown(rb_fde_t *F)
|
|
|
|
{
|
2008-04-01 18:52:26 +02:00
|
|
|
return;
|
2008-12-03 00:49:39 +01:00
|
|
|
}
|
2008-04-01 21:57:52 +02:00
|
|
|
|
|
|
|
void
|
2008-12-03 00:49:39 +01:00
|
|
|
rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
|
2008-04-01 21:57:52 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t
|
2008-12-03 00:49:39 +01:00
|
|
|
rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
|
2008-04-01 21:57:52 +02:00
|
|
|
{
|
2008-06-25 07:28:30 +02:00
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
2008-04-01 21:57:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t
|
2008-12-03 00:49:39 +01:00
|
|
|
rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
|
2008-04-01 21:57:52 +02:00
|
|
|
{
|
2008-06-25 07:28:30 +02:00
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
2008-04-01 21:57:52 +02:00
|
|
|
}
|
|
|
|
|
2008-06-25 07:28:30 +02:00
|
|
|
unsigned int
|
|
|
|
rb_ssl_handshake_count(rb_fde_t *F)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2008-12-03 00:49:39 +01:00
|
|
|
|
|
|
|
void
|
2008-06-25 07:28:30 +02:00
|
|
|
rb_ssl_clear_handshake_count(rb_fde_t *F)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-04-01 18:52:26 +02:00
|
|
|
|
2008-12-22 10:49:01 +01:00
|
|
|
void
|
|
|
|
rb_get_ssl_info(char *buf, size_t len)
|
|
|
|
{
|
2016-02-10 02:25:32 +01:00
|
|
|
snprintf(buf, len, "Not compiled with SSL support");
|
2008-12-22 10:49:01 +01:00
|
|
|
}
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2015-12-11 15:36:21 +01:00
|
|
|
int
|
|
|
|
rb_ssl_get_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN])
|
|
|
|
{
|
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
rb_ssl_get_cipher(rb_fde_t *F)
|
|
|
|
{
|
|
|
|
errno = ENOSYS;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-12-03 00:49:39 +01:00
|
|
|
#endif /* !HAVE_OPENSSL */
|