0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 06:28:55 +02:00

ircd::crh: Fix buffer argument types; cleanup.

This commit is contained in:
Jason Volk 2017-10-03 03:58:39 -07:00
parent 234f7e34d7
commit 67dba9c471
3 changed files with 19 additions and 19 deletions

View file

@ -54,12 +54,12 @@ struct ircd::crh::hash
virtual size_t length() const = 0;
virtual void finalize(const mutable_raw_buffer &) = 0;
virtual void extract(const mutable_raw_buffer &) const = 0;
virtual void update(const const_buffer &) = 0;
virtual void update(const const_raw_buffer &) = 0;
// conveniences
void finalize(const mutable_raw_buffer &) const;
void operator()(const mutable_raw_buffer &out, const const_buffer &in);
hash &operator+=(const const_buffer &);
void operator()(const mutable_raw_buffer &out, const const_raw_buffer &in);
hash &operator+=(const const_raw_buffer &);
virtual ~hash() noexcept;
};
@ -81,9 +81,9 @@ struct ircd::crh::sha256
size_t length() const override;
void finalize(const mutable_raw_buffer &) override;
void extract(const mutable_raw_buffer &) const override;
void update(const const_buffer &) override;
void update(const const_raw_buffer &) override;
sha256(const mutable_raw_buffer &, const const_buffer &);
sha256(const mutable_raw_buffer &, const const_raw_buffer &);
sha256();
~sha256() noexcept;
};

View file

@ -30,7 +30,7 @@ noexcept
}
ircd::crh::hash &
ircd::crh::hash::operator+=(const const_buffer &buf)
ircd::crh::hash::operator+=(const const_raw_buffer &buf)
{
update(buf);
return *this;
@ -38,7 +38,7 @@ ircd::crh::hash::operator+=(const const_buffer &buf)
void
ircd::crh::hash::operator()(const mutable_raw_buffer &out,
const const_buffer &in)
const const_raw_buffer &in)
{
update(in);
finalize(out);

View file

@ -22,16 +22,6 @@
#include <openssl/err.h>
#include <openssl/sha.h>
///////////////////////////////////////////////////////////////////////////////
//
// hash.h
//
namespace ircd::crh
{
static void finalize(struct sha256::ctx *const &, const mutable_raw_buffer &);
}
template<class exception = ircd::error,
int ERR_CODE = 0,
class function,
@ -54,6 +44,16 @@ call_openssl(function&& f, args&&... a)
return ret;
};
///////////////////////////////////////////////////////////////////////////////
//
// hash.h
//
namespace ircd::crh
{
static void finalize(struct sha256::ctx *const &, const mutable_raw_buffer &);
}
struct ircd::crh::sha256::ctx
:SHA256_CTX
{
@ -78,7 +78,7 @@ ircd::crh::sha256::sha256()
/// One-shot functor. Immediately calls operator().
ircd::crh::sha256::sha256(const mutable_raw_buffer &out,
const const_buffer &in)
const const_raw_buffer &in)
:sha256{}
{
operator()(out, in);
@ -90,7 +90,7 @@ noexcept
}
void
ircd::crh::sha256::update(const const_buffer &buf)
ircd::crh::sha256::update(const const_raw_buffer &buf)
{
call_openssl(::SHA256_Update, ctx.get(), data(buf), size(buf));
}