mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-11 17:52:00 +03:00
refactor(rng): move rng read data function to rng_ll.h and update docs of RNG source
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2010-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "esp_cpu.h"
|
||||
#include "soc/wdev_reg.h"
|
||||
#include "hal/rng_ll.h"
|
||||
|
||||
#include "hal/rtc_timer_hal.h"
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
#if !SOC_RTC_TIMER_V1
|
||||
random = REG_READ(WDEV_RND_REG);
|
||||
random = rng_ll_read_data();
|
||||
start = esp_cpu_get_cycle_count();
|
||||
do {
|
||||
random ^= REG_READ(WDEV_RND_REG);
|
||||
random ^= rng_ll_read_data();
|
||||
now = esp_cpu_get_cycle_count();
|
||||
} while (now - start < RNG_CPU_WAIT_CYCLE_NUM);
|
||||
|
||||
@@ -68,10 +68,10 @@
|
||||
as-is, we repeatedly read the RNG register and XOR all
|
||||
values.
|
||||
*/
|
||||
random = REG_READ(WDEV_RND_REG);
|
||||
random = rng_ll_read_data();
|
||||
start = esp_cpu_get_cycle_count();
|
||||
do {
|
||||
random ^= REG_READ(WDEV_RND_REG);
|
||||
random ^= rng_ll_read_data();
|
||||
now = esp_cpu_get_cycle_count();
|
||||
} while (now - start < RNG_CPU_WAIT_CYCLE_NUM);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user