hash: make finish public in accumulators

This commit is contained in:
Danny Robson 2014-05-09 14:43:40 +10:00
parent 5c0ac60e2f
commit b4a07538df
8 changed files with 16 additions and 21 deletions

View File

@ -108,9 +108,7 @@ MD2::update (const uint8_t *data, size_t size) {
MD2::digest_t MD2::digest_t
MD2::digest (void) { MD2::digest (void) const {
finish ();
digest_t d; digest_t d;
memcpy (d.data (), X, sizeof (d)); memcpy (d.data (), X, sizeof (d));
return d; return d;

View File

@ -36,13 +36,12 @@ namespace util {
void update (const uint8_t *data, size_t len); void update (const uint8_t *data, size_t len);
void update (const void *data, size_t len); void update (const void *data, size_t len);
digest_t digest (void); void finish (void);
digest_t digest (void) const;
void reset (void); void reset (void);
private: private:
void transform (void); void transform (void);
void finish (void);
uint64_t m_total; uint64_t m_total;

View File

@ -110,9 +110,7 @@ MD4::update (const uint8_t *data, size_t size) {
MD4::digest_t MD4::digest_t
MD4::digest (void) { MD4::digest (void) const {
finish ();
digest_t d; digest_t d;
memcpy (d.data (), ABCD.data(), sizeof (ABCD)); memcpy (d.data (), ABCD.data(), sizeof (ABCD));
return d; return d;

View File

@ -35,12 +35,12 @@ namespace util {
void update (const void *data, size_t len); void update (const void *data, size_t len);
void update (const uint8_t *data, size_t len); void update (const uint8_t *data, size_t len);
digest_t digest (void); void finish (void);
digest_t digest (void) const;
void reset (void); void reset (void);
private: private:
void transform (void); void transform (void);
void finish (void);
uint64_t m_total; uint64_t m_total;

View File

@ -141,9 +141,7 @@ MD5::update (const uint8_t *data, size_t size) {
MD5::digest_t MD5::digest_t
MD5::digest (void) { MD5::digest (void) const {
finish ();
static_assert (sizeof (ABCD) == sizeof (digest_t), static_assert (sizeof (ABCD) == sizeof (digest_t),
"Hash state must be the same size as the final digest"); "Hash state must be the same size as the final digest");

View File

@ -36,12 +36,12 @@ namespace util {
void update (const void *data, size_t len); void update (const void *data, size_t len);
void update (const uint8_t *data, size_t len); void update (const uint8_t *data, size_t len);
digest_t digest (void); void finish (void);
digest_t digest (void) const;
void reset (void); void reset (void);
private: private:
void transform (void); void transform (void);
void finish (void);
uint64_t m_total; uint64_t m_total;
std::array<uint32_t, 4> ABCD; std::array<uint32_t, 4> ABCD;

View File

@ -42,7 +42,7 @@ RIPEMD::reset (void) {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void void
RIPEMD::update(const uint8_t *data, size_t len) { RIPEMD::update (const uint8_t *data, size_t len) {
CHECK_HARD (data); CHECK_HARD (data);
size_t cursor = 0; size_t cursor = 0;

View File

@ -22,14 +22,16 @@ namespace util {
public: public:
RIPEMD(); RIPEMD();
void update(const uint8_t*, size_t); void update (const uint8_t*, size_t);
void finish(void); digest_t digest (void) const;
digest_t digest(void) const; void finish (void);
void reset(void); void reset (void);
protected: protected:
void transform (); void transform ();
bool m_finished;
uint32_t m_state[5]; uint32_t m_state[5];
uint64_t m_length; uint64_t m_length;