TrustZone-based user-level code and data security and trust protection method and device

By encrypting and storing key codes in a protected memory area and using TrustZone to achieve safe isolation of user-level code and data, it solves the problem of TEE_OS being untrustworthy during operation in TrustZone technology and ensures the security and isolation of user-level code and data. sex.

CN112818327BActive Publication Date: 2024-10-01NAT UNIV OF DEFENSE TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202110217365.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-26
Publication Date
2024-10-01
Estimated Expiration
2041-02-26

AI Technical Summary

Technical Problem

The existing TrustZone technology lacks real-time detection and measurement during TEE_OS operation, resulting in users' private data and secure applications no longer safe in the face of attacks.

Method used

By encrypting and storing key codes in a protected memory area, only users are allowed to load and access, and other programs cannot access them. TrustZone is used to realize mutual calls between non-safe users and safe user codes, separate operation areas, and ensure the safety of each operation. Security.

Benefits of technology

It reduces the source of trust, ensures the security of user-level code and data, prevents private data from being stolen, solves the problem of untrustworthy privileged software such as operating systems, and achieves the isolation of secure storage and encryption operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112818327B_ABST
    Figure CN112818327B_ABST
Patent Text Reader

Abstract

The present invention discloses a user-level code and data security and trustworthy protection method and device based on TrustZone. The present invention stores key codes in a protected memory area by encryption. Only users can load and access their own key codes and data, and other programs including privileged software cannot access the user's key codes. At the same time, TrustZone is used to implement the mutual calling of non-secure state user and secure state user codes. Non-secure state users call secure state user codes to implement secure operations such as secure storage and encryption. Secure state users call non-secure state user codes to complete non-secure operations such as interrupts and system calls. Each operation is distinguished, solving the problems of untrustworthy privileged software such as operating systems and threats to secure states from non-secure codes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer operating systems, and in particular to a TrustZone-based user-level code and data security and trustworthy protection method and device, which are used to implement secure isolation of user-level code and data and mutual calling of non-secure state user code and secure state user code based on TrustZone. Background Art

[0002] TrustZone is a technology jointly supported by software and hardware proposed by ARM to improve system security. In terms of hardware, TrustZone adds an additional control signal bit called NS (Non-Secure) bit for the read and write of each channel on the system bus. The NS bit can be used to divide resources such as memory into secure state and non-secure state. The non-secure state can only access the system resources of the non-secure state, while the secure state can access all resources. TrustZone implements secure isolation of resources such as memory and IO through bus control and auxiliary controllers such as TZASC, TZMA, and TZPC. After TrustZone is enabled, the physical processor can switch between two security modes, which are defined as normal world (running the host OS) and secure world (running TEE OS). The software and hardware environments running in the secure state and non-secure state are called TEE (Trusted Execution Environment) environment and REE (Rich Execution Environment) environment respectively. TEE and REE are securely isolated through the monitor mode, and the system implements the switch between the secure state and the non-secure state through the secure monitor mode call (Secure Monitor Call, smc) instruction. In terms of software, TrustZone's security resources are scheduled and allocated by the trusted operating system (TEE_OS). TEE_OS runs in the TEE environment. When a request is issued in the non-secure state, the request is sent to TEE_OS through a secure monitoring mode call, and TEE_OS sends the request to the corresponding secure application for response and execution.

[0003] In order to ensure that TEE_OS is trustworthy, the TrustZone boot process adopts the idea of ​​trusted chain. ARM provides trusted firmware (ATF). The ATF source code is divided into bl1, bl2, bl31, bl32, and bl33. bl32 and bl33 are used to load the images on the TEE and REE sides respectively. The trusted source of the entire TrustZone is the CPU, and the trusted base is the Root of Trust Public Key (ROTPK), which is burned into a module that can only be written once inside the CPU (trusted root key storage register). During the TrustZone boot process, the loaded image file needs to be electronically signed before loading the image of the next stage. Only after the signature verification is passed, the corresponding image will be loaded into the memory, and then the system will proceed to the next step. In the entire trusted chain, as long as there is an error in one step, the system will hang. Through the idea of ​​trusted chain, the credibility and integrity of TEE_OS are ensured.

[0004] The complete operating mechanism of TrustZone is as follows: Figure 1 As shown in the figure, the applications implemented by TrustZone technology are divided into secure applications (trusted applications, TA) and non-secure applications (client applications, CA). CA runs in the REE environment and performs non-secure operations, while TA runs in the TEE environment and performs secure operations. CA initiates system calls through specific API interfaces, and the Linux driver accepts the request and switches to the kernel state TEE_OS through SMC for thread processing. TEE_OS loads the TA image and the data resources required for TA operation. TA responds to CA's request and performs related security operations. In the whole process, for users, TEE_OS is completely trustworthy, and any sensitive and confidential operations can be completed by TEE_OS.

[0005] After TrustZone is started, TEE_OS, as a trusted system, manages and schedules all security resources. For users, placing key code and private data on the TEE side can isolate non-secure access, thereby ensuring the security of code and data. However, the state of TEE_OS changes dynamically during operation. The startup based on the trusted chain is a static measurement of TEE_OS. There are many attack methods now, such as side channel attacks, buffer overflow attacks, phishing attacks, etc. Once these attack methods are successful, the highest permissions of the system can be obtained. For users, if TEE_OS is compromised, the code and data stored on the TEE side will face the risk of being stolen.

[0006] In order to solve the trust problem, Intel proposed SGX technology (Intel Software Guard Extensions). SGX technology adds EPC (enclave page cache) and EPCM (enclave pagecache map) hardware components based on the original Intel platform. Enclave is a protected area in the application address space. The SGX technology design divides a protected area PRM (Processor Reserved Memory) in the memory. PRM is used to store the contents of EPC and EPCM. The relationship between PRM, EPC and EPCM is as follows: Figure 2 As shown in the figure, EPC consists of several 4KB pages, which are used to store application privacy data and security operation codes. EPCM is designed to record the correspondence between EPC and enclave.

[0007] SGX technology divides an application into two parts: the secure application part and the non-secure application part. When each application is created and run, an enclave is created on the PRM to store the code and privacy data of the secure application part. The data stored in the enclave can only be accessed and called by the internal functions of the enclave, and other privileged or malicious software cannot access it. Non-secure applications and secure applications can call each other through a unified calling interface to complete different functions. The enclaves created by different applications are isolated from each other. Even if the operating system is compromised, SGX can still ensure the integrity and credibility of user code and data.

[0008] The difference between SGX technology and TrustZone technology is: first, the purpose of TrustZone design is to provide a large secure isolation environment for protecting system data; while the purpose of SGX design is to provide a secure execution environment for applications to protect user data. Second, TrustZone is based on software and hardware implementation, while SGX is fully hardware-based. Third, the way TrustZone provides services is that CA initiates a request, and TEE_OS responds to the request and replies; the secure program part and the non-secure program part of SGX can call each other.

[0009] TrustZone provides TEE_OS with resources to manage the TEE environment. For users, the premise of entrusting TEE_OS with management and access to their private data and secure applications is that TEE_OS must be trustworthy. Although TEE_OS is loaded using a trusted chain, the loaded TEE_OS is trustworthy. However, during the running process, there is a lack of detection and measurement of TEE_OS. If TEE_OS is attacked or even compromised, the user's private data and secure applications will no longer be safe. Summary of the invention

[0010] The technical problem to be solved by the present invention: In view of the above-mentioned problems of the prior art, a user-level code and data security and trustworthy protection method and device based on TrustZone are provided. The present invention stores the key code in a protected memory area by encryption, and only the user can load and access his own key code and data, and other programs including privileged software cannot access the user's key code. At the same time, TrustZone is used to realize the mutual calling of non-secure state user and secure state user code. The non-secure state user calls the secure state user code to realize secure operations such as secure storage and encryption, and the secure state user calls the non-secure state user code to complete non-secure operations such as interruption and system call, and each operation is distinguished, which solves the problem that privileged software such as the operating system is untrustworthy.

[0011] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0012] A TrustZone-based user-level code and data security trusted protection method includes the steps of secure application code in a secure operating system calling non-secure application code in a general operating system:

[0013] A1) The secure application code calls a dedicated system call interface to initiate a non-secure operation call request to the monitor through a driver in the secure operating system;

[0014] A2) The monitor uses the secure monitoring mode to call the non-secure operation call request into the general operating system in the kernel state;

[0015] A3) The general operating system in kernel state loads the target non-secure application code corresponding to the non-secure operation call request, and the target non-secure application code performs the corresponding non-secure operation, and after completing the corresponding work, returns the operation result to the secure application code that initiated the non-secure operation call request through the monitor.

[0016] Optionally, the calling interface functions available in the dedicated system call interface in step A1) include a return interface function return, a key acquisition interface function getkey and an external call interface function outcall, wherein the return interface function return is used to pass data to non-secure application code, the key acquisition function getkey is used for secure application code to obtain keys, and the external call interface function outcall is used for secure application code to call functions encapsulated in non-secure application code.

[0017] Optionally, before initiating a non-safe operation call request to the monitor through the driver in the secure operating system in step A1), a step of performing formal verification and security check on the dedicated system call interface call is also included.

[0018] Optionally, when calling a dedicated system call interface in step A1), if the calling command of the dedicated system call interface contains a passed string or array, and the calling command contains an address declaration of the string or array and the length of the passed string or array; the formal verification and security check include: reading the length of the string or array passed in the calling command, and determining whether the length of the passed string or array and the length declared in the transfer are different, if different, determining that an abnormal value is passed, terminating and exiting; otherwise, initiating a non-safe operation call request to the monitor through the driver in the secure operating system.

[0019] Optionally, after the general operating system in kernel state loads the target non-safe application code corresponding to the non-safe operation call request in step A3), it also includes starting a corresponding listening thread following the target non-safe application code, and each listening thread of the non-safe application code has an identifier corresponding to the non-safe application code, and the listening thread is used to listen to the non-safe operation call request from the safe application code; if the listening thread listens to the non-safe operation call request from the safe application code, the listening thread generates a new thread to execute the call request, and the new thread is destroyed immediately after completing the corresponding task, and the listening thread continues to listen to the task, and when the user program execution exits, the listening thread is destroyed.

[0020] Optionally, the method further includes the step of a non-secure application program code in the general operating system calling a secure application program code in the secure operating system:

[0021] B1) The non-safe application code executes an ioctl system call and initiates a safe operation call request to the monitor through the driver in the general operating system;

[0022] B2) The monitor uses the security monitoring mode to call the security operation call request into the security operating system in the kernel state;

[0023] B3) The kernel-state secure operating system loads the target secure application code corresponding to the secure operation call request. The target secure application code performs the corresponding secure operation and returns the operation result to the non-secure application code that initiated the secure operation call request through the monitor after completing the corresponding work.

[0024] Optionally, before the secure application code in the secure operating system calls the non-secure application code in the general operating system, the step of loading a user program is also included:

[0025] C1) determining whether the user program to be loaded contains the declared secure application program code and the non-secure application program code, and if so, jumping to the next step;

[0026] C2) Load the non-secure application code in the user program into the general operating system, and load the secure application code in the user program into the secure operating system.

[0027] Optionally, before loading the user program, a step of writing the user program is included, and the step of writing the user program includes:

[0028] D1) Declare the safety application code and the non-safety application code in the user program to be written;

[0029] D2) dividing the functional operations in the user program into safe operations and non-safe operations, wherein safe operations refer to operations involving the processing of user privacy data, and non-safe operations refer to operations not involving the processing of privacy data;

[0030] D3) Place secure operations in secure application code and non-secure operations in non-secure application code.

[0031] In addition, the present invention also provides a TrustZone-based user-level code and data security trusted protection device, including a microprocessor and a memory connected to each other, the microprocessor is programmed or configured to execute the steps of the TrustZone-based user-level code and data security trusted protection method, or the memory stores a computer program programmed or configured to execute the TrustZone-based user-level code and data security trusted protection method.

[0032] In addition, the present invention also provides a computer-readable storage medium, which stores a computer program programmed or configured to execute the TrustZone-based user-level code and data security trusted protection method.

[0033] Compared with the prior art, the present invention has the following advantages:

[0034] 1. The present invention stores the key code in a protected memory area by encryption. Only the user can load and access his own key code and data. Other programs including privileged software cannot access the user's key code. The present invention reduces the trust source point. The trust source point of the present invention is a low-privilege user-mode application. Each application is divided into two parts: secure application code and non-secure application code. The operating system can access the code and data of the non-secure application code, but cannot access the secure application code. The data and code of the non-secure application code can only be accessed and used by internal functions. For each application, it is trustworthy to store private data and code in the secure application part.

[0035] 2. The present invention utilizes TrustZone to implement mutual calls between non-secure user and secure user codes. Non-secure users call secure user codes to implement secure operations such as secure storage and encryption. Secure users call non-secure user codes to complete non-secure operations such as interrupts and system calls. Each operation is distinguished, which solves the problem of untrustworthy privileged software such as operating systems, and the problem of interaction between secure applications and unsecure operating systems. Strict formal verification is performed on interfaces to ensure the security of interfaces. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a schematic diagram of the complete operation mechanism of TrustZone in the prior art.

[0037] Figure 2 Schematic diagram of the relationship among PRM, EPC and EPCM in the prior art.

[0038] Figure 3 Schematic diagram of the operating mechanism in an embodiment of the present invention.

[0039] Figure 4 Schematic diagram of the system structure in an embodiment of the present invention. DETAILED DESCRIPTION

[0040] like Figure 3 and Figure 4 As shown, this embodiment is based on the TrustZone user-level code and data security trusted protection method, including the steps of secure application code located in a secure operating system calling non-secure application code located in a general operating system:

[0041] A1) The secure application code calls a dedicated system call interface to initiate a non-secure operation call request to the monitor through a driver in the secure operating system;

[0042] A2) The monitor uses the secure monitoring mode to call the non-secure operation call request into the general operating system in the kernel state;

[0043] A3) The general operating system in kernel state loads the target non-secure application code corresponding to the non-secure operation call request, and the target non-secure application code performs the corresponding non-secure operation, and after completing the corresponding work, returns the operation result to the secure application code that initiated the non-secure operation call request through the monitor.

[0044] like Figure 3 and Figure 4 As shown, in this embodiment, the ARM platform with TrustZone support runs a secure operating system (TEE_OS for short) on the TEE (Trusted Execution Environment) side and provides secure application support, and runs a general operating system (specifically Linux in this embodiment) on the REE (Rich Execution Environment) side. The method of this embodiment divides the user's program into two parts: secure application code and non-secure application code. The non-secure application code that does not involve privacy data processing is placed on the REE side, and the secure application code that involves user privacy data is placed on the TEE side. The secure isolation environment of TrustZone is used to ensure the security of key codes and privacy data, thereby providing secure and reliable services for user-level code and data on a computing platform with TEE extensions, and realizing mutual calls between non-secure state user code and secure state user code.

[0045] This embodiment includes streamlining the traditional system structure, and only allows the dedicated system call interface to be retained. In this embodiment, the call interface functions available in the dedicated system call interface in step A1) include a return interface function return, a key acquisition interface function getkey, and an external call interface function outcall, wherein the return interface function return is used to transfer data to the non-secure application code, the key acquisition function getkey is used for the secure application code to acquire the key, and the external call interface function outcall is used for the secure application code to call the function encapsulated in the non-secure application code.

[0046] In this embodiment, before initiating a non-safe operation call request to the monitor through the driver in the secure operating system in step A1), it also includes the steps of performing formal verification and security check on the dedicated system call interface call.

[0047] In this embodiment, when calling a dedicated system call interface in step A1), if the calling command of the dedicated system call interface contains a string or array to be passed, and the calling command contains a declaration of the address of the string or array and the length of the string or array to be passed; the formal verification and security check include: reading the length of the string or array passed in the calling command, and judging whether the length of the string or array passed and the length declared in the transfer are different, if they are different, determining that an abnormal value is passed, ending and exiting; otherwise, initiating a non-safe operation call request to the monitor through the driver in the secure operating system. Taking the outcall call as an example, outcall is the interface for TA to call CA. In order to ensure the reliability of the call, the logic of the interface must be considered first during the design, and the formal verification method must be used to detect whether the system interface meets the expected expectations. At the same time, the parameters passed by outcall must be strictly checked. In this embodiment, for the transfer of a string or array, it is necessary to declare the address of the string or array, and at the same time, the length of the string or array is required to prevent abnormal value transfer. The specific parameter check implementation is expressed in pseudo code as follows:

[0048]

[0049] This example takes a parameter as an example to check the passed parameter. If it is found that the parameter does not meet the specification, the parameter exception handling function is triggered to perform exception handling. Subsequent operations can be performed only after the parameter check passes.

[0050] In this embodiment, after the general operating system in the kernel state loads the target non-safe application code corresponding to the non-safe operation call request in step A3), it also includes starting a corresponding listening thread following the target non-safe application code, and each listening thread of the non-safe application code has an identifier corresponding to the non-safe application code, and the listening thread is used to listen to the non-safe operation call request from the safe application code; if the listening thread listens to the non-safe operation call request from the safe application code, the listening thread generates a new thread to execute the call request, and the new thread is destroyed immediately after completing the corresponding task, and the listening thread continues to listen to the task. When the user program is executed and exits, the listening thread is destroyed.

[0051] like Figure 3 and Figure 4 As shown, this embodiment also includes the step of the non-secure application code in the general operating system calling the secure application code in the secure operating system:

[0052] B1) The non-safe application code executes an ioctl system call and initiates a safe operation call request to the monitor through the driver in the general operating system;

[0053] B2) The monitor uses the security monitoring mode to call the security operation call request into the security operating system in the kernel state;

[0054] B3) The kernel-state secure operating system loads the target secure application code corresponding to the secure operation call request. The target secure application code performs the corresponding secure operation and returns the operation result to the non-secure application code that initiated the secure operation call request through the monitor after completing the corresponding work.

[0055] In this embodiment, before the secure application code in the secure operating system calls the non-secure application code in the general operating system, the step of loading the user program is also included:

[0056] C1) determining whether the user program to be loaded contains the declared secure application program code and the non-secure application program code, and if so, jumping to the next step;

[0057] C2) Load the non-secure application code in the user program into the general operating system, and load the secure application code in the user program into the secure operating system.

[0058] In this embodiment, before loading the user program, a step of writing the user program is included, and the step of writing the user program includes:

[0059] D1) Declare the safety application code and the non-safety application code in the user program to be written;

[0060] D2) dividing the functional operations in the user program into safe operations and non-safe operations, wherein safe operations refer to operations involving the processing of user privacy data, and non-safe operations refer to operations not involving the processing of privacy data;

[0061] D3) Place secure operations in secure application code and non-secure operations in non-secure application code.

[0062] There are many kinds of system calls for TA (security application) in the security operating system. In this embodiment, by canceling most of the system call interfaces of TA and lowering the privilege level of TA operation, most of TA's operations do not require the participation of the security operating system (TEE_OS), reducing the interaction between TA and TEE_OS, ensuring the independence of TA operation, and will not be interfered with by other privileged applications. At the same time, the reserved system call interfaces are as few as possible. The more system call interfaces, the more difficult it is to monitor the system call interfaces. When making system calls, this embodiment checks and formally verifies the system call interfaces to prevent the system call interfaces from being changed or other security issues. On the basis of the non-security application code calling the security application code, the function of the security application code calling the non-security application code is realized. The role of the customized system call is prominent. On the one hand, the customized system call is highly targeted, and only the corresponding security application code can be used to ensure the independence between the security application codes; on the other hand, the customized system call interface is used to call the non-security application code, and the non-security application code is used to make system calls, thereby reducing the interaction between the security application code and TEE_OS. In this embodiment, the non-secure application code calls the secure application code to encrypt data, and the secure application code provides a dedicated interface outcall to call the non-secure user code to print out the ciphertext, thereby avoiding the secure application code directly making a system call to the printer for printing, reducing the interaction between the secure user code and the privileged software, and thus improving the reliability of the system.

[0063] like Figure 3 and Figure 4As shown, in this embodiment, when the security application code provides a method of calling the outcall non-security application code through the designed dedicated interface, the security operating system first performs a formal check on the system call interface, and at the same time performs a parameter check on the passed parameters such as strings or arrays. If the verification is passed, the call of the security application code is responded to, otherwise the call of the security application code is rejected. After the call request is successful, the security application code uses the non-security application code to complete the non-security operation, and after the operation is completed, the result is returned to the security application code. A listening thread is added to the non-security application code, and the listening thread is used to listen to the call request from the security application code in the security operating system. Each security application code corresponds to a specific identifier. The listening thread identifies the identifier of the security application code corresponding to the non-security application code and completes the request task specified by the security application code. In this embodiment, the non-security application code adds a security listening node to listen to the call request of the security application in the security operating system, distinguishes the identifier of the call request, and each security application code corresponds to a call request identifier. Different system calls are determined by different call request identifiers to complete the specified request task. In this example, a new device number is added to the non-safe application code, the call request is monitored, and the identifier of the call request is distinguished. Each safe application code corresponds to a call request identifier, and different system calls are determined by different call request identifiers. In this embodiment, a listening thread is started for the safe listening node in the general operating system where the non-safe application code is located. When the non-safe application code starts running, the listening thread also runs. The call request of the safe application code is read by the listening thread. Once the call request is monitored, the listening thread generates a new thread to execute the call request. The new thread is destroyed immediately after completing the corresponding task. The listening thread continues to listen to the task. When the user program is executed and exited, the listening thread is destroyed. In summary, the method of this embodiment further divides the secure isolation environment, and divides the isolation of the system level into the isolation of the application level. The user's secure application and data are stored in their respective application-level isolation ranges to prevent private data from being stolen. Different application-level isolations cannot access each other, and users can only call functions within their own application-level isolation ranges to ensure data security. The original system call of the secure isolation environment is canceled, and a unified system call interface is designed to realize the function of mutual calling between secure applications and non-safe applications.Non-secure applications call secure applications through a unified system call interface to perform secure operations, ensuring the reliability of operations; secure applications call non-secure applications through a unified system call interface to perform system calls and other functions. All operations of secure applications are application-level operations, and system call operations are not performed directly. When a system-level call is required, the non-secure application is called through a unified system call interface to perform related operations to avoid interaction between the secure application and the operating system. The designed system call interface is strictly formally verified and checked. The purpose of canceling the original system call is to avoid interaction between the secure application and the operating system. The purpose of formally verifying the designed system call interface is to prevent the system call interface from being tampered with, the function value or address passed from being replaced, and to ensure the security and reliability of the system call. In this embodiment, the key code is stored in a protected memory area through encryption. Only the user can load and access their own key code and data, and other programs including privileged software cannot access the user's key code. At the same time, TrustZone is used to implement mutual calls between non-secure user and secure user codes. Non-secure users call secure user codes to implement secure operations such as secure storage and encryption. Secure users call non-secure user codes to complete non-secure operations such as interrupts and system calls. Each operation is distinguished, solving the problem of untrustworthy privileged software such as the operating system.

[0064] In addition, this embodiment also provides a user-level code and data security trusted protection device based on TrustZone, including a microprocessor and a memory connected to each other, the microprocessor is programmed or configured to execute the steps of the aforementioned user-level code and data security trusted protection method based on TrustZone, or the memory stores a computer program programmed or configured to execute the aforementioned user-level code and data security trusted protection method based on TrustZone.

[0065] In addition, this embodiment also provides a computer-readable storage medium, which stores a computer program programmed or configured to execute the aforementioned TrustZone-based user-level code and data security and trusted protection method.

[0066] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is a flowchart of the method, device (system), and computer program product according to the embodiment of the present application, and / or the processor executes instructions to generate instructions for implementing the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0067] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.

Claims

1. A user-level code and data security and trust protection method based on TrustZone, It is characterized in that The key code is stored in a protected memory area through encryption. Only the user can load and access his own key code and data. Other programs including privileged software cannot access the user's key code and data. For applications divided into two parts, namely, secure application code and non-secure application code, the steps for secure application code in the secure operating system to call non-secure application code in the general operating system are as follows: A1) The secure application code calls a dedicated system call interface to initiate a non-secure operation call request to the monitor through the driver in the secure operating system; A2) The monitor uses the secure monitoring mode to call the non-secure operation call request into the general operating system in the kernel state; A3) The general operating system in kernel mode loads the target non-secure application code corresponding to the non-secure operation call request, and the target non-secure application code performs the corresponding non-secure operation and returns the operation result to the secure application code that initiated the non-secure operation call request through the monitor after completing the corresponding work; After the general operating system in kernel state loads the target non-safety application code corresponding to the non-safety operation call request in step A3), the process further includes starting a corresponding listening thread following the target non-safety application code, and each listening thread of the non-safety application code has an identifier corresponding to the non-safety application code, and the listening thread is used to listen to the non-safety operation call request from the safety application code; If the listening thread listens to a non-safe operation call request from the safe application code, the listening thread generates a new thread to execute the call request. The new thread is destroyed immediately after completing the corresponding task, and the listening thread continues to listen to the task. When the user program is executed and exited, the listening thread is destroyed; The method also includes the steps of calling the secure application code located in the secure operating system from the non-secure application code located in the general operating system: B1) The non-secure application code executes the ioctl system call and initiates a secure operation call request to the monitor through the driver in the general operating system; B2) The monitor uses the security monitoring mode to call the security operation call request into the kernel state security operating system; B3) The kernel-state secure operating system loads the target secure application code corresponding to the secure operation call request. The target secure application code performs the corresponding secure operation and returns the operation result to the non-secure application code that initiated the secure operation call request through the monitor after completing the corresponding work.

2. The method for protecting user-level code and data security based on TrustZone according to claim 1, It is characterized in that The available calling interface functions of the dedicated system call interface in step A1) include a return interface function return, a key acquisition interface function getkey and an external call interface function outcall, wherein the return interface function return is used to pass data to non-secure application code, the key acquisition interface function getkey is used by secure application code to obtain keys, and the external call interface function outcall is used by secure application code to call functions encapsulated in non-secure application code.

3. The method for protecting user-level code and data security based on TrustZone according to claim 1, It is characterized in that Before initiating a non-safe operation call request to the monitor through the driver in the secure operating system in step A1), a step of performing formal verification and security check on the dedicated system call interface call is also included.

4. The method for protecting user-level code and data security based on TrustZone according to claim 3, It is characterized in that When calling the dedicated system call interface in step A1), if the calling command of the dedicated system call interface includes the transferred string or array, and the calling command includes the address declaration of the string or array and the length of the transferred string or array; The formal verification and security check includes: reading the length of the string or array passed in the call command, and determining whether the length of the string or array passed is different from the length declared in the transfer, and if they are different, determining that an abnormal value is passed, ending and exiting; Otherwise, a non-safe operation call request is initiated to the monitor through the driver in the secure operating system.

5. The method for protecting user-level code and data security based on TrustZone according to claim 1, It is characterized in that The method also includes the steps of calling the secure application code located in the secure operating system from the non-secure application code located in the general operating system: B1) The non-secure application code executes the ioctl system call and initiates a secure operation call request to the monitor through the driver in the general operating system; B2) The monitor uses the security monitoring mode to call the security operation call request into the kernel state security operating system; B3) The kernel-state secure operating system loads the target secure application code corresponding to the secure operation call request. The target secure application code performs the corresponding secure operation and returns the operation result to the non-secure application code that initiated the secure operation call request through the monitor after completing the corresponding work.

6. The method for protecting user-level code and data security based on TrustZone according to claim 1, It is characterized in that Before the secure application code in the secure operating system calls the non-secure application code in the general operating system, the step of loading a user program is also included: C1) Determine whether the user program to be loaded contains the declared secure application code and the non-secure application code. If it contains the secure application code and the non-secure application code, jump to the next step; C2) Load the non-secure application code in the user program into the general operating system, and load the secure application code in the user program into the secure operating system.

7. The method for protecting user-level code and data security based on TrustZone according to claim 6, It is characterized in that The step of writing the user program includes the following steps before loading the user program: D1) Declare the safety application code and the non-safety application code in the user program to be written; D2) The functional operations in the user program are divided into safe operations and non-safe operations, where safe operations refer to operations involving the processing of user privacy data, and non-safe operations refer to operations that do not involve the processing of privacy data; D3) Place secure operations in secure application code and non-secure operations in non-secure application code.

8. A user-level code and data security trusted protection device based on TrustZone, comprising a microprocessor and a memory connected to each other, It is characterized in that The microprocessor is programmed or configured to execute the steps of the TrustZone-based user-level code and data security and trusted protection method as described in any one of claims 1 to 7, or the memory stores a computer program that is programmed or configured to execute the TrustZone-based user-level code and data security and trusted protection method as described in any one of claims 1 to 7.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program programmed or configured to execute the TrustZone-based user-level code and data security trusted protection method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Secure storage service system and method based on TrustZone technology

    CN105260663A

  • A method for protecting the interaction integrity and confidentiality of a trusted application and a common application

    CN109558211A

  • Method, device and system for realizing multi-core parallel at TEE side

    CN109960582A

  • TrustZone-based programming method, terminal equipment and storage medium

    CN112329019A

  • Apparatus and method for inheriting a non-secure thread context

    US20140259101A1