Add utility to log hex buffer with size len (LOG_D) and remove unused legacy hex_dump

* logging buffer is pretty useful for debugging purposes, e.g. derived key values
This commit is contained in:
Guido Casati
2025-06-09 20:10:01 +02:00
parent d06790fcf2
commit bd1f266ab5
4 changed files with 33 additions and 48 deletions
-28
View File
@@ -7,34 +7,6 @@
#include <errno.h>
#include "utils.h"
const char *hexdump(const void *data, size_t data_len, char *out, size_t out_len)
{
char *p = out;
char *endp = out + out_len;
const uint8_t *q = data;
snprintf(p, endp - p, "[%zu]", data_len);
p += strlen(p);
for (size_t i = 0; i < data_len; ++i)
{
if (p >= endp)
{
static const char ellipses[] = "...";
char *s = endp - sizeof(ellipses);
if (s >= p)
{
strcpy(s, ellipses);
}
break;
}
snprintf(p, endp - p, " %02X", *q++);
p += strlen(p);
}
return out;
}
/****************************************************************************
** **
** Name: hex_char_to_hex_value() **