Files
ZephCore/tests/support/identity_utils_boundary.cpp
liquidraver 159c086485 repo: publish the host regression suite; consolidate .gitignore
- tests/ (114 host cases over production sources), the CI workflow
  (ASan/UBSan on PRs and master pushes) and REGRESSION_TEST_PLAN.md
  are tracked
- .gitignore grouped and deduplicated (173 -> 96 lines, same ignored set)
2026-09-25 21:56:48 +02:00

42 lines
1.6 KiB
C++

#include <mesh/Utils.h>
#include <stdexcept>
#include <cstring>
// Identity tests exercise fromSeed, sign/verify, ECDH and storage serialization.
// Other constructors/private-key recovery need Utils.cpp/PSA integration later.
// Fail loudly if a new test accidentally reaches those unimplemented boundaries.
// Hex helpers are pure; copied from src/Utils.cpp for the prefs.json tests
// (ConfigSerializer stores binary blobs as hex).
static uint8_t hexVal(char c) {
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
if (c >= '0' && c <= '9') return c - '0';
return 0;
}
bool mesh::Utils::fromHex(uint8_t *dest, int dest_size, const char *src_hex) {
size_t len = strlen(src_hex);
if (len != (size_t)(dest_size * 2)) return false;
uint8_t *dp = dest;
while ((size_t)(dp - dest) < (size_t)dest_size) {
char ch = *src_hex++;
char cl = *src_hex++;
*dp++ = (uint8_t)((hexVal(ch) << 4) | hexVal(cl));
}
return true;
}
void mesh::Utils::printHex(Stream &s, const uint8_t *src, size_t len) {
static const char hex_chars[] = "0123456789ABCDEF";
while (len > 0) {
uint8_t b = *src++;
s.print(hex_chars[b >> 4]);
s.print(hex_chars[b & 0x0F]);
len--;
}
}
void mesh::Utils::secureZeroize(void*, size_t) {
throw std::runtime_error("Identity RNG/recovery path requires real Utils integration");
}
bool mesh::Utils::constantTimeEqual(const void*, const void*, size_t) {
throw std::runtime_error("Identity validation requires real Utils integration");
}