From ea097c9f53f74ce03387ba9e542c981a7442e28a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 6 Nov 2017 13:29:50 -0800 Subject: [PATCH] ircd: Split crypto.cc to hash.cc and rand.cc. --- ircd/Makefile.am | 3 ++- ircd/hash.cc | 40 +++++++++++++++++++++++++++++++++++++ ircd/{crypto.cc => rand.cc} | 30 ---------------------------- 3 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 ircd/hash.cc rename ircd/{crypto.cc => rand.cc} (84%) diff --git a/ircd/Makefile.am b/ircd/Makefile.am index ed47d5ecd..75e028c00 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -60,7 +60,8 @@ libircd_la_LIBADD = \ libircd_la_SOURCES = \ client.cc \ - crypto.cc \ + hash.cc \ + rand.cc \ ctx.cc \ db.cc \ exception.cc \ diff --git a/ircd/hash.cc b/ircd/hash.cc new file mode 100644 index 000000000..74f9cbdbb --- /dev/null +++ b/ircd/hash.cc @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 Charybdis Development Team + * Copyright (C) 2017 Jason Volk + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice is present in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +ircd::crh::hash::~hash() +noexcept +{ +} + +ircd::crh::hash & +ircd::crh::hash::operator+=(const const_raw_buffer &buf) +{ + update(buf); + return *this; +} + +void +ircd::crh::hash::operator()(const mutable_raw_buffer &out, + const const_raw_buffer &in) +{ + update(in); + finalize(out); +} diff --git a/ircd/crypto.cc b/ircd/rand.cc similarity index 84% rename from ircd/crypto.cc rename to ircd/rand.cc index 323cf3bb6..e313e8e05 100644 --- a/ircd/crypto.cc +++ b/ircd/rand.cc @@ -19,36 +19,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/////////////////////////////////////////////////////////////////////////////// -// -// hash.h -// - -ircd::crh::hash::~hash() -noexcept -{ -} - -ircd::crh::hash & -ircd::crh::hash::operator+=(const const_raw_buffer &buf) -{ - update(buf); - return *this; -} - -void -ircd::crh::hash::operator()(const mutable_raw_buffer &out, - const const_raw_buffer &in) -{ - update(in); - finalize(out); -} - -/////////////////////////////////////////////////////////////////////////////// -// -// rand.h -// - decltype(ircd::rand::device) ircd::rand::device { // on linux: uses RDRND or /dev/urandom