sha256: add sha256_direct()/SHA256_DIRECT() helpers

This commit is contained in:
Lennart Poettering
2022-08-19 12:53:04 +02:00
parent 00b4663813
commit 558d96240b
4 changed files with 14 additions and 14 deletions
+2 -11
View File
@@ -215,17 +215,8 @@ static void validate_sha256(void) {
0xaf, 0xac, 0x45, 0x03, 0x7a, 0xfe, 0xe9, 0xd1 }},
};
for (UINTN i = 0; i < ELEMENTSOF(array); i++) {
struct sha256_ctx hash;
uint8_t result[HASH_VALUE_SIZE];
sha256_init_ctx(&hash);
sha256_process_bytes(array[i].string, strlen8(array[i].string), &hash);
sha256_finish_ctx(&hash, result);
assert(memcmp(result, array[i].hash, HASH_VALUE_SIZE) == 0);
}
for (UINTN i = 0; i < ELEMENTSOF(array); i++)
assert(memcmp(SHA256_DIRECT(array[i].string, strlen8(array[i].string)), array[i].hash, HASH_VALUE_SIZE) == 0);
#endif
}