17 lines
446 B
C++
17 lines
446 B
C++
// 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);
|