mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-24 14:48:29 +02:00
Fail hard if no random bytes available for encryption (#3067)
This commit is contained in:
committed by
Jesse Hills
parent
7b03e07908
commit
869743a742
@@ -287,13 +287,12 @@ uint32_t random_uint32() {
|
||||
#endif
|
||||
}
|
||||
float random_float() { return static_cast<float>(random_uint32()) / static_cast<float>(UINT32_MAX); }
|
||||
void random_bytes(uint8_t *data, size_t len) {
|
||||
bool random_bytes(uint8_t *data, size_t len) {
|
||||
#ifdef USE_ESP32
|
||||
esp_fill_random(data, len);
|
||||
return true;
|
||||
#elif defined(USE_ESP8266)
|
||||
if (os_get_random(data, len) != 0) {
|
||||
ESP_LOGE(TAG, "Failed to generate random bytes!");
|
||||
}
|
||||
return os_get_random(data, len) == 0;
|
||||
#else
|
||||
#error "No random source available for this configuration."
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user