Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a system, and a storage medium for program metric verification, so as to avoid the risk of physical attack.
In a first aspect, an embodiment of the present invention provides a program metric verification method, including:
initializing a program verification environment;
invoking an on-chip security processor: measuring a program to be executed, and storing a measurement result in an on-chip storage area;
requesting the on-chip security processor to acquire a measurement result of a program to be executed, and receiving the measurement result read from the on-chip storage area by the on-chip security processor;
and after the verification measurement result passes, determining that the program to be executed is complete, and executing the program to be executed.
Further, initializing a program verification environment, comprising:
saving the context of the current operating environment;
and initializing a Central Processing Unit (CPU), closing interrupt and closing Direct Memory Access (DMA) transmission.
Further, invoking the on-chip security processor to measure the program to be executed, including:
and sending a program measurement calling instruction to the on-chip security processor, and instructing the on-chip security processor to measure the program to be executed, wherein the program measurement calling instruction comprises a storage address of the program to be executed.
In a second aspect, an embodiment of the present invention provides another program metric verification method, including:
receiving a program measurement calling instruction of an on-chip Central Processing Unit (CPU), measuring a program to be executed, and storing a measurement result in an on-chip storage area;
and receiving a measurement result acquisition request of the on-chip CPU, reading a measurement result from the on-chip storage area, and returning the measurement result to the on-chip CPU so that the on-chip CPU verifies the integrity of the program to be executed according to the measurement result.
Further, measuring the program to be executed includes:
and measuring the program to be executed by executing the TPM firmware program of the trusted platform module, which is loaded from the SRAM in advance.
Further, measuring the program to be executed includes:
and calling a built-in cryptography coprocessor to perform cryptography function calculation on the program to be executed.
Further, the cryptography function calculation includes the cryptography function calculation defined by the commercial cryptography standard of China.
Further, receiving a program measurement call instruction of the on-chip CPU, and measuring the program to be executed, includes:
receiving a program measurement calling instruction of an on-chip CPU, and extracting a storage address of a program to be executed carried by the instruction;
and reading the program to be executed for measurement according to the extracted storage address.
In a third aspect, an embodiment of the present invention provides a program metric verification apparatus, including:
an initialization unit for initializing a program verification environment;
a calling unit, configured to call an on-chip security processor: measuring a program to be executed, and storing a measurement result in an on-chip storage area;
the acquisition unit is used for requesting the on-chip security processor to acquire a measurement result of a program to be executed and receiving the measurement result read by the on-chip security processor from the on-chip storage area;
and the verification unit is used for determining that the program to be executed is complete and executing the program to be executed after the measurement result passes verification.
Further, the initialization unit is used for initializing a program verification environment, and includes:
saving the context of the current operating environment;
and initializing a Central Processing Unit (CPU), closing interrupt and closing Direct Memory Access (DMA) transmission.
Further, the invoking unit is configured to invoke the on-chip security processor to perform measurement on the program to be executed, and includes:
and sending a program measurement calling instruction to the on-chip security processor, and instructing the on-chip security processor to measure the program to be executed, wherein the program measurement calling instruction comprises a storage address of the program to be executed.
In a fourth aspect, an embodiment of the present invention provides another program metric verification apparatus, including:
the measurement unit is used for receiving a program measurement calling instruction of an on-chip Central Processing Unit (CPU), measuring a program to be executed and storing a measurement result in an on-chip storage area;
and the feedback unit is used for receiving a measurement result acquisition request of the on-chip CPU, reading the measurement result from the on-chip storage area and returning the measurement result to the on-chip CPU so that the on-chip CPU verifies the integrity of the program to be executed according to the measurement result.
Further, the measurement unit is configured to measure the program to be executed, and includes:
and measuring the program to be executed by executing the TPM firmware program of the trusted platform module, which is loaded from the SRAM in advance.
Further, the measurement unit is configured to measure the program to be executed, and includes:
and calling a built-in cryptography coprocessor to perform cryptography function calculation on the program to be executed.
Further, the measuring unit is configured to receive a program measurement call instruction of the on-chip CPU, and measure the program to be executed, and includes:
receiving a program measurement calling instruction of an on-chip CPU, and extracting a storage address of a program to be executed carried by the instruction;
and reading the program to be executed for measurement according to the extracted storage address.
In a fifth aspect, an embodiment of the present invention provides a program metric verification system, where the system includes a central processing unit and a secure processor connected by an on-chip bus; wherein: the central processing unit comprises a program metric verification device provided by the third aspect; the secure processor comprises another program metric verification apparatus as provided in the fourth aspect above.
In a sixth aspect, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs, which are executable by one or more central processors to implement the program metric verification method of the first aspect, or which are executable by one or more secure processors to implement the program metric verification method of the second aspect.
In the technical scheme provided by the embodiment of the invention, the measurement of the program to be executed is completed through the security processor arranged in the system on chip, and the whole dynamic measurement root creation process is not communicated with the external TPM through the off-chip bus any more, but is completely realized in the system on chip, so that the risk that the off-chip bus is subjected to physical attack can be avoided, and the security of the off-chip bus is enhanced.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
First, some terms related to the embodiments of the present invention will be briefly described.
Trusted Platform Module (TPM): the chip is planted inside a computer to provide a Trusted root for the computer, and the specification of the chip is formulated by Trusted Computing Group (Trusted Computing Group).
TPM in the chip: the SoC is internally provided with a credible module with a cryptography function and a storage function.
Dynamic metric Root (Dynamic Root Of Trust): the credible root is dynamically established when the system runs, and the concept corresponding to the dynamic measurement root is a static measurement root which must be established when the system is started.
A Platform Secure Processor (PSP), a Processor dedicated to handling Secure functions, which may be an x86 architecture or an ARM architecture, generally executes only firmware and does not execute operating systems and applications.
And (4) national secret: the domestic data encryption processing series algorithms identified by the China national crypto-administration realize the algorithm functions of symmetry, asymmetry, abstract and the like from SM1-SM4 respectively.
The technical solution of the present invention will be described in detail by examples.
Example one
The embodiment provides a program metric verification method, which can be executed by a corresponding program metric verification device, wherein the device can be executed by a CPU (central processing unit) integrated in an intelligent device with an SoC (system on chip), and the CPU is embedded in the SoC. Referring to fig. 1, the method specifically includes the following steps 101-104.
Step 101, initializing a program verification environment.
Specifically, step 101 initializes the program verification environment, and one possible implementation is realized by the following sub-steps:
sub-step 1011, saving the context of the current operating environment.
Substep 1012, performing central processing CPU initialization, closing interrupts, and closing direct memory access DMA transfers.
The CPU initialization may include, among other things, initializing a timestamp, initializing an interrupt disable time measurement, initializing a CPU name, etc.
Step 102, calling an on-chip security processor: and measuring the program to be executed, and storing the measurement result in an on-chip storage area.
Specifically, the CPU calls an on-chip security processor, sends a program measurement calling instruction to the on-chip security processor, and instructs the on-chip security processor to measure a program to be executed, wherein the program measurement calling instruction comprises a storage address of the program to be executed.
In this step, the on-chip security processor is built in the CPU for processing security-related tasks, and the to-be-executed program is measured by using the security processing chip built in the CPU, so that the program measurement call instruction and data do not need to be transmitted through an external bus any more, and only exist in an internal bus of the CPU, thereby improving the security of the TPM.
Step 103, requesting the on-chip security processor to acquire the measurement result of the program to be executed, and receiving the measurement result read from the on-chip storage area by the on-chip security processor.
In this step, the security processor measures the program to be executed to obtain a measurement result, and stores the measurement result in the on-chip storage area. The security processor may measure the program to be executed by executing a trusted platform module TPM firmware program previously loaded from the static random access SRAM.
And the CPU requests the on-chip secure memory to acquire a measurement result of the program to be executed, and receives the measurement result read from the on-chip storage area by the on-chip secure processor.
And 104, after the measurement result is verified, determining that the program to be executed is complete, and executing the program to be executed.
In this step, after the verification measurement result passes, the program to be executed is executed. In the execution process, the integrity of the program to be executed can be verified by calculating and comparing with the stored measurement result, and when the program to be executed is complete, the operation under the safe environment is proved.
Example two
The embodiment provides a program metric verification method, which can be executed by a corresponding program metric verification device, wherein the device can be executed by a security processor integrated in a smart device with an SoC, and the security processor is embedded in the SoC. Referring to fig. 2, the method specifically includes the following steps 201-202.
Step 201, receiving a program measurement calling instruction of an on-chip central processing unit CPU, measuring a program to be executed, and storing a measurement result in an on-chip storage area.
Step 202, receiving a measurement result acquisition request of the on-chip CPU, reading a measurement result from the on-chip storage area, and returning the measurement result to the on-chip CPU, so that the on-chip CPU verifies the integrity of the program to be executed according to the measurement result.
In this embodiment, the measuring, by the on-chip security processor, the program to be executed includes: and measuring the program to be executed by executing the TPM firmware program of the trusted platform module, which is loaded from the SRAM in advance.
In this embodiment, the on-chip secure processor is a processor dedicated to processing a secure function, and may be an x86 architecture or an ARM architecture. The secure processor typically executes only firmware and does not execute the operating system and application programs. Therefore, when the program to be executed is measured, the program to be executed can be measured by executing the TPM firmware program which is loaded from the SRAM to the trusted platform module in advance.
For example, the measurement of the program to be executed by the on-chip security processor may specifically include: and calling a built-in cryptography coprocessor to perform cryptography function calculation on the program to be executed.
The measurement of the program to be executed may include the calculation of cryptographic functions such as hash value calculation. Typically, a cryptology coprocessor (Crypto Co-Processor) is usually built in the on-chip security Processor, and the on-chip security Processor may accelerate the task execution of the computation of the cryptology function by calling the CCP, that is, the hardware for performing the computation of the cryptology function may be a security Processor built in the SoC. In addition, the cryptography function calculation includes the cryptography function calculation defined by the commercial cryptography standard of China. In order to support the national commercial cryptographic standard, the SoC-embedded security processor needs to support cryptographic calculation functions such as asymmetric encryption, signature verification, hash value calculation and the like defined by the national commercial cryptographic standards of china, such as SM2, SM3, SM4 and the like.
In this embodiment, receiving a program measurement call instruction of an on-chip CPU, and measuring a program to be executed includes: receiving a program measurement calling instruction of an on-chip CPU, and extracting a storage address of a program to be executed carried by the instruction; and reading the program to be executed for measurement according to the extracted storage address.
EXAMPLE III
The present embodiment provides a program metric verification apparatus, which may be configured to execute the program metric verification method according to the first embodiment, where the apparatus may be implemented by a CPU integrated in an intelligent device deployed with an SoC, and the CPU is embedded in the SoC. Referring to fig. 3, the apparatus specifically includes the following units:
an initialization unit 301 configured to initialize a program verification environment;
a calling unit 302, configured to call an on-chip security processor: measuring a program to be executed, and storing a measurement result in an on-chip storage area;
an obtaining unit 303, configured to request the on-chip security processor to obtain a measurement result of the program to be executed, and receive the measurement result read by the on-chip security processor from the on-chip storage area;
and the verification unit 304 is configured to determine that the program to be executed is complete and execute the program to be executed after the measurement result passes verification.
Further, the initialization unit is used for initializing the program verification environment, and may include:
saving the context of the current operating environment;
and initializing a Central Processing Unit (CPU), closing interrupt and closing Direct Memory Access (DMA) transmission.
Further, the invoking unit is configured to invoke the on-chip security processor to perform measurement on the program to be executed, and includes:
and sending a program measurement calling instruction to the on-chip security processor, and instructing the on-chip security processor to measure the program to be executed, wherein the program measurement calling instruction comprises a storage address of the program to be executed.
The program metric verification apparatus provided in this embodiment and the program metric verification method in the first embodiment belong to the same inventive concept, and the technical details that are not described in this embodiment may refer to the related description in the first embodiment, which is not described herein again.
Example four
The present embodiment provides a program metric verification apparatus, which can be used to execute the program metric verification method described in the second embodiment, and the apparatus can be executed by a security processor integrated in a smart device deployed with an SoC, where the security processor is embedded in the SoC. Referring to fig. 4, the apparatus specifically includes the following units:
a measurement unit 401, configured to receive a program measurement call instruction of an on-chip central processing unit CPU, measure a program to be executed, and store a measurement result in an on-chip storage area;
a feedback unit 402, configured to receive a measurement result obtaining request of the on-chip CPU, read a measurement result from the on-chip storage area, and return the measurement result to the on-chip CPU, so that the on-chip CPU verifies the integrity of the program to be executed according to the measurement result.
Further, the measurement unit is configured to measure the program to be executed, and includes:
and measuring the program to be executed by executing the TPM firmware program of the trusted platform module, which is loaded from the SRAM in advance.
Further, the measurement unit is configured to measure the program to be executed, and includes:
and calling a built-in cryptography coprocessor to perform cryptography function calculation on the program to be executed.
Further, the measuring unit is configured to receive a program measurement call instruction of the on-chip CPU, and measure the program to be executed, and includes:
receiving a program measurement calling instruction of an on-chip CPU, and extracting a storage address of a program to be executed carried by the instruction;
and reading the program to be executed for measurement according to the extracted storage address.
The program metric verification apparatus provided in this embodiment and the program metric verification method in the second embodiment belong to the same inventive concept, and the technical details that are not described in this embodiment may refer to the related description in the second embodiment, which is not described herein again.
In addition, an embodiment of the present invention further provides a program metric verification system, which may be integrated in an intelligent device deployed with an SoC, and includes a central processing unit (CPU core) and a security processor connected by an on-chip bus, where:
the central processing unit comprises the program metric verifying device of the third embodiment;
the secure processor includes the program metric verification apparatus described in the fourth embodiment.
Further, the system further comprises: SRAM (Static Random-Access Memory) TPM (Trusted Platform Module) firmware, on-chip Memory area, and cryptography coprocessor, all of which are connected to the secure processor through on-chip bus. Specifically, the interaction between these components and the secure processor can be referred to in the first to fourth embodiments, and is not described herein again.
The solution provided by the embodiments of the present invention is described in detail below with reference to a typical example. As shown in fig. 6, this example includes the steps of:
step 600, the CPU invokes a dynamic metric root creation instruction to complete the following actions:
initializing a CPU;
closing the interrupt;
closing the DMA transmission;
and loading the program to be executed to a specified memory interval, sending the memory address of the program to be executed to the on-chip security processor, measuring the program to be executed by the on-chip security processor, and storing the measurement result in the on-chip memory area.
Step 601, the CPU requests the security processor to obtain a measurement result of the program to be executed, and receives a measurement result queried by the security processor from the on-chip storage area.
Step 602, the CPU compares the measurement result obtained from the secure processor with the measurement result that the program to be executed is correct.
Step 603, comparing the two are the same by the CPU, determining that the loaded program to be executed is complete, and executing the program to be executed.
Furthermore, an embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored, and the one or more programs are executable by one or more central processing units to implement the program metric verification method according to the foregoing embodiment.
Finally, another computer-readable storage medium is provided in an embodiment of the present invention, where one or more programs are stored, and the one or more programs are executable by one or more secure processors to implement the program metric verification method described in the foregoing embodiment one or embodiment two.
In summary, in the embodiments of the present invention, the measurement of the program to be executed is completed by the security processor disposed inside the system on chip, and the whole dynamic measurement root creation process is not required to communicate with the external TPM through the off-chip bus, but is completely implemented inside the system on chip, so that the risk that the off-chip bus is subjected to physical attack can be avoided, and the security of the off-chip bus is enhanced.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The term "and/or" in the embodiments of the present invention describes an association relationship of associated objects, and indicates that three relationships may exist, for example, a and/or B may indicate: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
For convenience of description, the above devices are described separately in terms of functional division into various units/modules. Of course, the functionality of the units/modules may be implemented in one or more software and/or hardware implementations of the invention.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.