feat: HMAC-SHA256 signing module with native tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
firmware/lib/hmac/hmac.h
Normal file
16
firmware/lib/hmac/hmac.h
Normal 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);
|
||||
Reference in New Issue
Block a user