diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-08-09 19:23:48 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-08-09 19:23:48 -0700 |
commit | bddaf98342a461f4e02389d4db390098fb423fbf (patch) | |
tree | 30e472aa10754b2c93a24a3519387b766e814907 /includes/BHashes.h | |
parent | 032872bf6f7c14b0fdbc9cd75daae56bbeb50af0 (diff) |
Fixing even more warnings.
Diffstat (limited to 'includes/BHashes.h')
-rw-r--r-- | includes/BHashes.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/includes/BHashes.h b/includes/BHashes.h index c08b48d..3d7be49 100644 --- a/includes/BHashes.h +++ b/includes/BHashes.h @@ -3,6 +3,8 @@ #include <Exceptions.h> #include <tomcrypt.h> +#undef max + namespace Balau { template<const struct ltc_hash_descriptor * desc> @@ -13,9 +15,16 @@ class Hash { int r = desc->init(&m_state); IAssert(r == CRYPT_OK, "init for %s returned %i", desc->name, r); } - void update(const uint8_t * data, const size_t len) { - int r = desc->process(&m_state, data, len); - IAssert(r == CRYPT_OK, "process for %s returned %i", desc->name, r); + void update(const uint8_t * data, size_t len) { + while (len) { + unsigned long blockLen = std::numeric_limits<unsigned long>::max(); + if (blockLen > len) + blockLen = (unsigned long) len; + int r = desc->process(&m_state, data, blockLen); + data += blockLen; + len -= blockLen; + IAssert(r == CRYPT_OK, "process for %s returned %i", desc->name, r); + } } unsigned final(void * digest, unsigned outlen) { AAssert(outlen >= digestSize(), "digest size too small being passed on for %s: %u instead of %u", name(), outlen, digestSize()); |