forked from wolfSSL/wolfssl
Merge pull request #6930 from Frauschi/zephyr_fix
Fixes for the Zephyr port
This commit is contained in:
3
.github/workflows/zephyr.yml
vendored
3
.github/workflows/zephyr.yml
vendored
@@ -7,10 +7,13 @@ jobs:
|
|||||||
run_test:
|
run_test:
|
||||||
name: Build and run
|
name: Build and run
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
- zephyr-ref: v3.4.0
|
- zephyr-ref: v3.4.0
|
||||||
zephyr-sdk: 0.16.1
|
zephyr-sdk: 0.16.1
|
||||||
|
- zephyr-ref: v3.5.0
|
||||||
|
zephyr-sdk: 0.16.3
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# This should be a safe limit for the tests to run.
|
# This should be a safe limit for the tests to run.
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
|
@@ -3506,23 +3506,16 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
* extern int myRngFunc(byte* output, word32 sz);
|
* extern int myRngFunc(byte* output, word32 sz);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \
|
|
||||||
defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \
|
|
||||||
defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \
|
|
||||||
defined(WOLFSSL_LPC43xx) || defined(NO_STM32_RNG) || \
|
|
||||||
defined(MBED) || defined(WOLFSSL_EMBOS) || \
|
|
||||||
defined(WOLFSSL_GENSEED_FORTEST) || defined(WOLFSSL_CHIBIOS) || \
|
|
||||||
defined(WOLFSSL_CONTIKI) || defined(WOLFSSL_AZSPHERE)
|
|
||||||
|
|
||||||
/* these platforms do not have a default random seed and
|
|
||||||
you'll need to implement your own wc_GenerateSeed or define via
|
|
||||||
CUSTOM_RAND_GENERATE_BLOCK */
|
|
||||||
|
|
||||||
#define USE_TEST_GENSEED
|
|
||||||
|
|
||||||
#elif defined(WOLFSSL_ZEPHYR)
|
#elif defined(WOLFSSL_ZEPHYR)
|
||||||
|
|
||||||
|
#include <version.h>
|
||||||
|
|
||||||
|
#if KERNEL_VERSION_NUMBER >= 0x30500
|
||||||
|
#include <zephyr/random/random.h>
|
||||||
|
#else
|
||||||
#include <zephyr/random/rand32.h>
|
#include <zephyr/random/rand32.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _POSIX_C_SOURCE
|
#ifndef _POSIX_C_SOURCE
|
||||||
#include <zephyr/posix/time.h>
|
#include <zephyr/posix/time.h>
|
||||||
#else
|
#else
|
||||||
@@ -3623,6 +3616,20 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined(WOLFSSL_SAFERTOS) || defined(WOLFSSL_LEANPSK) || \
|
||||||
|
defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_MDK_ARM) || \
|
||||||
|
defined(WOLFSSL_uITRON4) || defined(WOLFSSL_uTKERNEL2) || \
|
||||||
|
defined(WOLFSSL_LPC43xx) || defined(NO_STM32_RNG) || \
|
||||||
|
defined(MBED) || defined(WOLFSSL_EMBOS) || \
|
||||||
|
defined(WOLFSSL_GENSEED_FORTEST) || defined(WOLFSSL_CHIBIOS) || \
|
||||||
|
defined(WOLFSSL_CONTIKI) || defined(WOLFSSL_AZSPHERE)
|
||||||
|
|
||||||
|
/* these platforms do not have a default random seed and
|
||||||
|
you'll need to implement your own wc_GenerateSeed or define via
|
||||||
|
CUSTOM_RAND_GENERATE_BLOCK */
|
||||||
|
|
||||||
|
#define USE_TEST_GENSEED
|
||||||
|
|
||||||
#elif defined(NO_DEV_RANDOM)
|
#elif defined(NO_DEV_RANDOM)
|
||||||
|
|
||||||
#error "you need to write an os specific wc_GenerateSeed() here"
|
#error "you need to write an os specific wc_GenerateSeed() here"
|
||||||
|
@@ -3164,6 +3164,30 @@ time_t z_time(time_t * timer)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTC) && \
|
||||||
|
(defined(CONFIG_PICOLIBC) || defined(CONFIG_NEWLIB_LIBC))
|
||||||
|
/* Try to obtain the actual time from an RTC */
|
||||||
|
static const struct device *rtc = DEVICE_DT_GET(DT_NODELABEL(rtc));
|
||||||
|
|
||||||
|
if (device_is_ready(rtc)) {
|
||||||
|
struct rtc_time rtc_time;
|
||||||
|
struct tm *tm_time = rtc_time_to_tm(&rtc_time);
|
||||||
|
|
||||||
|
int ret = rtc_get_time(rtc, &rtc_time);
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
time_t epochTime = mktime(tm_time);
|
||||||
|
|
||||||
|
if (timer != NULL)
|
||||||
|
*timer = epochTime;
|
||||||
|
|
||||||
|
return epochTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Fallback to uptime since boot. This works for relative times, but
|
||||||
|
* not for ASN.1 date validation */
|
||||||
if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
|
if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
|
||||||
if (timer != NULL)
|
if (timer != NULL)
|
||||||
*timer = ts.tv_sec;
|
*timer = ts.tv_sec;
|
||||||
|
@@ -982,7 +982,15 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
|
|||||||
#ifndef _POSIX_C_SOURCE
|
#ifndef _POSIX_C_SOURCE
|
||||||
#include <zephyr/posix/time.h>
|
#include <zephyr/posix/time.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RTC)
|
||||||
|
#if defined(CONFIG_PICOLIBC) || defined(CONFIG_NEWLIB_LIBC)
|
||||||
|
#include <zephyr/drivers/rtc.h>
|
||||||
|
#else
|
||||||
|
#warning "RTC support needs picolibc or newlib (nano)"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
time_t z_time(time_t *timer);
|
time_t z_time(time_t *timer);
|
||||||
|
Reference in New Issue
Block a user