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 (void) {
finish ();
MD2::digest (void) const {
digest_t d;
memcpy (d.data (), X, sizeof (d));
return d;

View File

@ -36,13 +36,12 @@ namespace util {
void update (const uint8_t *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);
private:
void transform (void);
void finish (void);
uint64_t m_total;

View File

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

View File

@ -35,12 +35,12 @@ namespace util {
void update (const void *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);
private:
void transform (void);
void finish (void);
uint64_t m_total;

View File

@ -141,9 +141,7 @@ MD5::update (const uint8_t *data, size_t size) {
MD5::digest_t
MD5::digest (void) {
finish ();
MD5::digest (void) const {
static_assert (sizeof (ABCD) == sizeof (digest_t),
"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 uint8_t *data, size_t len);
digest_t digest (void);
void finish (void);
digest_t digest (void) const;
void reset (void);
private:
void transform (void);
void finish (void);
uint64_t m_total;
std::array<uint32_t, 4> ABCD;

View File

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