From f286036a7bde332cadaf26274b9865458a0eabed Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 3 Sep 2025 14:33:18 +0530 Subject: [PATCH] fix(esp_hw_support): Fixed entropy mixing of RTC timer with RNG Previously the RTC timer entropy was being mixed with the RNG timer in a wrong way. Which led to the overwriting of the LSB with rtc timer value. This change fixes that behaviour --- components/esp_hw_support/hw_random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_hw_support/hw_random.c b/components/esp_hw_support/hw_random.c index e83b767d96..56cc1a09c4 100644 --- a/components/esp_hw_support/hw_random.c +++ b/components/esp_hw_support/hw_random.c @@ -75,7 +75,7 @@ uint32_t IRAM_ATTR esp_random(void) result ^= REG_READ(WDEV_RND_REG); } while (ccount - last_ccount < cpu_to_apb_freq_ratio * APB_CYCLE_WAIT_NUM); uint32_t current_rtc_timer_counter = (lp_timer_hal_get_cycle_count() & 0xFF); - result ^= ((result ^ current_rtc_timer_counter) & 0xFF) << (i * 8); + result ^= (current_rtc_timer_counter << (i * 8)); } #else do {