PAL time - platform. This file contains the real-time OS APIs that need to be implemented in the platform layer. More...
#include <stdint.h>
Go to the source code of this file.
Functions | |
palStatus_t | pal_plat_initTime (void) |
Initialize the time module After boot, the time in RAM will be initialized with the higher value of RTC and SOTP SAVED_TIME . If no RTC is present, RTC time is zero. After initialization, the time module will start counting ticks. More... | |
uint64_t | pal_plat_osGetTime (void) |
Get the system time. More... | |
palStatus_t | pal_plat_osSetTime (uint64_t seconds) |
Set the current system time by accepting seconds since January 1st 1970 UTC+0. More... | |
palStatus_t | pal_plat_osSetWeakTime (uint64_t setTimeInSeconds) |
Set the weak time. More... | |
palStatus_t | pal_plat_osSetStrongTime (uint64_t setTimeInSeconds) |
Set the strong time. This function will be called when receiving time from a server that is completely trusted. More... | |
PAL time - platform. This file contains the real-time OS APIs that need to be implemented in the platform layer.
This file contains the secure time APIs and is a part of the PAL service API. Unlike the usual timer and tick query APIs, which are found in RTOS, this optional module provides access to the clock, which is used mostly by PAL's own Crypto module.
palStatus_t pal_plat_initTime | ( | void | ) |
Initialize the time module After boot, the time in RAM will be initialized with the higher value of RTC and SOTP SAVED_TIME
. If no RTC is present, RTC time is zero. After initialization, the time module will start counting ticks.
uint64_t pal_plat_osGetTime | ( | void | ) |
Get the system time.
The time is calculated by the sum of the initial value + the number of ticks passed, converted into seconds.
PAL_LAST_SAVED_TIME_LATENCY_SEC
, then the secure time value will be overwritten with the current system time. palStatus_t pal_plat_osSetStrongTime | ( | uint64_t | setTimeInSeconds | ) |
Set the strong time. This function will be called when receiving time from a server that is completely trusted.
Set the time in RAM unconditionally. Save the new time in SOTP or RTC under the following conditions:
Time forward – if time difference between current time in SOTP (not device time) and new time is greater than a day.
Time backward – if time difference between current time and new time is greater than one minute. If the time is saved in SOTP (forward or backwards), the record LAST_TIME_BACK
must be saved.
[in] | setTimeInSeconds | Seconds from January 1st 1970 UTC+0. |
palStatus_t pal_plat_osSetTime | ( | uint64_t | seconds | ) |
Set the current system time by accepting seconds since January 1st 1970 UTC+0.
[in] | seconds | Seconds from January 1st 1970 UTC+0. |
palStatus_t pal_plat_osSetWeakTime | ( | uint64_t | setTimeInSeconds | ) |
Set the weak time.
Time Forward (a)
set the time (in RAM) unconditionally. Save the new time in SOTP if the change (between new time and current time in RAM) is greater than 24 hours. Set the time to RTC if the change is greater than 100 seconds. This limitation is to avoid multiple writes to the SOTP and RTC and not related to security.
Time Forward (b)
If (a) did not happen, save the time into SOTP if new time is greater from SAVED_TIME by a week (604800 seconds).
Time Backwards
set the device time on the device (RAM) and save the time in SOTP only if the change (between new time and current time in RAM) is smaller than 3 minutes for each day lapsed from the last change done via pal_osSetWeakTime
. RTC is never set backwards by pal_osSetWeakTime
.
[in] | setTimeInSeconds | Seconds from January 1st 1970 UTC+0. |
pal_osSetWeakTime
two different records must be saved in SOTP: LAST_TIME_BACK
.