hash: make finish public in accumulators
This commit is contained in:
parent
5c0ac60e2f
commit
b4a07538df
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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");
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user