From af82c0eca86eab376474f5771c8aa66c5a68c1d8 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Mon, 13 Apr 2020 06:16:03 +1000 Subject: util: re-implement SHA-1 and get rid of the two third-party implementations (nw) --- src/lib/util/hashing.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/lib/util/hashing.h') diff --git a/src/lib/util/hashing.h b/src/lib/util/hashing.h index b1505c654a4..11bf7fd655e 100644 --- a/src/lib/util/hashing.h +++ b/src/lib/util/hashing.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Aaron Giles +// copyright-holders:Aaron Giles, Vas Crabb /*************************************************************************** hashing.h @@ -7,7 +7,6 @@ Hashing helper classes. ***************************************************************************/ - #ifndef MAME_UTIL_HASHING_H #define MAME_UTIL_HASHING_H @@ -16,13 +15,14 @@ #include "osdcore.h" #include "corestr.h" #include "md5.h" -#include "sha1.h" +#include #include #include namespace util { + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -50,19 +50,13 @@ public: sha1_creator() { reset(); } // reset - void reset() { sha1_init(&m_context); } + void reset(); // append data - void append(const void *data, uint32_t length) { sha1_update(&m_context, length, reinterpret_cast(data)); } + void append(const void *data, uint32_t length); // finalize and compute the final digest - sha1_t finish() - { - sha1_t result; - sha1_final(&m_context); - sha1_digest(&m_context, sizeof(result.m_raw), result.m_raw); - return result; - } + sha1_t finish(); // static wrapper to just get the digest from a block static sha1_t simple(const void *data, uint32_t length) @@ -73,8 +67,9 @@ public: } protected: - // internal state - struct sha1_ctx m_context; // internal context + uint64_t m_cnt; + std::array m_st; + uint32_t m_buf[16]; }; -- cgit v1.2.3-70-g09d2