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:
@@ -98,17 +98,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)
|
||||
|
||||
@@ -82,17 +82,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)
|
||||
|
||||
@@ -62,17 +62,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)
|
||||
|
||||
@@ -64,17 +64,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user