Near Field Communication Methods, Configuration Methods, NFC Hosts, and Electronic Devices

By installing contactless applications in the TEE environment and using the secure process control application to communicate with the NFC controller, the problem of high hardware dependence in NFC devices is solved, flexible configuration and data security are achieved, and the security of the card reading process is improved. sex.

CN114302404BActive Publication Date: 2024-11-19GOODIX TECH (CHENGDU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111594904.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2024-11-19
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

The high dependence of security chips and related hardware in existing NFC devices leads to limited flexible configuration of contactless applications, and the security of data processing and communication during card reading is difficult to ensure.

Method used

Install contactless applications in TEE environment and communicate with the NFC controller through secure process control applications to realize card reading operations and RF parameter configuration, avoid dependence on security chips, improve configuration flexibility, and ensure data processing and communication security .

Benefits of technology

It improves the configuration flexibility and data processing security of contactless applications, ensures the security of data communication during card reading, and reduces dependence on security chips.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114302404B_ABST
    Figure CN114302404B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention provide a near field communication method, a configuration method, an NFC host, and an electronic device. The near field communication method is applied to an NFC host configured with a REE environment and a TEE environment, wherein a security process control application and a contactless application are installed in the TEE environment. The method comprises: the REE environment notifies the security process control application of the card discovery status of the NFC controller; the security process control application requests a card reading instruction from the contactless application according to the card discovery status; the security process control application sends the card reading instruction to the NFC controller, wherein the card reading instruction instructs the NFC controller to perform a card reading operation; the security process control application obtains the card reading response of the NFC controller, and forwards the card reading response to the contactless application. The solution of the embodiments of the present invention avoids dependence on related hardware such as security chips, and improves the configuration flexibility of security applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of communications, and in particular to a near field communication method, a configuration method, an NFC host, and an electronic device. Background Art

[0002] Near Field Communication (NFC) devices have multiple communication modes, including active mode and passive mode. Generally speaking, in active mode, NFC devices are used as card readers, actively emitting radio frequency signals to identify and read and write smart cards with radio frequency functions; passive mode is also called card emulation mode. In card emulation mode, NFC devices can act as smart cards and passively respond to the radio frequency field emitted by other NFC card readers to perform read and write operations.

[0003] The GP (Global Platform) specification is a specification that protects digital services by setting standards and certifying secure hardware or hardware combinations. It facilitates collaboration between service providers and device manufacturers, enabling them to ensure that all devices are secure enough to protect against threats.

[0004] Some smartphones have built-in NFC chips and secure chips (Secure Element, SE) that follow the GP specification. For example, the NFC chip is used as a card emulation mode in near-field communication, and the contactless application in the security chip is used to store card information of smart cards such as access cards, bus cards, electronic ID cards, bank cards, etc. Based on the GP specification, the contactless application can interact with the processor through the security chip, so that the smartphone can simulate the smart card to implement NFC card swiping operations. However, the security chip in this solution is highly dependent on related hardware, which is not conducive to the flexible configuration of contactless applications. Summary of the invention

[0005] In view of this, embodiments of the present invention provide a near field communication method, a configuration method, an NFC host, and an electronic device to at least partially solve the above problems.

[0006] According to a first aspect of an embodiment of the present invention, a near field communication method is provided, which is applied to an NFC host configured with a REE environment and a TEE environment, wherein a security process control application and a contactless application are installed in the TEE environment, and the method comprises: the REE environment notifies the security process control application of a card discovery status of an NFC controller; the security process control application requests a card read instruction from the contactless application according to the card discovery status; the security process control application sends the card read instruction to the NFC controller, wherein the card read instruction instructs the NFC controller to perform a card read operation; the security process control application obtains a card read response from the NFC controller, and forwards the card read response to the contactless application.

[0007] In other embodiments, the REE environment notifies the security process control application of the card discovery status of the NFC controller, including: the REE environment creates a first security process; the REE environment sends a first notification to the security process control application based on the first security process, and the first notification indicates the card discovery status of the NFC controller.

[0008] In other embodiments, the security process control application requests a card reading instruction from the contactless application based on the card discovery status, including: the security process control application creates a second security process based on the card discovery status; the security process control application requests a card reading instruction from the contactless application based on the second security process; and the security process control application ends the second security process after receiving the card reading instruction returned by the contactless application.

[0009] In other embodiments, the method further includes: after the sending of the card reading instruction is completed, the security process control application ends the first security process.

[0010] In some other embodiments, the method further includes: before the secure process control application obtains the card reading response of the NFC controller, the REE environment creates a third secure process. The REE environment sends a second notification to the secure process control application based on the third secure process, and the second notification instructs the secure process control application to obtain the card reading response of the NFC controller.

[0011] In other embodiments, the security process control application obtains the card reading response of the NFC controller and forwards the card reading response to the contactless application, including: the security process control application creates a fourth security process when obtaining the card reading response of the NFC controller; the security process control application forwards the card reading response to the contactless application based on the fourth security process, and ends the fourth security process.

[0012] In some other embodiments, the method further includes: after forwarding the card reading response to the contactless application, the secure process control application requests the contactless application for a next card reading instruction of the card reading instruction.

[0013] In some other embodiments, the method further includes: when the contactless application does not return a next card reading instruction of the card reading instruction, the security process control application ends the third security process.

[0014] In some other embodiments, the method further includes: when the contactless application returns a next card read instruction of the card read instruction, the security process control application updates the card read instruction based on the next card read instruction.

[0015] In other embodiments, the REE environment notifies the security process control application of the card discovery status of the NFC controller, including: the REE environment receives an interrupt instruction sent by the NFC controller; the REE environment notifies the security process control application to obtain the card discovery status from the NFC controller based on the interrupt instruction.

[0016] According to a second aspect of an embodiment of the present invention, a near field communication method is provided. The near field communication method is applied to an NFC host configured with a REE environment and a TEE environment, wherein a secure process control application and a contactless application are installed in the TEE environment, and the method comprises: the REE environment notifies the secure process control application of the card discovery status of the NFC controller; the secure process control application obtains the card reading instruction of the NFC controller to the contactless application according to the card discovery status, so that the contactless application generates a card reading response according to the card reading instruction; the secure process control application forwards the card reading response of the contactless application to the NFC controller.

[0017] In other embodiments, the REE environment notifies the security process control application of the card discovery status of the NFC controller, including: when the REE environment receives the card discovery status sent by the NFC controller, sending a third notification to the security process control application, the third notification instructing the security process control application to obtain the card reading instruction of the NFC controller from the NFC controller.

[0018] In some other embodiments, the method further includes: before the NFC controller sends the card discovery status, the NFC controller encapsulates the card reading instruction of the NFC controller into an event message based on the HCI interface via the HCI interface between the security process control application and the NFC controller. Accordingly, the third notification instructs the security process control application to obtain the event message based on the HCI interface from the NFC controller.

[0019] According to a third aspect of an embodiment of the present invention, a near field communication configuration method is provided, the near field communication method being applied to an NFC host configured with a REE environment and a TEE environment, wherein a security process control application and a contactless application are installed in the TEE environment, the method comprising: the security process control application receiving an RF parameter request from the REE environment; the security process control application forwarding the RF parameter request to the contactless application; the security process control application receiving the RF parameters returned by the contactless application in response to the RF parameter request; and the security process control application configuring an NFC controller based on the RF parameters.

[0020] In some other embodiments, the security process control application configures the NFC controller based on the RF parameters, including: the security process control application returns the RF parameters to the REE environment; the REE environment configures the NFC controller according to the NCI interface between the REE environment and the NFC controller.

[0021] In other embodiments, the security process control application configures the NFC controller based on the RF parameters, including: the security process control application generates an RF configuration instruction; the security process control application sends the RF configuration instruction to the NFC controller to make the NFC controller enter an RF parameter configuration state; the security process control application performs configuration on the NFC controller in the RF parameter configuration state based on the RF parameters.

[0022] According to a fourth aspect of an embodiment of the present invention, there is provided an NFC host, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, wherein the executable instruction enables the processor to perform an operation corresponding to the method described in any one of the first to third aspects.

[0023] According to a fifth aspect of the embodiments of the present invention, there is provided an electronic device, comprising: an NFC controller and the NFC host according to the third aspect. The NFC controller is in communication connection with the NFC host.

[0024] In the embodiment of the present invention, since the contactless application for near field communication is installed in a software environment such as a TEE environment, the dependence on related hardware such as a security chip is avoided, and the configuration flexibility of the contactless application is improved. In addition, during the card reading process, the contactless application and the security process control application respectively ensure the security of data processing and data communication. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0026] Figure 1 FIG. 4 is an exemplary architecture diagram of a near field communication system according to an embodiment of the present invention.

[0027] Figure 2A FIG. 4 is a flowchart of a near field communication method according to another embodiment of the present invention.

[0028] Figure 2B for Figure 2A A schematic interaction diagram of an example of a near field communication method.

[0029] Figure 2C for Figure 2A A schematic interactive diagram of an example of a near field communication method and configuration method.

[0030] Figure 2D for Figure 2A A schematic interaction diagram of an example of a near field communication configuration method.

[0031] Figure 2E FIG. 4 is a schematic diagram of a data frame format in near field communication according to another embodiment of the present invention.

[0032] Figure 2F FIG. 4 is a schematic diagram of an HCI interface initialization process according to another embodiment of the present invention.

[0033] Figure 3 The present invention is a flowchart of a near field communication configuration method according to another embodiment of the present invention.

[0034] Figure 4A FIG. 4 is a flowchart of a near field communication method according to another embodiment of the present invention.

[0035] Figure 4B for Figure 4A A schematic interaction diagram of an example of a near field communication method.

[0036] Figure 5 The figure is a schematic diagram of the structure of an NFC host according to an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.

[0038] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.

[0039] Figure 1 FIG. 4 is an exemplary architecture diagram of a near field communication system according to an embodiment of the present invention. Figure 1 The near field communication system shown includes an NFC host and an NFC controller (NFC Controller, NFCC). The NFC host can also be called a device host (Device Host, DH), which can configure the NFC controller so that the NFC controller implements the corresponding card reading mode and card emulation mode. In the card reading mode, the remote card can be read via the configured NFC controller. In the card emulation mode, the NFC controller can obtain an external card reading instruction and return a card reading response, that is, a card reading result, to the outside. Figure 1 The near field communication system shown can be configured in an electronic device, and the electronic device includes but is not limited to an embedded device, an Internet of Things device, a terminal device, etc. with near field communication capabilities.

[0040] The NFC host can be configured with a Trusted Execution Environment (TEE) and a Rich Execution Environment (REE). Specifically, the TEE environment can be configured with its own operating system and applications, and the REE environment can also be configured with its own operating system and applications. Normally, the REE environment cannot access the TEE environment, but through the protocol specified by the (Global Platform, GP) specification, the REE environment can access the resources of the TEE environment through a secure process. For example, the REE environment can access the TEE environment through a secure process such as TA_invoke. In addition, within the TEE environment, different applications can also use secure processes such as TA_invoke to perform access. Secure processes such as TA_invoke enable the corresponding memory space to be accessed within a certain period. When the secure process ends, the corresponding memory space cannot be accessed, thereby improving the security of access.

[0041] Generally speaking, the NFC host can perform configuration operations such as NCI interface (NFC ControllerInterface) configuration on the NFC controller. In order to improve communication reliability, data communication between the NFC host and the NFC controller is implemented through a bus. For example, the bus connection between the NFC controller and the NFC host includes GPIO bus 1 and I2C bus, which are used to carry the existing NCI command interaction under REE.

[0042] In order to implement the near field communication method of the embodiment of the present invention, a first bus and a second bus may be further configured between the NFC controller and the NFC host. The first bus may be a bus used between the REE environment (e.g., the hardware abstraction layer in the REE environment) and the NFC controller, for example, GPIO bus 2. It should be understood that the further configured GPIO bus 2 is a GPIO bus other than the GPIO bus 1 used for NCI interface communication, and the transmission based on the GPIO bus 2 can perform simplex communication such as interrupt operation.

[0043] The second bus may be a bus such as a serial peripheral interface (SPI) or I2C for use between the TEE environment and the NFC controller. The second bus may perform duplex communication such as between a master device side and a slave device side.

[0044] Figure 2A FIG. 4 is a flowchart of a near field communication method according to another embodiment of the present invention. Figure 2AThe near field communication method is applied to an NFC host configured with a REE environment and a TEE environment, and a security process control application and a contactless application are installed in the TEE environment. Contactless applications include, but are not limited to, applications related to card reading or identification, such as payment (for example, a bank card or a bus card) and identity authentication. The contactless application can be at least one application installed in an electronic device. The security process control application can perform security process-based communications with a REE environment outside the TEE environment, and can also perform security process-based communications with a contactless application within the TEE environment. In other words, the contactless application is used for data processing related to card information, and the security process control application is used for data communication related to card information. In one example, a REE environment such as a hardware abstraction layer (HAL) does not allow data or instructions to be requested from a contactless application. The contactless application does not allow data or instructions to be requested from the security process application.

[0045] The solution of this embodiment is applicable to the NFC card reading mode, including:

[0046] S2100: The REE environment notifies the secure process control application of the card discovery status of the NFC controller.

[0047] It should be understood that the card discovery state indicates that the NFC controller detects the presence of a remote card, for example, the NFC controller sends a radio frequency signal, and when a response to the radio frequency signal is received, it indicates that a remote card exists. The REE environment can perform the above notification operation through a security process.

[0048] S2200: The security process control application requests a card reading instruction from the contactless application according to the card discovery status.

[0049] It should be understood that the security process control application can request a card reading instruction based on the security process, and after obtaining the card reading instruction, the security process can be terminated. The requested card reading instruction is used to perform a read operation on the card information, and the read operation can be for at least one card. When reading multiple cards, each card reading instruction performs a read operation on the card once. In other words, the current card reading instruction can be obtained first, and then the next card reading instruction can be obtained. In one example, when the card reading operation is used in a scenario for payment or identity recognition, a card reading can indicate a card swipe.

[0050] S2300: The security process control application sends a card reading instruction to the NFC controller, and the card reading instruction instructs the NFC controller to perform a card reading operation.

[0051] It should be understood that the secure process control application can send a card reading instruction during the cycle of the secure process with the REE environment. Since the secure process control application is in the TEE environment, the secure process control application has the authority to send a card reading instruction to the NFC controller outside the TEE environment during the cycle of the secure process.

[0052] S2400: The security process control application obtains a card reading response from the NFC controller, and forwards the card reading response to the contactless application.

[0053] It should be understood that the card reading response indicates the card reading result of the NFC controller. After the contactless application obtains the card reading response, it can perform various subsequent application operations, for example, perform payment card swiping or identity authentication process according to the result indicated by the card reading response.

[0054] In an embodiment of the present invention, a contactless application for near field communication is installed in a TEE environment, which improves the security of data processing related to card reading instructions and card reading responses of the contactless application. In addition, a secure process control application ensures the security of data communication with the TEE environment.

[0055] It should be understood that Figure 1 The data reading and writing process between the NFC controller and the NFC host in the near field communication system can adopt the following scheme:

[0056] Example 1: Sending data from NFC controller to NFC host

[0057] The NFC controller and the REE environment of the NFC host are connected by a first bus such as a GPIO bus. For example, the NFC controller is connected to the hardware abstraction layer (HAL) of the REE environment. The NFC controller can place the target data in the buffer area, and then initiate an interrupt instruction to the REE environment through the first bus, and the signal of the interrupt instruction can be implemented at a preset high level or low level. The REE environment can be interrupted in response to the interrupt instruction, and then a data read instruction is sent to the NFC controller through the TEE environment (for example, a secure process control application) to read the target data from the buffer to the TEE environment. Specifically, the TEE environment can be connected to the NFC controller by a second bus such as SPI or I2C, and the TEE environment can send a data read instruction through the second bus to perform a data reading process. For example, the TEE host is the master device side of the second bus, and the NFC controller is the slave device side of the second bus. When the target data is placed in the buffer area of ​​the NFC controller, the TEE environment sends a data read instruction as the master device to the NFC controller as the slave device side, and the target data can be directly read.

[0058] Example 2: Sending data from NFC controller to NFC host

[0059] The TEE environment (e.g., a secure process control application) can be connected to the NFC controller using a second bus such as SPI or I2C. The TEE sends a polling read instruction through the second bus. When the NFC controller receives the polling read instruction after determining the target data, it returns the target data to the TEE environment. For example, the TEE host acts as the master device of the second bus, the NFC controller acts as the slave device of the second bus, and the TEE environment acts as the master device to send a polling read instruction to the NFC controller acting as the slave device. The NFC controller that receives the polling read instruction returns a read response carrying the target data to the TEE environment accordingly.

[0060] In one example, the data frame structure of the target data includes a start field and a subsequent field, and the subsequent field includes a data length information field, a data field, and an optional field. Figure 2E As shown, the start field can be 1 Byte, for example, 0x12. The data length information field can be 2 Bytes, and the optional field can be 2 Bytes of CRC check information. It should be understood that when the TEE environment reads the target data, it first determines whether the correct start field is read. If the start field is correct, it continues to read the subsequent fields of the target data.

[0061] Example 3: Sending data from NFC host to NFC controller

[0062] The TEE environment (e.g., the secure process control application) can be connected to the NFC controller using a second bus such as SPI or I2C. The TEE environment writes the target data to the buffer area of ​​the NFC controller through the second bus and sends an interrupt instruction to the NFC controller. Then, the NFC controller responds to the interrupt instruction and reads the target data.

[0063] As an example, the NFC controller receives an interrupt instruction, stops current data processing, and responds to the interrupt instruction. As another example, the NFC controller is in a state of waiting for an interrupt instruction from the TEE environment, and when the NFC controller receives the interrupt instruction, it responds to the interrupt instruction.

[0064] In one example, the data frame structure of the target data includes a start field and a subsequent field, and the subsequent field includes a data length information field, a data field, and an optional field. Figure 2E As shown, the start field may be 1 Byte, for example, 0x34. The data length information field may be 2 Bytes, and the optional field may be 2 Bytes of CRC check information.

[0065] It should be understood that when writing target data, the TEE environment can write the starting field and subsequent fields in sequence.

[0066] The following will be combined Figure 2B right Figure 2A An example of a near field communication method is described and illustrated in detail.

[0067] As an example of the REE environment notifying the security process control application of the card discovery status of the NFC controller, the REE environment creates a first security process and sends a first notification to the security process control application based on the first security process. The first notification indicates the card discovery status of the NFC controller. More specifically, in Figure 2B In step 101, when the NFC controller detects the peer card, it can generate an RF interface activation notification RF_INTF_ACTIVATED_NTF based on the RF interface specification, and then send the RF interface activation notification to the NFC host. Then, the NFC host notifies the security process control application of detecting the card through the first security process TA (Trusted Application) Invoke of the GP standard. Alternatively, the REE environment can receive an interrupt instruction sent by the NFC controller, and the REE environment notifies the security process control application to obtain the card discovery status from the NFC controller according to the interrupt instruction.

[0068] In addition, as an example in which the security process control application requests a card reading instruction (i.e., a current card reading instruction) from the contactless application according to the card discovery status, the security process control application creates a second security process according to the card discovery status, and requests a card reading instruction from the contactless application based on the second security process. Figure 2B In step 102, the security process control application notifies the contactless application through the second security process TA Invoke that the card is detected, and obtains a card reading instruction.

[0069] The security process control application may terminate the second security process after receiving the card reading instruction returned by the contactless application. For example, in step 103, the contactless application returns the card reading instruction to the security process control application, and terminates the calling of the second security process TA Invoke.

[0070] As an example of a secure process control application sending a card read command to the NFC controller, Figure 2B In step 104, the security process control application can send the card reading instruction to the NFC controller in the manner of Example 3.

[0071] In addition, after the card reading instruction is sent, the security process control application ends the first security process. Specifically, in step 105, after the card reading instruction is sent, the security process control application ends the call of the first security process TAInvoke.

[0072] It should be understood that the card reading instruction instructs the NFC controller to perform a card reading operation. Specifically, in step 106, after receiving the card reading instruction, the NFC controller forwards it to the remote card, and in step 107, the remote card returns a card reading response to the NFC controller.

[0073] As an example of a secure process controlling an application to obtain a card reading response from an NFC controller, the REE environment may create a third secure process. It should be understood that the REE environment may respond to an interrupt instruction and create a third secure process TA Invoke. For example, in step 108, the NFC controller places the card reading response in a sending buffer and sends an interrupt instruction to the NFC host via GPIO, and in step 109, the REE environment creates a third secure process TA Invoke.

[0074] Then, the REE environment sends a second notification to the security process control application based on the third security process, and the second notification instructs the security process control application to obtain the card reading response of the NFC controller. For example, in step 109, the REE HAL notifies the security process control application to read the card reading response by calling the third security process TA Invoke.

[0075] As an example of the secure process control application obtaining the card reading response of the NFC controller, in step 110, the secure process control application may read the card reading response from the NFC controller by the method of the above-mentioned example 1 or example 2.

[0076] Then, the security process control application obtains the card reading response of the NFC controller and forwards the card reading response to the contactless application. As an example, when the security process control application obtains the card reading response of the NFC controller, it creates a fourth security process TA Invoke, and then, based on the fourth security process TA Invoke, the security process control application forwards the card reading response to the contactless application, and ends the fourth security process TA Invoke after the forwarding is completed.

[0077] Specifically, in Figure 2B In step 111, the security process control application sends the card reading response to the contactless application. For example, the security process control application creates a fourth security process TA Invoke, and sends the card reading response to the contactless application via the fourth security process TA Invoke. More specifically, after sending the card reading response to the contactless application, the security process control application can directly end the fourth security process.

[0078] Alternatively, after forwarding the card reading response to the contactless application, the security process control application may request the contactless application for the next card reading instruction of the card reading instruction. For example, after the security process control application sends the card reading response to the contactless application, it requests the next card reading instruction. Then, when the contactless application does not return the next card reading instruction of the card reading instruction, the security process control application may end the third security process, and the card reading operation ends. For example, Figure 2B In step 112, if the contactless application does not return the next card reading instruction, it means that the card reading operation is completed, so the security process control application ends the third security process.

[0079] Alternatively, in step 113, if the security process control application receives the next card reading instruction, the next card reading instruction is sent to the NFC controller. Figure 2B In step 114, after the security process control application successfully sends the next card reading instruction to the NFC controller, it ends the third security process TA Invoke created in step 109, and updates the card reading instruction (i.e., the current card reading instruction) based on the next card reading instruction, so as to return to step 106 to continue the card reading process. If the contactless application does not return the next card reading instruction of the card reading instruction, the end of the third security process TA Invoke indicates the end of the card reading operation.

[0080] The following will be combined Figure 2C Detailed description and instructions Figure 2A It should be understood that in the near field communication method of this example, the configuration of the HCI (Host Controller Interface) interface is completed between the security process control application and the NFC controller, and communication can be performed based on the HCI interface.

[0081] Specifically, as an example of the REE environment receiving an interrupt instruction sent by the NFC controller, in step 208, after detecting the peer card, the NFC controller generates data HCI EVT_TARGET_DISCOVERED indicating the card discovery status based on the HCI interface specification, and notifies the NFC host based on the first bus.

[0082] Then, as an example of the REE environment notifying the security process control application to obtain the card discovery status from the NFC controller according to the interrupt instruction, in step 209, after receiving the interrupt instruction based on the first bus, the REE environment notifies the security process control application of the card discovery status of the NFC controller through the first security process TA Invoke. Then, in step 210, the security process control application reads the data HCI EVT_TARGET_DISCOVERED indicating the card discovery status in the manner of Example 1. It should be understood that in other implementations, the security process control application can also read the data indicating the card discovery status in the manner of Example 2.

[0083] Then, the security process control application creates a second security process according to the card discovery status, and requests a card reading instruction from the contactless application based on the second security process. For example, in step 211, the security process control application notifies the contactless application that the card is detected and requests a card reading instruction. Then, in step 212, the contactless application returns the card reading instruction, and accordingly, the security process control application can directly end the second security process or continue to request the next card reading instruction of the card reading instruction. If the contactless application does not return the next card reading instruction in step 212, then in step 214, the security process control application ends the first security process, in other words, returns to the call of the first security process TA Invoke created in step 209.

[0084] It should be understood that before executing step 214, the security process control application sends a card reading instruction to the NFC controller. For example, in step 213, if the security process control application receives the card reading instruction, the card reading instruction is actively written to the NFC controller; if the contactless application does not return the next card reading instruction, the security process control application generates a notification indicating the end of the card reading operation, and sends the card reading operation end notification to the NFC controller, for example, sending a card reading operation end notification HCI EVT_END_OPERATION to the NFC controller based on the HCI interface.

[0085] As an example of a card reading operation, in step 215, after receiving the card reading instruction, the NFC controller forwards the card reading instruction to the remote card; if the NFC controller receives the card reading operation end notification HCI EVT_END_OPERATION, the card reading operation ends.

[0086] As an example of the secure process control application obtaining the card reading response of the NFC controller, in step 216, after the remote card processes the card reading instruction, it returns the card reading response to the NFC controller. Accordingly, the secure process control application can obtain the card reading response from the NFC controller in the manner of the above-mentioned example 1 or example 2. It should be understood that the NFC controller uses Figure 2BThe implementation method in executes the process after obtaining the card reading response, which will not be repeated in this example.

[0087] Figure 3 The figure is a flowchart of a near field communication configuration method according to another embodiment of the present invention. Figure 3 The near field communication configuration method is applied to an NFC host configured with a REE environment and a TEE environment, wherein a secure process control application and a contactless application are installed in the TEE environment, and the method comprises:

[0088] S3100: The security process control application receives an RF parameter request from the REE environment.

[0089] S3200: The security process control application forwards the RF parameter request to the contactless application.

[0090] S3300: The security process control application receives the RF parameters returned by the contactless application in response to the RF parameter request.

[0091] S3400: The security process control application configures the NFC controller based on the RF parameters.

[0092] In an embodiment of the present invention, a contactless application for near field communication is installed in a TEE environment, which improves the security of data processing related to RF parameters of the contactless application. In addition, a secure process control application ensures the security of communication with the TEE environment, thereby achieving the security of RF parameter configuration.

[0093] It should be understood that the RF parameter request is used to request RF parameters, which are used by the NFC controller to perform RF-related operations, and the RF parameters include technology and mode information, discovery frequency information, etc. When the contactless application is activated, the contactless application returns the RF parameters in response to the RF parameter request; when the contactless application is not activated, the activation request for the contactless application can be used as the RF parameter request, and accordingly, when the contactless application is activated, the RF parameters are returned to the security process control application.

[0094] In some examples, the security process control application configures the NFC controller based on RF parameters, including: the security process control application generates an RF configuration instruction, the security process control application sends the RF configuration instruction to the NFC controller to put the NFC controller into an RF parameter configuration state, and then the security process control application performs configuration on the NFC controller in the RF parameter configuration state based on the RF parameters.

[0095] The following will be combined Figure 2CAn example of a secure process control application obtaining RF parameters is described. Specifically, in step 201, the REE environment creates a fifth secure process TA Invoke, and sends an RF parameter request to the secure process control application via the fifth secure process. Then, in step 202, the secure process control application creates a sixth secure process TA Invoke, and forwards the RF parameter request obtained in step 201 to the contactless application via the sixth secure process. Then, in step 203, the contactless application returns its own RF parameters to the secure process control application. For example, the RF parameter request can be used to activate the contactless application, and after being activated, the contactless application returns the RF parameters to the secure process control application.

[0096] As an example of generating an RF configuration instruction, the RF configuration instruction generated by the security process control application is based on the HCI interface between the NFC controller. In other words, the security process control application generates the RF configuration instruction HCIANY_SET_PARAMETERS CMD based on the HCI interface protocol.

[0097] Then, in step 204, the secure process control application sends an RF configuration instruction to the NFC controller.

[0098] Specifically, the security process control application can write the RF configuration instruction as the target data to the NFC controller in the manner of the above example three. Then, in step 205, the configuration response returned by the NFC controller based on the HCI interface is received. After the NFC controller returns the configuration response, it enters the RF parameter configuration state. For example, the security process control application can read the configuration response HCI ANY_OK RSP in the manner of example one or example two.

[0099] Then, in step 206, the security process control application may send the RF parameters to the NFC controller in the RF parameter configuration state to configure the NFC controller. For example, the security process control application may encapsulate the RF parameters into an RF parameter event message HCI EVT_READER_REQUESTED based on the HCI interface protocol and send it to the NFC controller. Specifically, the security process control application may write the RF parameter event message as the target data to the NFC controller in the manner of the above example three.

[0100] Then, in step 207, after the security process control application completes configuring the NFC controller, the security process control application ends the fifth security process TA Invoke.

[0101] In some other examples, the secure process control application configures the NFC controller based on the RF parameters, including: the secure process control application returns the RF parameters to the REE environment, and the REE environment configures the NFC controller according to the NCI interface between the REE environment and the NFC controller.

[0102] The following will be combined Figure 2D Describe the RF configuration process in detail. Figure 2D Steps 301-303 in the process may correspond to steps 201-203 respectively, and will not be described in detail here.

[0103] As an example of the secure process control application returning RF parameters to the REE environment, in step 304, the secure process control application returns the RF parameters to the REE environment.

[0104] As an example of configuring the NFC controller by the REE environment, in step 305, the REE environment configures the RF parameters to the NFCC in the form of an NCI command.

[0105] It should be understood that before the NFC controller or the security process control application sends data via the HCI interface, the HCI interface needs to be initialized.

[0106] The following will be combined Figure 2F The initialization process of the HCI interface between the secure process control application and the NFC controller is described.

[0107] In step 31, the REE environment sends an activation instruction for activating the contactless application to the secure process control application. For example, the REE environment creates a seventh secure process TA Invoke, and sends an activation instruction for activating the contactless application to the secure process control application via the seventh secure process TA Invoke.

[0108] In step 32, the security process control application forwards the activation instruction to the contactless application. For example, the security process control application creates an eighth security process TA Invoke, and sends the activation instruction to the contactless application via the eighth security process TA Invoke. It should be understood that the activation instruction is used to activate the contactless application, and after the contactless application is activated, the application parameters of the contactless application are generated.

[0109] In step 33, the contactless application may return application parameters to the security process control application, for example, the contactless application may return application parameters to the security process control application via the eighth security process TA Invoke. It should be understood that the application parameters herein include activation status of the contactless application, contactless parameters, etc.

[0110] In step 34, the secure process control application sends an initialization instruction of the HCI interface to the NFC controller. For example, the secure process control application saves application parameters of the contactless application, and after saving the application parameters, sends an initialization instruction HCI CMD of the HCI interface to the NFC controller.

[0111] It should be understood that based on the HCI interface protocol, the HCI CMD includes but is not limited to instructions such as Get Parameter, Clear AllPipe, Open Pipe, and Set Parameter.

[0112] It should also be understood that after the HCI interface is initialized, there is no interface for direct communication between the contactless application and the NFC controller. At this time, the security process control application needs to determine the status of the contactless application based on the application parameters, so as to reliably realize data communication with the contactless application, and further realize reliable data forwarding between the NFC controller and the contactless application.

[0113] In step 35, the security process control application receives the initialization response of the HCI interface returned by the NFC controller. It should be understood that the initialization response of the HCI interface can be an HCI RSP according to the HCI interface protocol. For example, after the security process control application sends the initialization instruction HCI CMD to the NFC controller, it can read the HCI RSP in a polling manner in the manner of the above-mentioned example 2. More specifically, after receiving the initialization instruction HCI CMD, the NFC controller places the HCI RSP in a buffer and sends it to the security process control application.

[0114] In step 36, the security process control application ends the HCI initialization process. For example, the security process control application notifies the HAL in the REE environment to end the seventh security process TA Invoke.

[0115] Figure 4A FIG. 4 is a flowchart of a near field communication method according to another embodiment of the present invention. Figure 4AThe near field communication method is applied to an NFC host configured with a REE environment and a TEE environment, and a security process control application and a contactless application are installed in the TEE environment. The contactless application includes but is not limited to applications related to card reading or identification such as payment (for example, a bank card or a bus card) and identity authentication. The contactless application can be at least one application installed in an electronic device. The security process control application can perform security process-based communications with a REE environment outside the TEE environment, and can also perform security process-based communications with a contactless application within the TEE environment. In other words, the contactless application is used for data processing related to card information, and the security process control application is used for data communication related to card information. In one example, a REE environment such as a hardware abstraction layer (HAL) does not allow data or instructions to be requested from a contactless application. The contactless application does not allow data or instructions to be requested from the security process control application.

[0116] The solution of this embodiment is applicable to the NFC card emulation mode, including:

[0117] S4100: The REE environment notifies the security process control application of the card discovery status of the NFC controller.

[0118] S4200: The security process control application obtains the card reading instruction of the NFC controller according to the card discovery status and transmits it to the contactless application, so that the contactless application generates a card reading response according to the card reading instruction.

[0119] S4300: The security process control application forwards the card reading response of the contactless application to the NFC controller.

[0120] In an embodiment of the present invention, a contactless application for near field communication is installed in a TEE environment, which improves the security of data processing related to card reading instructions and card reading responses of the contactless application. In addition, a secure process control application ensures the security of data communication with the TEE environment.

[0121] It should be understood that the card is found state indicates that the NFC controller is read by the card reader device. For example, the NFC controller receives the RF read signal of the remote card reader device. In addition, the card read response forwarded to the NFC controller can be obtained by the card reader device to complete the card reading operation.

[0122] It should also be understood that, similar to the NFC card reading mode, the card reading operation can be used in payment or identity recognition scenarios, and one card reading can indicate one card swipe.

[0123] Figure 4B Shows Figure 4A An example of a near field communication method.

[0124] As an example of the REE environment notifying the security process control application of the card being discovered, when the REE environment receives the card being discovered sent by the NFC controller, it sends a third notification to the security process control application, and the third notification instructs the security process control application to obtain the card reading instruction of the NFC controller from the NFC controller.

[0125] More specifically, in step 401, the remote card reader sends a card reading instruction to the NFC controller, and after receiving the card reading instruction, the NFC controller enters a card discovery state.

[0126] Then, the NFC controller notifies the REE environment of the card being found. Specifically, in step 402, the NFC controller places the card reading instruction in the sending buffer, and then sends an interrupt signal to the REE environment via the first bus, for example, by pulling up a GPIO interrupt signal. In other words, the card reading instruction is sent in the manner of Example 1 above.

[0127] Then, the REE environment sends a third notification to the security process control application. Specifically, in step 403, the NFC host creates a ninth security process TA Invoke based on the HAL, and notifies the security process control application of the card being discovered via the ninth security process. More specifically, before the NFC controller sends the card being discovered status, the NFC controller encapsulates the card reading instruction of the NFC controller into an event message based on the HCI interface via the HCI interface between the security process control application and the NFC controller. Accordingly, the third notification instructs the security process control application to obtain an event message based on the HCI interface from the NFC controller.

[0128] As an example of obtaining the card reading instruction of the NFC controller to the contactless application, in step 404, the security process control application reads the card reading instruction from the NFC controller based on the second bus, for example, the security process control application initiates an SPI read operation to read out the card reading instruction.

[0129] In step 405, the security process control application forwards the card reading instruction to the contactless application for processing. For example, the security process control application sends the card reading instruction to the contactless application based on the tenth security process TA Invoke. It should be understood that after receiving the card reading instruction, the contactless application performs the corresponding card reading process and obtains a card reading response.

[0130] As an example of the security process controlling the application to forward the card reading response of the contactless application, the contactless application returns the corresponding card reading response in step 406. For example, the card reading response is still returned based on the tenth security process TA Invoke.

[0131] Then, in step 407, the security process control application may write a card reading response to the NFC controller based on the second bus, for example, initiate an SPI write operation to write the card reading response to the NFC controller.

[0132] Then, in step 408, the NFC controller receives the write operation, receives the card read response, and then returns the card read response to the remote card reader.

[0133] In addition, in step 409 , after the security process control application writes the card reading response to the NFC controller, the security process control application returns to the ninth security process TA Invoke created in step 403 .

[0134] Reference Figure 5 The structure diagram of the NFC host according to another embodiment of the present invention is shown, but it should be understood that the specific embodiment of the present invention does not limit the specific implementation method of the NFC host.

[0135] like Figure 5 As shown, the NFC host may include: a processor (processor) 502 , a communications interface (Communications Interface) 504 , a memory (memory) 506 , and a communication bus 508 .

[0136] The processor 502 , the communication interface 504 , and the memory 506 communicate with each other via a communication bus 508 .

[0137] The communication interface 504 is used to communicate with other electronic devices or servers.

[0138] The processor 502 is used to execute the program 510, and specifically can execute the relevant steps in the above method embodiment.

[0139] Specifically, the program 510 may include program codes, which include computer operation instructions.

[0140] The processor 502 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0141] The memory 506 is used to store the program 510. The memory 506 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0142] The program 510 may be specifically used to enable the processor 502 to perform the operations of the above-mentioned near field communication method.

[0143] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.

[0144] The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the verification code generation method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the verification code generation method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the verification code generation method shown here.

[0145] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.

[0146] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not intended to limit the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.

Claims

1. A near field communication method, characterized in that: Applied to an NFC host configured with a REE environment and a TEE environment, wherein a secure process control application and a contactless application are installed in the TEE environment, the method comprises: The REE environment notifies the secure process control application of the card discovery status of the NFC controller; The security process control application requests a card reading instruction from the contactless application according to the card discovery status; The security process control application sends the card reading instruction to the NFC controller, wherein the card reading instruction instructs the NFC controller to perform a card reading operation; The security process control application obtains a card reading response from the NFC controller and forwards the card reading response to the contactless application.

2. The method according to claim 1, characterized in that The REE environment notifies the secure process control application of a card discovery status of the NFC controller, including: The REE environment creates a first security process; The REE environment sends a first notification to the security process control application based on the first security process, where the first notification indicates a card discovery status of the NFC controller.

3. The method according to claim 2, characterized in that The security process control application requests a card reading instruction from the contactless application according to the card discovery state, including: The security process control application creates a second security process according to the card discovery status; The security process control application requests a card reading instruction from the contactless application based on the second security process; After receiving the card reading instruction returned by the contactless application, the security process control application ends the second security process.

4. The method according to claim 2, characterized in that: The method further comprises: After the sending of the card reading instruction is completed, the security process control application ends the first security process.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Before the security process control application obtains the card reading response of the NFC controller, the REE environment creates a third security process; The REE environment sends a second notification to the security process control application based on the third security process, where the second notification instructs the security process control application to obtain a card reading response from the NFC controller.

6. The method according to claim 5, characterized in that The security process control application obtains a card reading response from the NFC controller and forwards the card reading response to the contactless application, including: The security process control application creates a fourth security process when obtaining a card reading response from the NFC controller; The security process control application forwards the card reading response to the contactless application based on the fourth security process, and ends the fourth security process.

7. The method according to claim 5, characterized in that The method further comprises: After forwarding the card reading response to the contactless application, the secure process control application requests the contactless application for a next card reading instruction of the card reading instruction.

8. The method according to claim 7, characterized in that The method further comprises: When the contactless application does not return a next card reading instruction of the card reading instruction, the security process control application ends the third security process.

9. The method according to claim 7, characterized in that: The method further comprises: When the contactless application returns a next card reading instruction of the card reading instruction, the secure process control application updates the card reading instruction based on the next card reading instruction.

10. The method according to claim 1, characterized in that The REE environment notifies the secure process control application of a card discovery status of the NFC controller, including: The REE environment receives an interrupt instruction sent by the NFC controller; The REE environment notifies the security process control application to obtain the card discovery status from the NFC controller according to the interrupt instruction.

11. A near field communication method, characterized in that: Applied to an NFC host configured with a REE environment and a TEE environment, wherein a secure process control application and a contactless application are installed in the TEE environment, the method comprises: The REE environment notifies the secure process control application of the card discovery status of the NFC controller; The security process control application obtains the card reading instruction of the NFC controller according to the card discovery status to the contactless application, so that the contactless application generates a card reading response according to the card reading instruction; The security process control application forwards the card reading response of the contactless application to the NFC controller.

12. The method according to claim 11, wherein: The REE environment notifies the security process control application of the card discovery status of the NFC controller, including: When the REE environment receives the card discovery status sent by the NFC controller, it sends a third notification to the security process control application, where the third notification instructs the security process control application to obtain a card reading instruction of the NFC controller from the NFC controller.

13. The method according to claim 12, wherein: The method further comprises: Before the NFC controller sends the card discovery status, the NFC controller encapsulates the card reading instruction of the NFC controller into an event message based on the HCI interface via the HCI interface between the security process control application and the NFC controller. Accordingly, the third notification instructs the secure process control application to obtain an event message based on the HCI interface from the NFC controller.

14. A near field communication configuration method, characterized in that: Applied to an NFC host configured with a REE environment and a TEE environment, wherein a secure process control application and a contactless application are installed in the TEE environment, the method comprises: The secure process control application receives an RF parameter request from the REE environment; The secure process control application forwards the RF parameter request to the contactless application; The secure process control application receives the RF parameters returned by the contactless application in response to the RF parameter request; The secure process control application configures the NFC controller based on the RF parameters.

15. The method according to claim 14, characterized in that The secure process control application configures the NFC controller based on the RF parameters, including: The secure process control application returns the RF parameters to the REE environment; The REE environment configures the NFC controller according to an NCI interface between the REE environment and the NFC controller.

16. The method according to claim 14, characterized in that The secure process control application configures the NFC controller based on the RF parameters, including: The secure process control application generates RF configuration instructions; The security process control application sends the RF configuration instruction to the NFC controller, so that the NFC controller enters the RF parameter configuration state; The security process control application performs configuration on the NFC controller in an RF parameter configuration state based on the RF parameters.

17. An NFC host, characterized in that: include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method according to any one of claims 1-16.

18. An electronic device, characterized in that: include: NFC controller; The NFC host according to claim 17, wherein the NFC host is communicatively connected to the NFC controller.