diff --git a/test/mocks/SHA256.h b/test/mocks/SHA256.h index 38e779b7d..d81c1add7 100644 --- a/test/mocks/SHA256.h +++ b/test/mocks/SHA256.h @@ -2,43 +2,26 @@ #include #include -#include // Mock SHA256 class for native testing. -// Provides a deterministic stand-in so code can hash data without Arduino crypto deps. +// Provides a fixed stand-in so code can compile without Arduino crypto deps. +// update() and resetHMAC() ignore all input; finalize() and finalizeHMAC() +// fill the requested output buffer with 0x11 bytes. class SHA256 { - uint32_t state_ = 2166136261u; - public: - void update(const void* data, size_t len) { - update(static_cast(data), len); - } + void update(const void*, size_t) {} - void update(const uint8_t* data, size_t len) { - for (size_t i = 0; i < len; ++i) { - state_ ^= data[i]; - state_ *= 16777619u; - state_ += 0x9E3779B9u; - } - } + void update(const uint8_t*, size_t) {} void finalize(uint8_t* hash, size_t hashLen) { - uint32_t value = state_; for (size_t i = 0; i < hashLen; ++i) { - value ^= value >> 13; - value *= 1274126177u; - hash[i] = static_cast((value >> ((i & 3) * 8)) & 0xFF); + hash[i] = 0x11; } } - void resetHMAC(const uint8_t* key, size_t keyLen) { - state_ = 2166136261u; - update(key, keyLen); - state_ ^= 0x36363636u; - } + void resetHMAC(const uint8_t*, size_t) {} - void finalizeHMAC(const uint8_t* key, size_t keyLen, uint8_t* hash, size_t hashLen) { - update(key, keyLen); + void finalizeHMAC(const uint8_t*, size_t, uint8_t* hash, size_t hashLen) { finalize(hash, hashLen); } };