mirror of https://github.com/meshcore-dev/MeshCore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
544 B
21 lines
544 B
// Stub implementation of rweather's RNGClass for host-side sim builds.
|
|
// Ed25519::generatePrivateKey() calls RNG.rand() — we satisfy it with /dev/urandom.
|
|
#include "RNG.h"
|
|
#include <cstdio>
|
|
|
|
RNGClass RNG;
|
|
|
|
void RNGClass::begin(const char*) {}
|
|
|
|
void RNGClass::rand(uint8_t* buf, size_t len) {
|
|
FILE* f = fopen("/dev/urandom", "rb");
|
|
if (f) {
|
|
(void)fread(buf, 1, len, f);
|
|
fclose(f);
|
|
} else {
|
|
// fallback: deterministic
|
|
for (size_t i = 0; i < len; i++) buf[i] = (uint8_t)(i * 0x6B ^ 0xA3);
|
|
}
|
|
}
|
|
|
|
void RNGClass::loop() {}
|
|
|