Skip to content

Commit 0cd73df

Browse files
AdityaHPatwardhanmahavirj
authored andcommitted
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
1 parent b8b4a4f commit 0cd73df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

components/esp_hw_support/hw_random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ uint32_t IRAM_ATTR esp_random(void)
7878
result ^= REG_READ(WDEV_RND_REG);
7979
} while (ccount - last_ccount < cpu_to_apb_freq_ratio * APB_CYCLE_WAIT_NUM);
8080
uint32_t current_rtc_timer_counter = (lp_timer_hal_get_cycle_count() & 0xFF);
81-
result ^= ((result ^ current_rtc_timer_counter) & 0xFF) << (i * 8);
81+
result ^= (current_rtc_timer_counter << (i * 8));
8282
}
8383
#else
8484
do {

0 commit comments

Comments
 (0)