summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/rng.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2026-01-07 22:13:36 +0100
committerUros Majstorovic <majstor@majstor.org>2026-01-07 22:13:36 +0100
commit285ddd410a559449b7e2cbab9b2b10e850efbd08 (patch)
treed6cfe1577675c3478444f0b82b7c5f56bd6b174f /fw/esp32/components/eos/rng.c
parent2357302c5e0228c1209b747cc5e0b11d7bef0a02 (diff)
added APP <-> FE310 bridge SPI messages; enabled esp32 wake from deep sleep; IP tunnel for app module supports NAT and port forwadring; introduced EOSMessage struct for SPI messages;
Diffstat (limited to 'fw/esp32/components/eos/rng.c')
-rw-r--r--fw/esp32/components/eos/rng.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/fw/esp32/components/eos/rng.c b/fw/esp32/components/eos/rng.c
index 675a79c..6f53a0b 100644
--- a/fw/esp32/components/eos/rng.c
+++ b/fw/esp32/components/eos/rng.c
@@ -7,21 +7,19 @@
static const char *TAG = "EOS RNG";
-static void rng_handler(unsigned char _mtype, unsigned char *buffer, uint16_t buf_len) {
+static void rng_handler(unsigned char _mtype, EOSMessage *msg, uint16_t len) {
+ unsigned char *buffer = msg->buffer;
uint16_t rng_len = 0;
- if (buf_len < sizeof(uint16_t)) goto rng_handler_fin;
+ if (!(eos_msg_flags(msg) & EOS_MSG_FLAG_RPLY_REQ)) return;
+ if (len < sizeof(uint16_t)) return;
rng_len = (uint16_t)buffer[0] << 8;
rng_len |= (uint16_t)buffer[1];
- if (rng_len > EOS_NET_SIZE_BUF) {
- rng_len = 0;
- goto rng_handler_fin;
- }
- esp_fill_random(buffer, rng_len);
+ if (rng_len > msg->size) return;
-rng_handler_fin:
- eos_net_reply(EOS_NET_MTYPE_RNG, buffer, rng_len);
+ esp_fill_random(buffer, rng_len);
+ eos_net_reply(EOS_NET_MTYPE_RNG, msg, rng_len);
}
void eos_rng_init(void) {