5 #include "sw/device/silicon_creator/lib/boot_log.h"
8 #include "sw/device/silicon_creator/lib/drivers/hmac.h"
14 kDigestRegionSize =
sizeof(
boot_log_t) - kDigestRegionOffset,
16 static_assert(offsetof(
boot_log_t, digest) == 0,
17 "`digest` must be the first field of `boot_log_t`.");
18 hmac_sha256((
const char *)
boot_log + kDigestRegionOffset, kDigestRegionSize,
44 static const uint32_t kCheckShares[kHmacDigestNumWords + 1] = {
45 0x7b00d08e, 0xfdb69374, 0x336c86df, 0xff2ef417, 0xe1517012,
46 0x4bf5408c, 0x9c6a7b25, 0xf771f8fa, 0xcd468505,
50 static_assert(offsetof(
boot_log_t, digest) == 0,
51 "`digest` must be the first field of `boot_log_t`.");
53 rom_error_t error = kErrorBootLogInvalid;
55 boot_log_digest_compute(
boot_log, &actual_digest);
58 for (; launder32(i) < kHmacDigestNumWords; ++i) {
60 boot_log->
digest.digest[i] ^ actual_digest.digest[i] ^ kCheckShares[i];
66 if (launder32(error) == kErrorOk) {
71 return kErrorBootLogInvalid;
76 rom_error_t error = boot_log_check(
boot_log);
77 if (launder32(error) == kErrorOk) {