feat: HMAC-SHA256 signing module with native tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-13 14:20:24 -07:00
parent 74bff0912b
commit 47f3f6afef
4 changed files with 116 additions and 0 deletions

16
firmware/lib/hmac/hmac.h Normal file
View File

@@ -0,0 +1,16 @@
// firmware/src/hmac.h
#pragma once
#include <stdint.h>
#ifdef NATIVE_TEST
#include <string>
using HString = std::string;
#else
#include <Arduino.h>
using HString = String;
#endif
// Returns lowercase hex-encoded HMAC-SHA256 signature.
// Message signed: device_id + ":" + timestamp_str + ":" + hex(sha256(body))
HString hmac_sign(const HString& secret_hex, const HString& device_id,
uint32_t timestamp, const HString& body);