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
This commit is contained in:
Aditya Patwardhan
2025-09-03 14:33:18 +05:30
parent f4c3f907a9
commit 2ebc781c44

View File

@@ -66,7 +66,7 @@ uint32_t IRAM_ATTR esp_random(void)
result ^= REG_READ(WDEV_RND_REG); result ^= REG_READ(WDEV_RND_REG);
} while (ccount - last_ccount < cpu_to_apb_freq_ratio * APB_CYCLE_WAIT_NUM); } 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); 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 #else
do { do {