API encryption (#2254)

This commit is contained in:
Otto Winter
2021-09-08 23:22:47 +02:00
committed by GitHub
parent 9e5cd0da51
commit e5051eefbc
11 changed files with 777 additions and 0 deletions
+3
View File
@@ -54,5 +54,8 @@
#define USE_SOCKET_IMPL_BSD_SOCKETS
#endif
#define USE_API_PLAINTEXT
#define USE_API_NOISE
// Disabled feature flags
//#define USE_BSEC // Requires a library with proprietary license.
+9
View File
@@ -55,6 +55,15 @@ double random_double() { return random_uint32() / double(UINT32_MAX); }
float random_float() { return float(random_double()); }
void fill_random(uint8_t *data, size_t len) {
#ifdef ARDUINO_ARCH_ESP32
esp_fill_random(data, len);
#else
int err = os_get_random(data, len);
assert(err == 0);
#endif
}
static uint32_t fast_random_seed = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
void fast_random_set_seed(uint32_t seed) { fast_random_seed = seed; }
+2
View File
@@ -109,6 +109,8 @@ double random_double();
/// Returns a random float between 0 and 1. Essentially just casts random_double() to a float.
float random_float();
void fill_random(uint8_t *data, size_t len);
void fast_random_set_seed(uint32_t seed);
uint32_t fast_random_32();
uint16_t fast_random_16();