adapt bearsll-esp8266 to ESP32

This commit is contained in:
Staars 2020-10-19 19:07:22 +02:00
parent 90ee6f3995
commit 968fda65ca
3 changed files with 27 additions and 4 deletions

View File

@ -140,6 +140,24 @@ seeder_win32(const br_prng_class **ctx)
#endif
#if BR_USE_ESP8266_RAND
#ifdef ESP32
extern uint32_t esp_random(void);
static int
seeder_esp8266(const br_prng_class **ctx) //TODO: rename/refactor it to ESP32
{
uint32_t tmp[32 / sizeof(uint32_t)];
size_t i;
for (i=0; i<sizeof(tmp)/sizeof(tmp[0]); i++) {
tmp[i] = esp_random();
}
(*ctx)->update(ctx, tmp, sizeof tmp);
return 1;
}
#else
extern uint32_t phy_get_rand(void); // From the ESP8266 SDK
static int
@ -157,6 +175,7 @@ seeder_esp8266(const br_prng_class **ctx)
return 1;
}
#endif
#endif
/* see bearssl_rand.h */

View File

@ -33,7 +33,11 @@ br_chacha20_ct_run(const void *key,
uint32_t kw[8], ivw[3];
size_t u;
#ifdef ESP32
static const uint32_t CW[] = {
#else
static const uint32_t CW[] PROGMEM = {
#endif
0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
};

View File

@ -132,7 +132,7 @@
* Set BR_LOMUL on platforms where it makes sense.
*/
#ifndef BR_LOMUL
#if BR_ARMEL_CORTEXM_GCC || (defined(ESP8266) && !defined(ESP8266M32))
#if BR_ARMEL_CORTEXM_GCC || ((defined(ESP8266) || defined(ESP32)) && !defined(ESP8266M32))
#define BR_LOMUL 1
#endif
#endif
@ -315,7 +315,7 @@
* Use ESP8266 hardware random generator when possible.
*/
#ifndef BR_USE_ESP8266_RAND
#if defined(ESP8266)
#if (defined(ESP8266) || defined(ESP32))
#define BR_USE_ESP8266_RAND 1
#endif
#endif
@ -433,7 +433,7 @@
*/
#ifndef BR_USE_UNIX_TIME
#if defined __unix__ || defined __linux__ || defined ESP8266 \
#if defined __unix__ || defined __linux__ || defined ESP8266 || defined ESP32\
|| defined _POSIX_SOURCE || defined _POSIX_C_SOURCE \
|| (defined __APPLE__ && defined __MACH__)
#define BR_USE_UNIX_TIME 1
@ -2568,7 +2568,7 @@ br_cpuid(uint32_t mask_eax, uint32_t mask_ebx,
#endif
#ifdef ESP8266
#if (defined(ESP8266)|| defined(ESP32))
#ifdef __cplusplus
extern "C" {