Clock synchronization method and system based on trusted execution environment

文档序号:85529 发布日期:2021-10-08 浏览:17次 中文

阅读说明:本技术 基于可信执行环境的时钟同步方法及系统 (Clock synchronization method and system based on trusted execution environment ) 是由 梁凉 赵旭棹 于 2021-07-12 设计创作,主要内容包括:本发明提供了一种基于可信执行环境的时钟同步方法及系统,涉及工业互联网技术领域,该方法包括:可信设备端计时步骤:将设备端的时钟源驱动程序迁移至可信执行环境中,并在可信执行环境中实现可信时钟服务,可信时间由时钟源读数与可信时钟服务维护的可信时钟偏差值相加得到;设备端时钟数据与云端同步步骤:设备定期或主动同步云端时钟源的时钟数据;设备以随机化的周期持久化时钟数据步骤:以随机化的周期存储可信时钟数据,在对设备性能影响较小的情况下,减小设备断电对计时造成的影响。本发明能够提高通过软件攻击以及掉电等低成本硬件攻击非法篡改时钟数据的难度,安全有效地同步云端时间。(The invention provides a clock synchronization method and a system based on a trusted execution environment, which relate to the technical field of industrial internet, and the method comprises the following steps: timing by the trusted device side: migrating a clock source driving program of an equipment end to a trusted execution environment, and realizing trusted clock service in the trusted execution environment, wherein trusted time is obtained by adding clock source reading and a trusted clock deviation value maintained by the trusted clock service; synchronizing device end clock data and a cloud end: the device periodically or actively synchronizes clock data of a cloud clock source; the device persists the clock data with randomized periods: the trusted clock data is stored in a randomized period, and the influence of power-off of the equipment on timing is reduced under the condition that the influence on the performance of the equipment is small. The invention can improve the difficulty of illegally tampering clock data through low-cost hardware attacks such as software attack, power failure and the like, and safely and effectively synchronize the cloud time.)

1. A clock synchronization method based on a trusted execution environment is characterized by comprising the following steps:

timing by the trusted device side: migrating a clock source driving program of an equipment end to a trusted execution environment, and realizing trusted clock service in the trusted execution environment, wherein trusted time is obtained by adding clock source reading and a trusted clock deviation value maintained by the trusted clock service;

synchronizing device end clock data and a cloud end: the device periodically or actively synchronizes clock data of a cloud clock source;

the device persists the clock data with randomized periods: the trusted clock data is stored in a randomized period, and the influence of power-off of the equipment on timing is reduced under the condition that the influence on the performance of the equipment is small.

2. The clock synchronization method based on the trusted execution environment according to claim 1, wherein the trusted device-side timing step is to use a trusted execution environment peripheral protection technology to disable configuration of a clock source by an untrusted execution environment, and implement a driver management clock source in the trusted execution environment;

the trusted execution environment opens a clock source data reading interface to the rich execution environment, and the clock source data reading interface is used for reading the value of the clock source;

the trusted execution environment opens an update interface of the clock source data to the rich execution environment for updating the value of the clock source, and the rich execution environment updates the value of the clock source by calling the clock source data update interface opened by the trusted execution environment;

maintaining the trusted time offset to represent the difference between the trusted time and the clock source value, and synchronously updating when the clock source data updating interface is called;

and calculating the current safe time according to the trusted time offset and the value of the clock source.

3. The clock synchronization method based on trusted execution environment as claimed in claim 2, wherein said read interface of clock source data directly returns to original value of clock source data without performing storage operation in the whole execution process, so as to reduce influence of frequent read clock source value on system performance operation in rich execution environment.

4. The trusted execution environment-based clock synchronization method of claim 2, wherein the maintaining of the trusted time offset specifically comprises:

defining the relevant state:

defining the value of the clock source as T0

Defining a trusted time as Ts

Defining a trusted time offset as Ts_offset

The trusted time offset is calculated as the difference between the trusted time and the clock source value, Ts-T0In the initial state, Ts_offsetIs 0;

when the clock source data updating interface is called, the synchronous updating method of the trusted time offset is as follows:

step S1.1.1: reading the value T of the clock source0

Step S1.1.2: invoking an update interface with a rich execution environment attempts to set the value of the clock source to T0', specifically includes:

a: calculating a new trusted time offset as Ts_offset'=T0+Ts_offset-T0';

B: will T0Is updated to T0';

C: will Ts_offsetIs updated to Ts_offset';

D: will Ts_offsetThe value of (2) is written into the secure storage, and if the value fails, the operation is directly quitted;

e: updating T in secure memorys_offsetA value of (d);

f: will T0The value of' is written into the timing hardware RTC.

5. The trusted execution environment based clock synchronization method of claim 2, wherein said secure time is calculated by:

a: reading the value T of the clock source0

b: reading T in secure memorys_offsetA value of (d);

c: returning a trusted time Ts=T0+Ts_offset

6. The trusted execution environment-based clock synchronization method of claim 1, wherein the device-side clock data and cloud synchronization step specifically comprises:

step S2.1: the trusted clock service acquires the latest trusted time T from the cloud through specific security communicationn

Step S2.2: reading the value T of the clock source0

Step S2.3: calculating a new trusted time offset as Ts_offset'=Tn-T0

Step S2.4: will Ts_offsetThe value of' is written into the secure storage, and if the value fails, the operation is directly exited;

step S2.5: updating T in secure memorys_offsetThe value of.

7. The trusted execution environment based clock synchronization method of claim 1, wherein said clock data persistence step of the randomized period specifically comprises:

after the system is started or the clock data storage is finished each time, generating a random number within a specified range, reading the value of a clock source and storing the value in a safe storage in a lasting way after the length of the random number is seconds;

and in the initial stage of the trusted time service started by the equipment, recalculating the trusted time offset according to the clock source value and the trusted time data stored in the secure storage so as to realize the monotonic increase of the trusted time.

8. The trusted execution environment-based clock synchronization method of claim 7, wherein said recalculating the time offset specifically comprises:

setting the clock source value at the start of the equipment as T1

The last write clock source value in the secure storage is T0

Trusted time offset is Ts_offset

If T is1<T0If the device clock source is determined to be back-off, the trusted time offset T is updated to realize the monotone increment of the trusted times_offset'=(T0+Ts_offset)-T1And updating the value of the trusted time offset in the secure storage and the secure memory with the value.

9. A trusted execution environment based clock synchronization system, comprising:

the trusted device side timing module: migrating a clock source driving program of an equipment end to a trusted execution environment, and realizing trusted clock service in the trusted execution environment, wherein trusted time is obtained by adding clock source reading and a trusted clock deviation value maintained by the trusted clock service;

the device end clock data and cloud synchronization module: the device periodically or actively synchronizes clock data of a cloud clock source;

the device persists the clock data module with randomized periods: the trusted clock data is stored in a randomized period, and the influence of power-off of the equipment on timing is reduced under the condition that the influence on the performance of the equipment is small.

10. The clock synchronization system based on the trusted execution environment according to claim 9, wherein the trusted device side timing module disables configuration of the non-trusted execution environment to the clock source by using a trusted execution environment peripheral protection technology, and implements a driver management clock source in the trusted execution environment;

the trusted execution environment opens a clock source data reading interface to the rich execution environment, and the clock source data reading interface is used for reading the value of the clock source;

the trusted execution environment opens an update interface of the clock source data to the rich execution environment for updating the value of the clock source, and the rich execution environment updates the value of the clock source by calling the clock source data update interface opened by the trusted execution environment;

maintaining the trusted time offset to represent the difference between the trusted time and the clock source value, and synchronously updating when the clock source data updating interface is called;

and calculating the current safe time according to the trusted time offset and the value of the clock source.

Technical Field

The invention relates to the technical field of industrial internet, in particular to a clock synchronization method and system based on a trusted execution environment.

Background

A Trusted Execution Environment (Trusted Execution Environment) is an Execution Environment independent of a conventional operating system, and is generally used for running high-security-requirement operations, protecting sensitive data, protecting high-value data, and the like. The Rich Execution Environment refers to Rich Execution Environment. Generally refers to all software or hardware that is outside of the trusted execution environment, and it is generally believed that components within the REE should not be used to handle sensitive traffic.

The time of synchronization is important in software business. The existing system can reduce the time deviation on different nodes by relying on a network clock mechanism of a third party, and the mechanism can assist each node in time calibration regularly. The timing mechanism of a computer system usually needs to be realized by combining a plurality of different hardware clock sources, and the selection of the hardware clock sources needs to comprehensively consider the problems of precision and persistence.

Mobile devices, generally without stable external power, require a persistent clock source with independent power to maintain the clock when the device is turned off or hibernating. Therefore, timing of the mobile device is generally completed by a high-precision Clock source integrated in a CPU core and an RTC Clock (Real-Time Clock) independently powered outside the core, and the system Time of the mobile device is generally obtained by performing comprehensive operation on values of the high-precision Clock source and the RTC Clock. When the mobile equipment performs network timing, the system acquires network time through a timing protocol and updates values of different hardware clock sources according to a predefined rule. The above process is generally handled by a clock service in the system and multiple clock source drivers in the operating system kernel.

In this process, if the operation of any one of the components is disturbed, damaged, or the component operation condition cannot be met (e.g. no network, power-off reset of RTC), the system maintenance time is inaccurate or unstable. In some scenarios, an attacker can typically implement the attack at a lower cost (such as actively modifying the device time, jail or Root of the handset, breaking the network, or removing the RTC battery). At this point, the time maintained by the operating system should not be the basis for the time-sensitive application to execute the business logic.

The invention patent with publication number CN109600186B discloses a clock synchronization method and device, including: the method comprises the steps of obtaining a first clock difference with a first clock source based on a slave port, obtaining second clock differences with at least one second clock source based on at least one alternative interface respectively, obtaining at least one second clock difference, determining a credible clock difference based on the first clock difference and the at least one second clock difference, and synchronizing a system clock based on the credible clock difference. The invention provides an accurate clock data but fails to provide a reference, monotonically increasing clock data.

Disclosure of Invention

Aiming at the defects in the prior art, the invention provides a clock synchronization method and system based on a trusted execution environment.

According to the clock synchronization method and system based on the trusted execution environment provided by the invention, the scheme is as follows:

in a first aspect, a clock synchronization method based on a trusted execution environment is provided, the method including:

timing by the trusted device side: migrating a clock source driving program of an equipment end to a trusted execution environment, and realizing trusted clock service in the trusted execution environment, wherein trusted time is obtained by adding clock source reading and a trusted clock deviation value maintained by the trusted clock service;

synchronizing device end clock data and a cloud end: the device periodically or actively synchronizes clock data of a cloud clock source;

the device persists the clock data with randomized periods: the trusted clock data is stored in a randomized period, and the influence of power-off of the equipment on timing is reduced under the condition that the influence on the performance of the equipment is small.

Preferably, the trusted device side timing step means that a trusted execution environment peripheral protection technology is used to disable configuration of an untrusted execution environment on a clock source, and a driver management clock source is implemented in the trusted execution environment;

the trusted execution environment opens a clock source data reading interface to the rich execution environment, and the clock source data reading interface is used for reading the value of the clock source;

the trusted execution environment opens an update interface of the clock source data to the rich execution environment for updating the value of the clock source, and the rich execution environment updates the value of the clock source by calling the clock source data update interface opened by the trusted execution environment;

maintaining the trusted time offset to represent the difference between the trusted time and the clock source value, and synchronously updating when the clock source data updating interface is called;

and calculating the current safe time according to the trusted time offset and the value of the clock source.

Preferably, the read interface of the clock source data directly returns the original value of the clock source data without performing a storage operation in the whole execution process, so as to reduce the influence of frequent reading of the clock source value on the system performance operation in the rich execution environment.

Preferably, the maintaining of the trusted time offset specifically includes:

defining the relevant state:

defining the value of the clock source as T0

Defining a trusted time as Ts

Defining a trusted time offset as Ts_offset

The trusted time offset is calculated as the difference between the trusted time and the clock source value, Ts-T0In the initial state, Ts_offsetIs 0;

when the clock source data updating interface is called, the synchronous updating method of the trusted time offset is as follows:

step S1.1.1: reading the value T of the clock source0

Step S1.1.2: invoking an update interface with a rich execution environment attempts to set the value of the clock source to T0', specifically includes:

a: calculating a new trusted time offset as Ts_offset'=T0+Ts_offset-T0';

B: will T0Is updated to T0';

C: will Ts_offsetIs updated to Ts_offset';

D: will Ts_offsetThe value of (2) is written into the secure storage, and if the value fails, the operation is directly quitted;

e: updating T in secure memorys_offsetA value of (d);

f: will T0The value of' is written into the timing hardware RTC.

Preferably, the method for calculating the safe time is as follows:

a: reading the value T of the clock source0

b: reading T in secure memorys_offsetA value of (d);

c: returning a trusted time Ts=T0+Ts_offset

Preferably, the step of synchronizing the clock data of the device side and the cloud side specifically includes:

step S2.1: the trusted clock service acquires the latest trusted time T from the cloud through specific security communicationn

Step S2.2: reading the value T of the clock source0

Step S2.3: calculating a new trusted time offset as Ts_offset'=Tn-T0

Step S2.4: will Ts_offsetThe value of' is written into the secure storage, and if the value fails, the operation is directly exited;

step S2.5: updating T in secure memorys_offsetThe value of.

Preferably, the step of clock data persistence of the randomization period specifically includes:

after the system is started or the clock data storage is finished each time, generating a random number within a specified range, reading the value of a clock source and storing the value in a safe storage in a lasting way after the length of the random number is seconds;

and in the initial stage of the trusted time service started by the equipment, recalculating the trusted time offset according to the clock source value and the trusted time data stored in the secure storage so as to realize the monotonic increase of the trusted time.

Preferably, the recalculating the time offset specifically includes:

setting the clock source value at the start of the equipment as T1

The last write clock source value in the secure storage is T0

Trusted time offset is Ts_offset

If T is1<T0If the device clock source is determined to be back-off, the trusted time offset T is updated to realize the monotone increment of the trusted times_offset'=(T0+Ts_offset)-T1And updating the value of the trusted time offset in the secure storage and the secure memory with the value.

In a second aspect, a clock synchronization system based on a trusted execution environment is provided, the system comprising:

the trusted device side timing module: migrating a clock source driving program of an equipment end to a trusted execution environment, and realizing trusted clock service in the trusted execution environment, wherein trusted time is obtained by adding clock source reading and a trusted clock deviation value maintained by the trusted clock service;

the device end clock data and cloud synchronization module: the device periodically or actively synchronizes clock data of a cloud clock source;

the device persists the clock data module with randomized periods: the trusted clock data is stored in a randomized period, and the influence of power-off of the equipment on timing is reduced under the condition that the influence on the performance of the equipment is small.

Preferably, the trusted device side timing module is configured to disable the configuration of the non-trusted execution environment to the clock source by using a trusted execution environment peripheral protection technology, and implement a driver management clock source in the trusted execution environment;

the trusted execution environment opens a clock source data reading interface to the rich execution environment, and the clock source data reading interface is used for reading the value of the clock source;

the trusted execution environment opens an update interface of the clock source data to the rich execution environment for updating the value of the clock source, and the rich execution environment updates the value of the clock source by calling the clock source data update interface opened by the trusted execution environment;

maintaining the trusted time offset to represent the difference between the trusted time and the clock source value, and synchronously updating when the clock source data updating interface is called;

and calculating the current safe time according to the trusted time offset and the value of the clock source.

Compared with the prior art, the invention has the following beneficial effects:

1. the invention uses a credible timing mode, can still accurately time after the operating system and the clock service are attacked and trapped, and can run the clock driving program in a credible execution environment to prevent the credible clock data from being illegally tampered;

2. the device end and the cloud end use the safe link to transmit the synchronous time, so that the privacy and the integrity of communication data can be ensured, and the cloud end time can be safely and effectively synchronized;

3. the invention adopts a random device clock persistence mechanism to regularly store the clock data in the safe storage, thereby avoiding the clock data loss caused by RTC power failure; after the equipment is powered off, a time value which is closer to the current time can be obtained, and the influence of the power-off of the equipment is reduced as much as possible.

Drawings

Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments with reference to the following drawings:

FIG. 1 is a schematic flow chart of updating clock source values;

FIG. 2 is a schematic flow chart of reading the safety time;

FIG. 3 is a schematic flow chart of synchronizing secure time;

FIG. 4 is a schematic diagram of clock data stored at random cycles;

FIG. 5 is a diagram illustrating an updated trusted time offset after power-on.

Detailed Description

The present invention will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the invention, but are not intended to limit the invention in any way. It should be noted that it would be obvious to those skilled in the art that various changes and modifications can be made without departing from the spirit of the invention. All falling within the scope of the present invention.

The embodiment of the invention provides a clock synchronization method based on a trusted execution environment, and referring to fig. 1, the work of a trusted clock of a device end in the method is completed by a trusted timing step, a cloud synchronization step and a randomized storage step. The credible timing mode provides a safe and stable timing clock; the device and the cloud are synchronized to reduce the error of a trusted clock; the randomized storage can ensure that the device can still provide clock data with reference significance after being shut down and powered off.

The implementation of trusted timing relies on secure storage and secure memory in the trusted execution environment. The safe storage is a storage service built on the basis of a special storage medium, and the storage service can ensure that the content in the storage medium can only be read by authorized application and cannot be tampered randomly by combining the hardware characteristic of the storage medium and an encryption and decryption algorithm; in a device supporting the relevant characteristics, the secure memory is one or more areas in the physical memory, and data in the areas can be prevented from being read and written by unauthorized applications through proper configuration.

Specifically, the trusted timing step comprises:

the trusted timing mechanism needs to implement a trusted clock and also needs to ensure that the original logic of the system is not affected. The method selected by the invention is to maintain a trusted time in addition to the original time of the whole system. The behavior of the original time of the system is unchanged, and the trusted time and the cloud time are kept synchronous.

In order to achieve the above object, the present invention migrates the original clock source driver of the system to the trusted execution environment, and realizes an independent clock service in the trusted execution environment.

The trusted execution environment provides a stable execution space for the clock service and the clock source program, and the processor state, the memory and the storage space involved in the execution cannot be influenced by software outside the trusted execution environment. The method is mainly realized through a secure memory and a secure peripheral of the TEE.

After the design is adopted, the timing hardware and the original operating system work in the mutually isolated trusted execution environment, the original operating system software cannot use the timing hardware by calling functions or directly operating the hardware, and accordingly, a series of interfaces provided in the trusted execution environment need to be called to realize the original functions.

To implement trusted timing, we need to define some timing related states:

defining the value of the clock source as T0

Defining a trusted time as Ts

Defining a trusted time offset as Ts_offset

The trusted time offset is calculated as the difference between the trusted time and the clock source value, Ts-T0In the initial state, Ts_offsetIs 0;

the interface provided by the clock source driver is shown in fig. 1, and the implementation steps are as follows:

1. reading the value T of the clock source0

2. Invoking an update interface with a rich execution environment attempts to set the value of the clock source to T0', specifically includes:

a: calculating a new trusted time offset as Ts_offset'=T0+Ts_offset-T0';

B: will T0Is updated to T0';

C: will Ts_offsetIs updated to Ts_offset';

D: will be provided withTs_offsetThe value of (2) is written into the secure storage, and if the value fails, the operation is directly quitted;

e: updating T in secure memorys_offsetA value of (d);

f: will T0The value of' is written into the timing hardware RTC.

The trusted clock service needs to provide an interface, namely, the implementation steps are as follows:

(1) obtaining a trusted time TsAs shown in fig. 2:

a: reading the value T of the clock source0

b: reading T in secure memorys_offsetA value of (d);

c: returning a trusted time Ts=T0+Ts_offset

(2) Setting a trusted time TsAnd synchronizing the latest clock data to the cloud, and storing the data in the secure storage and the secure memory through randomized storage.

The time synchronization protocol of the device side and the cloud side is as follows:

fig. 3 shows a flow of time synchronization between the device and the cloud, which specifically includes:

firstly, the trusted clock service acquires the latest trusted time T from the cloud through specific security communicationn

Reading the value T of the clock source0

Thirdly, calculating a new credible time offset as Ts_offset'=Tn-T0

Fourthly, mixing Ts_offsetThe value of' is written into the secure storage, and if the value fails, the operation is directly exited;

fifthly, updating T in the secure memorys_offsetThe value of.

Device clock persistence mechanism:

in order to prevent the clock loss problem caused by the RTC power-off, the scheme of the present invention may periodically store the state maintained in the design in the secure storage of the trusted execution environment, and the process is as shown in fig. 4, and specifically includes:

firstly, generating a random number within a specified range after a system is started or clock data storage is finished each time, and reading a value of a clock source and storing the value in a safe storage in a lasting manner after the number of seconds of the length of the random number;

and secondly, in the initial stage of the trusted time service started by the equipment, recalculating the trusted time offset according to the clock source value and the trusted time data stored in the secure storage so as to realize the monotonic increase of the trusted time.

When the equipment end is started, the scheme of the invention compares the time difference between the RTC and the safety storage of the timing hardware, and selects a larger value to recalculate the time offset Ts_offsetAs shown in fig. 5, the method specifically includes:

firstly, setting a clock source value at the start of equipment as T1

Secondly, the clock source value at the last time of writing in the safe storage is T0

Thirdly, the trusted time offset is Ts_offset

Clock persistence is a relatively time consuming operation whose time consumption depends primarily on the performance of the device's secure storage medium, typically in the range of 500 ms. Therefore, this operation is generally not suitable to be performed at a higher frequency. If the frequency at which the device clock persistence operations are performed is excessively reduced, it may happen that the clock state is not preserved when the persistent clock source is powered down. Therefore, the invention carries out the persistence operation of the device clock at randomized intervals, and the random range of the intervals can be specified according to specific scenes.

The embodiment of the invention provides a clock synchronization method based on a trusted execution environment, which adopts a trusted timing mode, can still accurately time after an operating system and clock service are attacked, runs a clock driving program in the trusted execution environment, and can prevent trusted clock data from being illegally tampered; the device side and the cloud side transmit the synchronization time by using the secure link, so that the privacy and integrity of communication data can be ensured, and the cloud side time can be safely and effectively synchronized; a random device clock persistence mechanism is adopted to regularly store clock data in a safe storage, so that clock data loss caused by RTC power failure can be avoided; after the equipment is powered off, a time value which is closer to the current time can be obtained, and the influence of the power-off of the equipment is reduced as much as possible.

Those skilled in the art will appreciate that, in addition to implementing the system and its various devices, modules, units provided by the present invention as pure computer readable program code, the system and its various devices, modules, units provided by the present invention can be fully implemented by logically programming method steps in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system and various devices, modules and units thereof provided by the invention can be regarded as a hardware component, and the devices, modules and units included in the system for realizing various functions can also be regarded as structures in the hardware component; means, modules, units for performing the various functions may also be regarded as structures within both software modules and hardware components for performing the method.

The foregoing description of specific embodiments of the present invention has been presented. It is to be understood that the present invention is not limited to the specific embodiments described above, and that various changes or modifications may be made by one skilled in the art within the scope of the appended claims without departing from the spirit of the invention. The embodiments and features of the embodiments of the present application may be combined with each other arbitrarily without conflict.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:手机和平板电脑防辐射伤害的防护屏及其放大镜功能

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!