1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Simplify the hashing API by removing the need to remember the final hash

This commit is contained in:
Rhys Weatherley
2015-03-14 15:36:40 +10:00
parent e7175a80f3
commit 0c52bf0d50
17 changed files with 94 additions and 196 deletions

View File

@@ -85,17 +85,7 @@ bool testHash_N(Hash *hash, const struct TestHashVector *test, size_t inc)
size_t posn, len;
uint8_t value[HASH_SIZE];
for (posn = 0; posn < size; posn += inc) {
len = size - posn;
if (len > inc)
len = inc;
hash->update(test->data + posn, len);
}
hash->finalize(value, sizeof(value));
if (memcmp(value, test->hash, sizeof(value)) != 0)
return false;
// Try again to make sure the hash resets.
hash->reset();
for (posn = 0; posn < size; posn += inc) {
len = size - posn;
if (len > inc)