diff --git a/hash/md2.cpp b/hash/md2.cpp index 53434727..84c5d1b2 100644 --- a/hash/md2.cpp +++ b/hash/md2.cpp @@ -81,14 +81,6 @@ MD2::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce } -//----------------------------------------------------------------------------- -void -MD2::update (const void *restrict data, size_t size) noexcept -{ - update (static_cast (data), size); -} - - //----------------------------------------------------------------------------- static const size_t M_OFFSET = 16; static const size_t M_LENGTH = 16; @@ -96,8 +88,10 @@ static const size_t M_LENGTH = 16; //----------------------------------------------------------------------------- void -MD2::update (const uint8_t *restrict data, size_t size) noexcept +MD2::update (const void *restrict _data, size_t size) noexcept { + auto data = static_cast (_data); + uint8_t *M = X + M_OFFSET; size_t offset = m_total % M_LENGTH; size_t remain = M_LENGTH - offset; diff --git a/hash/md2.hpp b/hash/md2.hpp index 9ac59715..3c2f6374 100644 --- a/hash/md2.hpp +++ b/hash/md2.hpp @@ -30,8 +30,7 @@ namespace util { namespace hash { public: MD2 (); - void update (const uint8_t *restrict data, size_t len) noexcept; - void update (const void *restrict data, size_t len) noexcept; + void update (const void *restrict data, size_t len) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void finish (void); diff --git a/hash/md4.cpp b/hash/md4.cpp index 6d4b4151..a396315f 100644 --- a/hash/md4.cpp +++ b/hash/md4.cpp @@ -100,16 +100,11 @@ MD4::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce //----------------------------------------------------------------------------- void -MD4::update (const void *restrict data, size_t size) noexcept +MD4::update (const void *restrict _data, size_t size) noexcept { - update (static_cast (data), size); -} + CHECK (_data); + auto data = static_cast (_data); - -//----------------------------------------------------------------------------- -void -MD4::update (const uint8_t *restrict data, size_t size) noexcept -{ size_t offset = m_total % sizeof (Xb); size_t remain = sizeof (Xb) - offset; diff --git a/hash/md4.hpp b/hash/md4.hpp index 8c3ee9ea..dad98dee 100644 --- a/hash/md4.hpp +++ b/hash/md4.hpp @@ -31,7 +31,6 @@ namespace util { namespace hash { MD4(); void update (const void *restrict data, size_t len) noexcept; - void update (const uint8_t *restrict data, size_t len) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void finish (void); diff --git a/hash/md5.cpp b/hash/md5.cpp index 86368625..35ce8a29 100644 --- a/hash/md5.cpp +++ b/hash/md5.cpp @@ -132,16 +132,11 @@ MD5::update (const uint8_t *restrict first, const uint8_t *restrict last) noexce //----------------------------------------------------------------------------- void -MD5::update (const void *restrict data, size_t len) noexcept +MD5::update (const void *restrict _data, size_t size) noexcept { - MD5::update (static_cast (data), len); -} + CHECK (_data); + auto data = static_cast (_data); - -//----------------------------------------------------------------------------- -void -MD5::update (const uint8_t *restrict data, size_t size) noexcept -{ size_t offset = m_total % sizeof (Xb); size_t remain = sizeof (Xb) - offset; diff --git a/hash/md5.hpp b/hash/md5.hpp index 1be855d0..58679232 100644 --- a/hash/md5.hpp +++ b/hash/md5.hpp @@ -34,7 +34,6 @@ namespace util { namespace hash { MD5(); void update (const void *restrict data, size_t len) noexcept; - void update (const uint8_t *restrict data, size_t len) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void finish (void); @@ -52,9 +51,6 @@ namespace util { namespace hash { uint8_t Xb[64]; }; }; - - typedef uint8_t md5_t; - md5_t md5 (const void *restrict data, size_t len); } } #endif diff --git a/hash/ripemd.cpp b/hash/ripemd.cpp index b1cb6f90..2d5376bc 100644 --- a/hash/ripemd.cpp +++ b/hash/ripemd.cpp @@ -63,9 +63,11 @@ RIPEMD::update ( //----------------------------------------------------------------------------- void -RIPEMD::update (const uint8_t *restrict data, size_t len) noexcept +RIPEMD::update (const void *restrict _data, size_t len) noexcept { - CHECK (data); + CHECK (_data); + + auto data = static_cast (_data); size_t cursor = 0; diff --git a/hash/ripemd.hpp b/hash/ripemd.hpp index 80d964a8..1ab6db67 100644 --- a/hash/ripemd.hpp +++ b/hash/ripemd.hpp @@ -30,7 +30,7 @@ namespace util { namespace hash { public: RIPEMD(); - void update (const uint8_t *restrict, size_t) noexcept; + void update (const void *restrict, size_t) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; digest_t digest (void) const; diff --git a/hash/sha1.cpp b/hash/sha1.cpp index cc47b4c3..25243082 100644 --- a/hash/sha1.cpp +++ b/hash/sha1.cpp @@ -135,11 +135,14 @@ SHA1::update ( //----------------------------------------------------------------------------- void -SHA1::update (const uint8_t *restrict data, size_t size) noexcept +SHA1::update (const void *restrict _data, size_t size) noexcept { + CHECK (_data); CHECK_EQ (state, READY); CHECK_GE (std::numeric_limits::max () - total, size); + auto data = static_cast (_data); + while (size > 0) { // Copy the data into the remaining available buffer slots const size_t offset = total % BLOCK_BYTES; diff --git a/hash/sha1.hpp b/hash/sha1.hpp index e90d5912..022018e3 100644 --- a/hash/sha1.hpp +++ b/hash/sha1.hpp @@ -34,7 +34,7 @@ namespace util { namespace hash { public: SHA1(); - void update (const uint8_t *restrict, size_t) noexcept; + void update (const void *restrict, size_t) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void finish (void); diff --git a/hash/sha2.cpp b/hash/sha2.cpp index 84f76b8d..1ff0e098 100644 --- a/hash/sha2.cpp +++ b/hash/sha2.cpp @@ -183,8 +183,11 @@ SHA256::update (const uint8_t *restrict first, const uint8_t *restrict last) noe //----------------------------------------------------------------------------- void -SHA256::update (const uint8_t *restrict data, size_t length) noexcept +SHA256::update (const void *restrict _data, size_t length) noexcept { + CHECK (_data); + auto data = static_cast (_data); + while (length) { size_t buffered = m_total % sizeof (M); size_t chunk = std::min (sizeof (M) - buffered, length); diff --git a/hash/sha2.hpp b/hash/sha2.hpp index 0724cfd0..c72f65b6 100644 --- a/hash/sha2.hpp +++ b/hash/sha2.hpp @@ -31,7 +31,7 @@ namespace util { namespace hash { public: SHA256(); - void update (const uint8_t *restrict, size_t) noexcept; + void update (const void *restrict, size_t) noexcept; void update (const uint8_t *restrict first, const uint8_t *restrict last) noexcept; void finish (void);