Implemented better testing and fixed skipepd frames

This commit is contained in:
Martino Ferrari
2026-07-01 16:39:34 +02:00
parent 7a326c5d78
commit 0bea41f866
46 changed files with 4358 additions and 1739 deletions
+13 -4
View File
@@ -18,18 +18,27 @@
#include <cstdlib>
#include <ctime>
#include <chrono>
#include <random>
namespace StreamHubClient {
/* ── Helpers ─────────────────────────────────────────────────────────────── */
static std::string base64Key() {
/* Generate 16 random bytes and base64-encode them */
/* HI-7: use /dev/urandom (CSPRNG) instead of srand(time)/rand() */
uint8_t raw[16];
srand(static_cast<unsigned>(time(nullptr)));
for (int i = 0; i < 16; i++) {
raw[i] = static_cast<uint8_t>(rand() & 0xFF);
int fd = open("/dev/urandom", O_RDONLY);
if (fd < 0 || read(fd, raw, sizeof(raw)) != static_cast<ssize_t>(sizeof(raw))) {
/* Fallback: std::random_device (still better than srand/rand) */
std::random_device rd;
for (size_t i = 0; i < sizeof(raw); i += sizeof(unsigned)) {
unsigned val = rd();
for (size_t j = 0; j < sizeof(unsigned) && i + j < sizeof(raw); j++) {
raw[i + j] = static_cast<uint8_t>(val >> (j * 8));
}
}
}
if (fd >= 0) { close(fd); }
char out[32];
WS_Base64Encode(raw, 16, out);
return std::string(out);
Binary file not shown.