CN106663017B - Method, terminal, data routing method and device for realizing host card simulation - Google Patents
Method, terminal, data routing method and device for realizing host card simulation Download PDFInfo
- Publication number
- CN106663017B CN106663017B CN201580043877.1A CN201580043877A CN106663017B CN 106663017 B CN106663017 B CN 106663017B CN 201580043877 A CN201580043877 A CN 201580043877A CN 106663017 B CN106663017 B CN 106663017B
- Authority
- CN
- China
- Prior art keywords
- external data
- identifier
- tee
- hce application
- terminal
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45508—Runtime interpretation or emulation, e g. emulator loops, bytecode interpretation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W88/00—Devices specially adapted for wireless communication networks, e.g. terminals, base stations or access point devices
- H04W88/02—Terminal devices
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04B—TRANSMISSION
- H04B5/00—Near-field transmission systems, e.g. inductive or capacitive transmission systems
- H04B5/20—Near-field transmission systems, e.g. inductive or capacitive transmission systems characterised by the transmission technique; characterised by the transmission medium
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Stored Programmes (AREA)
- Mobile Radio Communication Systems (AREA)
- Telephonic Communication Services (AREA)
Abstract
本发明实施例提供一种实现主机卡模拟的方法及装置,本发明中终端根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中,终端环境包括可信执行环境TEE和富执行环境REE;终端解析所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识,第一标识用于在终端中唯一标识所述HCE应用,第二标识用于标识读卡设备与所述HCE应用之间的消息流;终端将所述HCE应用的路由信息注册到TEE中,路由信息包括第一标识、至少一个第二标识以及HCE应用安装的终端环境。通过本发明能够在终端上实现支持TEE和REE两种不同安全级别的HCE应用。
Embodiments of the present invention provide a method and device for implementing host card emulation. In the present invention, a terminal installs the HCE application in a terminal environment corresponding to the type of the HCE application according to the type of the HCE application. Information execution environment TEE and rich execution environment REE; the terminal parses the first identifier of the HCE application and at least one second identifier included in the HCE application, the first identifier is used to uniquely identify the HCE application in the terminal, and the first identifier is used to uniquely identify the HCE application in the terminal. The second identifier is used to identify the message flow between the card reader device and the HCE application; the terminal registers the routing information of the HCE application into the TEE, and the routing information includes the first identifier, at least one second identifier, and the information installed by the HCE application. terminal environment. By means of the present invention, HCE applications supporting two different security levels of TEE and REE can be implemented on the terminal.
Description
技术领域technical field
本发明涉及通信技术领域,尤其涉及一种实现主机卡模拟的方法、终端、数据路由方法及装置。The present invention relates to the field of communication technologies, and in particular, to a method, a terminal, and a data routing method and device for realizing host card simulation.
背景技术Background technique
卡模拟(Card Emulation,CE)功能,是指利用支持近场通信(Near FieldCommunication,NFC)功能并且具有安全单元(Secure Element,SE)的终端,模拟非接触式芯片卡(Contactless IC Card)。卡模拟应用安装到终端的安全单元中,并在安全单元中运行。安全单元一般允许安装多个卡模拟应用,这使得用户携带一部终端就相当于携带了多张实体卡片,为用户带来了极大便利。The card emulation (Card Emulation, CE) function refers to simulating a contactless IC Card (Contactless IC Card) by using a terminal that supports a Near Field Communication (Near Field Communication, NFC) function and has a Secure Element (Secure Element, SE). The card emulation application is installed into the security cell of the terminal and runs in the security cell. The security unit generally allows to install multiple card simulation applications, which makes the user carry a terminal equivalent to carrying multiple physical cards, which brings great convenience to the user.
主机卡模拟(Host-based Card Emulation或Host Card Emulation,HCE)是指卡模拟应用无需安装到安全单元中,而是像普通的应用一样直接安装到终端的操作系统中,并运行在终端主机(Device Host,或者称之为设备主机)上。HCE广泛应用于近场通信(NearField Communication,NFC)中。Host card emulation (Host-based Card Emulation or Host Card Emulation, HCE) means that the card emulation application does not need to be installed in the security unit, but is directly installed into the operating system of the terminal like a common application, and runs on the terminal host ( Device Host, or called the device host). HCE is widely used in near field communication (Near Field Communication, NFC).
目前,HCE应用程序一般运行在终端的富执行环境(Rich ExecutionEnvironment,REE)中,通过终端的NFC接口与POS机或者读卡器等读卡设备进行通信。REE是一种安全级别较低的运行环境,即任何来源的应用程序经用户许可都可安装到终端的REE中,并且对于REE中存储的数据的保护也不足以抵御各种恶意软件的威胁,故当HCE应用程序安装和运行在REE中时,其相关的用户账户等机密数据的安全级别较低,容易被窃取。At present, HCE applications generally run in a rich execution environment (Rich Execution Environment, REE) of a terminal, and communicate with a card reading device such as a POS machine or a card reader through an NFC interface of the terminal. REE is an operating environment with a low level of security, that is, applications from any source can be installed into the REE of the terminal with the permission of the user, and the protection of the data stored in the REE is not enough to resist various malware threats. Therefore, when the HCE application is installed and run in the REE, the security level of its related confidential data such as user accounts is low, and it is easy to be stolen.
然而,目前常常需要利用HCE机制来实现一些安全性能要求较高的应用,诸如银行发布的HCE支付应用等,如果将这些安全性能要求较高的HCE应用安装到REE中,HCE应用关联的账户数据很容易被恶意程序的窃取。因此REE中的HCE程序的关联数据处于比较危险的状态。However, it is often necessary to use the HCE mechanism to implement some applications with high security performance requirements, such as HCE payment applications issued by banks, etc. If these HCE applications with high security performance requirements are installed into REE, the account data associated with the HCE application It is easy to be stolen by malicious programs. Therefore, the associated data of the HCE program in the REE is in a dangerous state.
发明内容SUMMARY OF THE INVENTION
本发明实施例提供一种实现主机卡模拟的方法、终端、数据路由方法及装置,以在终端上实现不同安全级别的HCE功能。Embodiments of the present invention provide a method, terminal, and data routing method and device for implementing host card simulation, so as to implement HCE functions of different security levels on the terminal.
第一方面,提供一种实现主机卡模拟HCE的方法,包括:In a first aspect, a method for implementing a host card to simulate HCE is provided, including:
终端根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中,其中,所述终端环境包括可信执行环境TEE和富执行环境REE;The terminal installs the HCE application into a terminal environment corresponding to the type of the HCE application according to the type of the HCE application, wherein the terminal environment includes a trusted execution environment TEE and a rich execution environment REE;
所述终端解析所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识,所述第一标识用于在所述终端中唯一标识所述HCE应用,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流;The terminal parses the first identifier of the HCE application and at least one second identifier included in the HCE application, where the first identifier is used to uniquely identify the HCE application in the terminal, and the second identifier Used to identify the message flow between the card reader device and the HCE application;
所述终端将所述HCE应用的路由信息注册到TEE中,其中,所述路由信息包括所述第一标识、所述至少一个第二标识以及所述HCE应用安装的所述终端环境。The terminal registers the routing information of the HCE application in the TEE, where the routing information includes the first identifier, the at least one second identifier, and the terminal environment in which the HCE application is installed.
结合第一方面,在第一种实现方式中,所述方法还包括:With reference to the first aspect, in a first implementation manner, the method further includes:
所述终端将获取的外部数据发送至TEE中的路由管理模块;The terminal sends the acquired external data to the routing management module in the TEE;
所述路由管理模块将所述外部数据发送至与所述外部数据对应的HCE应用。The route management module sends the external data to the HCE application corresponding to the external data.
结合第一方面的第一种实现方式,在第二种实现方式中,所述终端将获取的外部数据发送至TEE中的路由管理模块,具体包括:In combination with the first implementation manner of the first aspect, in the second implementation manner, the terminal sends the acquired external data to the routing management module in the TEE, specifically including:
所述终端通过TEE中的近场通信控制器NFCC或REE中的NFCC获取外部数据;The terminal obtains external data through the near field communication controller NFCC in the TEE or the NFCC in the REE;
由TEE中的所述NFCC或REE中的所述NFCC,将路由目标是设备主机的所述外部数据发送至TEE中的路由管理模块。The external data whose routing target is the device host is sent to the routing management module in the TEE by the NFCC in the TEE or the NFCC in the REE.
结合第一方面的第一种实现方式或者第一方面的第二种实现方式,在第三种实现方式中,所述路由管理模块将所述外部数据发送至所述外部数据对应的HCE应用,具体包括:With reference to the first implementation manner of the first aspect or the second implementation manner of the first aspect, in a third implementation manner, the routing management module sends the external data to the HCE application corresponding to the external data, Specifically include:
所述路由管理模块获取所述外部数据中的第二标识;The routing management module obtains the second identifier in the external data;
所述路由管理模块根据所述注册到TEE中的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境;The routing management module determines, according to the routing information registered in the TEE, the first identification of the external data corresponding to the second identification in the external data, and the HCE application installed corresponding to the first identification of the external data. terminal environment;
所述路由管理模块根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。The route management module sends the external data to the HCE application corresponding to the first identifier of the external data according to the determined terminal environment.
结合第一方面的第三种实现方式,在第四种实现方式中,根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用,包括:In combination with the third implementation manner of the first aspect, in a fourth implementation manner, according to the determined terminal environment, sending the external data to the HCE application corresponding to the first identifier of the external data includes:
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
第二方面,提供一种数据路由方法,包括:In a second aspect, a data routing method is provided, including:
终端将获取的外部数据发送至TEE中的路由管理模块;The terminal sends the acquired external data to the routing management module in the TEE;
所述路由管理模块将所述外部数据发送至与所述外部数据对应的HCE应用。The route management module sends the external data to the HCE application corresponding to the external data.
结合第二方面,在第一种实现方式中,所述终端将获取的外部数据发送至TEE中的路由管理模块,具体包括:With reference to the second aspect, in the first implementation manner, the terminal sends the acquired external data to the routing management module in the TEE, specifically including:
所述终端通过TEE中的NFCC驱动或者REE中的NFCC驱动获取所述外部数据,并将路由目标是设备主机的所述外部数据发送至TEE中的路由管理模块。The terminal obtains the external data through the NFCC driver in the TEE or the NFCC driver in the REE, and sends the external data whose routing target is the device host to the routing management module in the TEE.
结合第二方面或者第二方面的第一种实现方式,在第二种实现方式中,所述路由管理模块将所述外部数据发送至与所述外部数据对应的HCE应用,包括:With reference to the second aspect or the first implementation manner of the second aspect, in the second implementation manner, the routing management module sends the external data to the HCE application corresponding to the external data, including:
所述路由管理模块获取所述外部数据中的第二标识,所述第二标识用于标识读卡设备与一个HCE应用之间的消息流;The routing management module acquires the second identifier in the external data, and the second identifier is used to identify the message flow between the card reader device and an HCE application;
根据所述注册到TEE中的HCE应用的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境,所述第一标识用于在终端中唯一标识一个HCE应用;Determine, according to the routing information of the HCE application registered in the TEE, the first identifier of external data corresponding to the second identifier in the external data, and the terminal environment in which the HCE application corresponding to the first identifier of external data is installed , the first identifier is used to uniquely identify an HCE application in the terminal;
根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的所述HCE应用。According to the determined terminal environment, the external data is sent to the HCE application corresponding to the first identifier of the external data.
结合第二方面的第二种实现方式,在第三种实现方式中,所述根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的所述HCE应用,包括:With reference to the second implementation manner of the second aspect, in a third implementation manner, the external data is sent to the HCE application corresponding to the first identifier of the external data according to the determined terminal environment ,include:
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的所述HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的所述HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
第三方面,提供一种实现主机卡模拟HCE的终端,包括:In a third aspect, a terminal for realizing HCE simulation by a host card is provided, including:
安装单元,用于根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中,其中,所述终端环境包括可信执行环境TEE和富执行环境REE;an installation unit, configured to install the HCE application into a terminal environment corresponding to the type of the HCE application according to the type of the HCE application, wherein the terminal environment includes a trusted execution environment TEE and a rich execution environment REE;
解析单元,用于解析所述安装单元安装的所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识,所述第一标识用于在所述终端中唯一标识所述HCE应用,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流;a parsing unit, configured to parse the first identifier of the HCE application installed by the installation unit and at least one second identifier included in the HCE application, where the first identifier is used to uniquely identify the terminal HCE application, the second identifier is used to identify the message flow between the card reader device and the HCE application;
注册单元,用于将所述HCE应用的路由信息注册到TEE中,其中,所述路由信息包括所述解析单元解析出的所述第一标识、所述至少一个第二标识以及所述HCE应用安装的所述终端环境。a registration unit, configured to register the routing information of the HCE application into the TEE, where the routing information includes the first identifier, the at least one second identifier and the HCE application parsed by the parsing unit Installed the terminal environment.
结合第三方面,在第一种实现方式中,所述终端还包括第一路由单元和第二路由单元,其中,With reference to the third aspect, in a first implementation manner, the terminal further includes a first routing unit and a second routing unit, wherein,
所述第一路由单元,用于将获取的外部数据发送至TEE中的第二路由单元;the first routing unit, configured to send the acquired external data to the second routing unit in the TEE;
所述第二路由单元,用于将所述外部数据发送至与所述外部数据对应的安装单元安装的HCE应用。The second routing unit is configured to send the external data to the HCE application installed by the installation unit corresponding to the external data.
结合第三方面的第一种实现方式,在第二种实现方式中,所述第一路由单元,具体用于按如下方式将获取的外部数据发送至TEE种的第二路由单元:In combination with the first implementation manner of the third aspect, in the second implementation manner, the first routing unit is specifically configured to send the acquired external data to the second routing unit of the TEE type in the following manner:
通过TEE中的近场通信控制器NFCC或REE中的NFCC获取外部数据;Obtain external data through the near field communication controller NFCC in TEE or NFCC in REE;
由TEE中的所述NFCC或REE中的所述NFCC将路由目标是设备主机的所述外部数据发送至TEE中的第二路由单元。The external data whose routing target is a device host is sent by the NFCC in the TEE or the NFCC in the REE to a second routing unit in the TEE.
结合第三方面的第一种实现方式,或者第三方面的的第二种实现方式,在第三种实现方式中,所述第二路由单元,具体用于按如下方式将所述外部数据发送至所述外部数据对应的HCE应用:With reference to the first implementation manner of the third aspect, or the second implementation manner of the third aspect, in the third implementation manner, the second routing unit is specifically configured to send the external data in the following manner To the HCE application corresponding to the external data:
获取所述外部数据中的第二标识;obtaining the second identifier in the external data;
根据注册到TEE中的信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的所述HCE应用安装的终端环境;According to the information registered in the TEE, determine the first identification of external data corresponding to the second identification in the external data, and the terminal environment in which the HCE application corresponding to the first identification of external data is installed;
根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。According to the determined terminal environment, the external data is sent to the HCE application corresponding to the first identifier of the external data.
结合第三方面的第三种实现方式,在第四种实现方式中,所述第二路由单元,具体用于按如下方式根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用:With reference to the third implementation manner of the third aspect, in a fourth implementation manner, the second routing unit is specifically configured to send the external data to the communication server according to the determined terminal environment in the following manner. The HCE application corresponding to the first identifier of the external data:
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
第四方面,提供一种数据路由装置,包括:In a fourth aspect, a data routing device is provided, comprising:
获取单元,用于获取外部数据;The acquisition unit is used to acquire external data;
第一路由单元,用于将所述获取单元获取的外部数据发送至TEE中的第二路由单元;a first routing unit, configured to send the external data acquired by the acquiring unit to a second routing unit in the TEE;
第二路由单元,用于将所述外部数据发送至与所述外部数据对应的HCE应用。The second routing unit is configured to send the external data to the HCE application corresponding to the external data.
结合第四方面,在第一种实现方式中,所述第一路由单元,具体用于按如下方式将获取的外部数据发送至TEE中的第二路由单元:With reference to the fourth aspect, in the first implementation manner, the first routing unit is specifically configured to send the acquired external data to the second routing unit in the TEE in the following manner:
通过TEE中的NFCC驱动或者REE中的NFCC驱动获取所述外部数据,并将路由目标是设备主机的所述外部数据发送至TEE中的第二路由单元。The external data is acquired through the NFCC driver in the TEE or the NFCC driver in the REE, and the external data whose routing target is the device host is sent to the second routing unit in the TEE.
结合第四方面的第一种实现方式,在第二种实现方式中,所述第二路由单元,具体用于按如下方式,将所述外部数据发送至与所述外部数据对应的HCE应用:In combination with the first implementation manner of the fourth aspect, in the second implementation manner, the second routing unit is specifically configured to send the external data to the HCE application corresponding to the external data in the following manner:
获取所述外部数据中的第二标识,所述第二标识用于标识读卡设备与一个HCE应用之间的消息流;Obtain the second identification in the external data, and the second identification is used to identify the message flow between the card reader device and an HCE application;
根据注册到TEE中的所述HCE应用的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的所述HCE应用安装的终端环境,所述第一标识用于在终端中唯一标识一个HCE应用;Determine, according to the routing information of the HCE application registered in the TEE, the first identifier of external data corresponding to the second identifier in the external data, and the first identifier of the external data corresponding to the first identifier of the external data installed by the HCE application terminal environment, where the first identifier is used to uniquely identify an HCE application in the terminal;
根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。According to the determined terminal environment, the external data is sent to the HCE application corresponding to the first identifier of the external data.
结合第四方面的第二种实现方式,在第三种实现方式中,所述第二路由单元,具体用于按如下方式,根据所述确定的终端环境,将所述外部数据发送至与所述第一标识对应的HCE应用:With reference to the second implementation manner of the fourth aspect, in the third implementation manner, the second routing unit is specifically configured to send the external data to the destination according to the determined terminal environment in the following manner. Describe the HCE application corresponding to the first identifier:
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
第五方面,提供一种实现主机卡模拟HCE的终端,包括存储器、外设、通信单元和处理器,其中:In a fifth aspect, a terminal for realizing HCE simulation by a host card is provided, including a memory, a peripheral device, a communication unit and a processor, wherein:
所述存储器,包括运行于富执行环境REE的公共随机存取存储器RAM和公共只读存储器ROM,以及运行于可信执行环境TEE的可信RAM和可信ROM,用于存储指令和数据;Described memory, comprises the public random access memory RAM that runs in rich execution environment REE and public read-only memory ROM, and runs in trusted execution environment TEE trusted RAM and trusted ROM, are used for storing instruction and data;
所述外设,包括所述REE中的公共外设和所述TEE中的可信外设;the peripherals, including the public peripherals in the REE and the trusted peripherals in the TEE;
所述通信单元,位于所述REE中;the communication unit, located in the REE;
所述处理器,用于调用存储在所述公共RAM、公共ROM、可信RAM以及可信ROM内的指令以及数据,通过所述可信外设、所述公共外设以及所述通信单元,实现以下功能:The processor is configured to call the instructions and data stored in the public RAM, the public ROM, the trusted RAM and the trusted ROM, and through the trusted peripherals, the public peripherals and the communication unit, Implement the following functions:
根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中,其中,所述终端环境包括TEE和REE;解析所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识,所述第一标识用于在所述终端中唯一标识所述HCE应用,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流;并用于将所述HCE应用的路由信息注册到TEE中,其中,所述路由信息包括所述第一标识、所述至少一个第二标识以及所述HCE应用安装的所述终端环境。Install the HCE application into a terminal environment corresponding to the type of the HCE application according to the type of the HCE application, wherein the terminal environment includes TEE and REE; parse the first identifier of the HCE application and the HCE At least one second identifier included in the application, the first identifier is used to uniquely identify the HCE application in the terminal, and the second identifier is used to identify the message flow between the card reader device and the HCE application and is used to register the routing information of the HCE application in the TEE, wherein the routing information includes the first identifier, the at least one second identifier, and the terminal environment where the HCE application is installed.
结合第五方面,在第一种实现方式中,所述处理器,还用于:With reference to the fifth aspect, in the first implementation manner, the processor is further configured to:
将获取的外部数据发送至TEE中的路由管理模块,控制所述路由管理模块将所述外部数据发送至与所述外部数据对应的HCE应用。The acquired external data is sent to the routing management module in the TEE, and the routing management module is controlled to send the external data to the HCE application corresponding to the external data.
结合第五方面的第一种实现方式,在第二种实现方式中,所述处理器,具体用于采用如下方式将获取的外部数据发送至TEE中的路由管理模块:In combination with the first implementation manner of the fifth aspect, in the second implementation manner, the processor is specifically configured to send the acquired external data to the routing management module in the TEE in the following manner:
通过TEE中的近场通信控制器NFCC或REE中的NFCC获取外部数据;Obtain external data through the near field communication controller NFCC in TEE or NFCC in REE;
由TEE中的所述NFCC或REE中的所述NFCC将路由目标是设备主机的所述外部数据发送至TEE中的路由管理模块。The external data whose routing target is a device host is sent by the NFCC in the TEE or the NFCC in the REE to a routing management module in the TEE.
结合第五方面的第一种实现方式或者第二种实现方式,在第三种实现方式中,所述处理器,具体用于按如下方式控制所述路由管理模块将所述外部数据发送至所述外部数据对应的HCE应用:With reference to the first implementation manner or the second implementation manner of the fifth aspect, in a third implementation manner, the processor is specifically configured to control the routing management module to send the external data to the The HCE application corresponding to the external data mentioned above:
控制所述路由管理模块通过所述通信单元以及所述外设获取所述外部数据中的第二标识,并根据所述注册到TEE中的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境,并控制所述路由管理模块根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。Control the routing management module to obtain the second identifier in the external data through the communication unit and the peripheral device, and determine the second identifier in the external data according to the routing information registered in the TEE The corresponding external data first identification and the terminal environment in which the HCE application corresponding to the external data first identification is installed, and control the routing management module to send the external data to the terminal environment according to the determined terminal environment. The HCE application corresponding to the first identifier of the external data.
结合第五方面的第三种实现方式,在第四种实现方式中,所述处理器,具体用于按如下方式控制所述路由管理模块根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用:With reference to the third implementation manner of the fifth aspect, in the fourth implementation manner, the processor is specifically configured to control the routing management module to send the external data according to the determined terminal environment in the following manner To the HCE application corresponding to the first identifier of the external data:
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。本发明实施例提供的实现主机卡模拟的方法、终端、数据路由方法及装置,通过不同的应用类型标签,区分HCE应用为TA或CA,进而将TA安装到TEE中,将CA安装到REE中,实现了基于TEE和基于REE两种不同安全级别的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory. The method, terminal, and data routing method and device for implementing host card simulation provided by the embodiments of the present invention distinguish HCE applications as TA or CA through different application type labels, and then install TA into TEE and CA into REE , HCE applications with two different security levels based on TEE and REE are realized.
附图说明Description of drawings
图1A至图1B为本发明实施例提供的主机卡模拟方法应用的终端系统架构;1A to 1B are terminal system architectures to which the host card emulation method provided by an embodiment of the present invention is applied;
图2为本发明实施例提供的主机卡模拟方法实现流程图;FIG. 2 is a flowchart for implementing a host card simulation method provided by an embodiment of the present invention;
图3为本发明实施例提供的将HCE应用安装到对应的环境实现流程图;Fig. 3 is the implementation flow chart of installing the HCE application to the corresponding environment provided by the embodiment of the present invention;
图4为本发明实施例提供的另一主机卡模拟方法实现流程图;4 is a flowchart for implementing another host card simulation method provided by an embodiment of the present invention;
图5为本发明实施例提供的将获取的外部数据发送至TEE中的路由管理模块的流程图;5 is a flowchart of sending acquired external data to a routing management module in a TEE provided by an embodiment of the present invention;
图6为本发明实施例提供的路由信息保存过程示意图;6 is a schematic diagram of a routing information storage process provided by an embodiment of the present invention;
图7为本发明实施例提供的根据应用保存的路由信息进行外部数据路由的过程示意图;7 is a schematic diagram of a process of performing external data routing according to routing information saved by an application according to an embodiment of the present invention;
图8为本发明实施例设置的路由表示意图;8 is a schematic diagram of a routing table set up in an embodiment of the present invention;
图9为本发明实施例提供的在TEE中执行路由过程示意图;FIG. 9 is a schematic diagram of a routing process in a TEE provided by an embodiment of the present invention;
图10为本发明实施例提供的将外部数据转发给TA过程示意图;10 is a schematic diagram of a process of forwarding external data to a TA provided by an embodiment of the present invention;
图11A至图11B为本发明实施例提供的将外部数据转发给CA过程示意图;11A to 11B are schematic diagrams of a process of forwarding external data to a CA according to an embodiment of the present invention;
图12A至图12B为本发明实施例提供的实现主机卡模拟的终端构成示意图;12A to 12B are schematic diagrams of the configuration of a terminal for implementing host card emulation according to an embodiment of the present invention;
图13为本发明实施例提供的实现主机卡模拟的终端另一构成示意图;13 is a schematic diagram of another configuration of a terminal for implementing host card emulation according to an embodiment of the present invention;
图14为本发明实施例提供的数据路由装置的构成示意图。FIG. 14 is a schematic structural diagram of a data routing apparatus according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚地描述。The technical solutions in the embodiments of the present invention will be clearly described below with reference to the accompanying drawings in the embodiments of the present invention.
可信执行环境(Trusted Execution Environment,TEE)与REE,是共同存在于终端中的两种程序运行环境,TEE和REE可以称为终端环境,其各自包括存储器、处理器等硬件资源和操作系统(Operating System,OS)、框架(Framework)等软件。REE没有严格限定应用的来源,如果用户许可,REE可接受任何来源的软件安装。然而,TEE则不同,TEE内的存储为安全存储,其会受到TEE发行者(如,终端厂商或运营商)的管理,具有一定的限制访问条件;终端收到访问TEE存储的请求时,例如读写安全存储(向TEE中安装程序属于写安全存储操作),需验证是否符合安全访问规则,在符合安全访问规则的前提下,才可访问相应的存储内容。因为TEE的上述特性,恶意程序无法访问安装到TEE中的程序及其数据;安装到TEE环境中的程序,互相之间也无法越界访问不属于自己的数据,因此实现了较高的安全级别。Trusted Execution Environment (TEE) and REE are two program running environments that coexist in the terminal. TEE and REE can be called terminal environments, each including hardware resources such as memory, processor, and operating system ( Operating System, OS), framework (Framework) and other software. REE does not strictly limit the source of the application, if the user allows, REE can accept software installation from any source. However, TEE is different. The storage in the TEE is a secure storage, which is managed by the TEE issuer (eg, terminal manufacturer or operator) and has certain restricted access conditions; when the terminal receives a request to access the TEE storage, for example To read and write secure storage (installing a program into a TEE is a write secure storage operation), it is necessary to verify whether it complies with the security access rules. Only when the security access rules are met can the corresponding storage content be accessed. Because of the above characteristics of TEE, malicious programs cannot access programs and their data installed in the TEE; programs installed in the TEE environment cannot access data that does not belong to each other across the border, so a higher level of security is achieved.
可信应用(Trusted APPlication,TA)是指运行于TEE中的应用,能够为REE中的客户端应用或者TEE环境中的其他可信应用提供安全相关功能,如密码服务、签名服务和摘要服务等。相应的,客户端应用(Client APPlication,CA)是指运行在REE中,可以通过TEE客户端应用编程接口或共享内存机制与TEE中的某个可信应用TA进行通信并调用TA提供的服务的应用。A Trusted Application (TA) refers to an application running in a TEE that can provide security-related functions for client applications in the REE or other trusted applications in the TEE environment, such as cryptographic services, signature services, and digest services. . Correspondingly, the client application (Client Application, CA) refers to the application running in the REE, which can communicate with a trusted application TA in the TEE through the TEE client application programming interface or the shared memory mechanism and call the services provided by the TA. application.
为了便于软件开发商(Soft Processor,SP)根据自己的业务需求选择不同安全级别的HCE,本发明实施例提供一种主机卡模拟实现方法,以在包括TEE的终端上实现不同安全级别HCE应用的安装,满足不同业务需求的不同安全级别需求。例如,对安全性能要求较高的金融卡、支付卡应用等高安全级别的业务需求,可实现为TA,并安装到TEE中;类似于超市会员卡,门禁卡等低安全级别的业务需求,可实现为CA,并安装在REE中。In order to facilitate software developers (Soft Processor, SP) to select HCEs with different security levels according to their own business requirements, an embodiment of the present invention provides a host card simulation implementation method, so as to realize HCE applications of different security levels on a terminal including a TEE. Installation to meet different security level requirements for different business needs. For example, high-security business requirements such as financial cards and payment card applications that require high security performance can be implemented as TA and installed in TEE; similar to supermarket membership cards, access control cards and other low-security business requirements, Can be implemented as a CA and installed in the REE.
本发明实施例提供的主机卡模拟方法,依据HCE应用业务需求要求安装的终端环境是TEE还是REE,将HCE应用安装到对应的终端环境中。The host card simulation method provided by the embodiment of the present invention installs the HCE application in the corresponding terminal environment according to whether the installed terminal environment is TEE or REE according to HCE application service requirements.
本发明实施例中可在HCE应用的资源文件中定义用于标识HCE应用安装终端环境的应用类型标签,通过不同的应用类型标签区分HCE应用应该安装的终端环境是TEE还是REE,并将HCE应用安装到TEE或REE中,以在终端上实现支持TEE和REE两种不同安全级别的HCE应用。In the embodiment of the present invention, an application type label for identifying the terminal environment in which the HCE application is installed can be defined in the resource file of the HCE application, and the terminal environment to which the HCE application should be installed is TEE or REE through different application type labels, and the HCE application Installed into TEE or REE to implement HCE applications that support two different security levels of TEE and REE on the terminal.
本发明实施例中为了实现在终端上支持TEE和REE两种不同安全级别的HCE应用,即将高安全级别的HCE应用安装到TEE中,将较低安全级别的HCE应用安装到REE中,可应用图1A或图1B所示的终端系统架构,在TEE中实现不同安全级别的HCE应用的路由功能。图1A中,NFC控制器(NFC Controller,NFCC)收到数据后,通过REE操作系统内核中的NFCC驱动(NFCC Driver)和NFCC路由模块发送给上层应用,当支持TEE和REE两种不同安全级别的HCE应用时,NFCC driver将收到的数据发送给TEE环境中的可信NFC服务框架(NFC ServiceFramework),并由TEE环境中的NFC Service Framework转发给路由管理模块(RoutingManagement Module,本发明中也记为Route-TA),TEE中的路由管理模块(Route-TA)将数据分发(即路由)给TEE中的TA或者REE中的CA。图1B中,NFC控制器收到数据后,通过TEE中的可信操作系统内核中的可信NFCC驱动将数据发送给TEE中的路由管理模块,由TEE中的路由管理模块将数据分发给TEE中的TA或者REE中的CA。In this embodiment of the present invention, in order to support HCE applications with two different security levels, TEE and REE, on the terminal, that is, installing HCE applications with a high security level into the TEE, and installing HCE applications with a lower security level in the REE, the applicable The terminal system architecture shown in FIG. 1A or FIG. 1B implements the routing function of HCE applications of different security levels in the TEE. In Figure 1A, after the NFC controller (NFC Controller, NFCC) receives the data, it sends it to the upper-layer application through the NFCC driver (NFCC Driver) and the NFCC routing module in the REE operating system kernel. When two different security levels of TEE and REE are supported, When the HCE is applied in the TEE environment, the NFCC driver sends the received data to the trusted NFC service framework (NFC ServiceFramework) in the TEE environment, and is forwarded by the NFC Service Framework in the TEE environment to the Routing Management Module (Routing Management Module, also in the present invention). Denoted as Route-TA), the route management module (Route-TA) in the TEE distributes (ie routes) the data to the TA in the TEE or the CA in the REE. In Figure 1B, after receiving the data, the NFC controller sends the data to the routing management module in the TEE through the trusted NFCC driver in the trusted operating system kernel in the TEE, and the routing management module in the TEE distributes the data to the TEE TA in or CA in REE.
需要说明的是本发明实施例中NFCC,也可称之为近场通信控制器(Near FieldCommunication Controller,NFCC),NFCC是NFC论坛(NFC Forum)定义的一种逻辑实体,业界也常用NFCC表示实现了主要NFC功能的NFCC芯片。本发明中,将NFCC芯片、NFCC驱动和NFCC路由模块区分开来,以上三种硬件或软件都是NFCC逻辑实体的一部分。It should be noted that the NFCC in the embodiment of the present invention may also be called a Near Field Communication Controller (NFCC). The NFCC is a logical entity defined by the NFC Forum (NFC Forum). NFCC chip with main NFC functions. In the present invention, the NFCC chip, the NFCC driver and the NFCC routing module are distinguished, and the above three kinds of hardware or software are all part of the NFCC logical entity.
图2所示为本发明实施例提供的主机卡模拟实现方法流程图,如图2所示,包括:FIG. 2 shows a flowchart of a method for implementing a host card simulation provided by an embodiment of the present invention. As shown in FIG. 2 , the method includes:
S101:终端根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中。S101: The terminal installs the HCE application into a terminal environment corresponding to the type of the HCE application according to the type of the HCE application.
本发明实施例中安装所述HCE应用的终端环境包括TEE和REE,一个HCE应用只对应一种终端环境,即HCE应用运行的终端环境为TEE或者REE。需要说明的是,本发明实施例中安装HCE应用的终端环境称之为环境、安装环境,当然也可称之为应用运行环境等,本发明实施例不做限定。In the embodiment of the present invention, the terminal environment in which the HCE application is installed includes TEE and REE, and one HCE application corresponds to only one terminal environment, that is, the terminal environment in which the HCE application runs is TEE or REE. It should be noted that, in the embodiment of the present invention, the terminal environment in which the HCE application is installed is referred to as an environment, an installation environment, and of course, may also be referred to as an application running environment, etc., which is not limited in the embodiment of the present invention.
具体的,本发明实施例中终端根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中,可采用如图3所示的方法流程,包括:Specifically, in the embodiment of the present invention, the terminal installs the HCE application in the terminal environment corresponding to the type of the HCE application according to the type of the HCE application, and the method flow shown in FIG. 3 may be adopted, including:
S1011:获取HCE应用的资源文件。S1011: Obtain the resource file of the HCE application.
HCE应用安装包中包含有HCE应用的配置文件,终端接收到HCE应用的安装包,检查该安装包中的配置文件,并根据该配置文件中指定的资源文件名及路径,获取HCE应用的资源文件。The HCE application installation package contains the configuration file of the HCE application. The terminal receives the installation package of the HCE application, checks the configuration file in the installation package, and obtains the resources of the HCE application according to the resource file name and path specified in the configuration file. document.
S1012:根据获取的资源文件中的应用类型标签,确定所述HCE应用安装的终端环境。S1012: Determine the terminal environment in which the HCE application is installed according to the application type label in the acquired resource file.
本发明实施例中通过不同的应用类型标签,区分HCE应用安装的终端环境是TEE还是REE。本发明实施例中可通过资源文件中的REE主机卡模拟程序(<host-apdu-service/>)标签标识此HCE应用是一个CA应用,待安装的环境为REE;通过资源文件中的TEE主机卡模拟程序(<TEE-apdu-service/>)标签标识此HCE应用是一个TA,待安装的环境为TEE。故,若获取的资源文件中的应用类型标签为<host-apdu-service/>,则确定待安装所述HCE应用的终端环境为REE,即该应用为CA。若获取的资源文件中的应用类型标签为<TEE-apdu-service/>,则确定待安装所述HCE应用的终端环境为TEE,即该应用为TA。In this embodiment of the present invention, different application type labels are used to distinguish whether the terminal environment in which the HCE application is installed is TEE or REE. In this embodiment of the present invention, the REE host card emulation program (<host-apdu-service/>) tag in the resource file can be used to identify that the HCE application is a CA application, and the environment to be installed is REE; through the TEE host in the resource file The card emulation program (<TEE-apdu-service/>) tag identifies that the HCE application is a TA, and the environment to be installed is TEE. Therefore, if the application type label in the acquired resource file is <host-apdu-service/>, it is determined that the terminal environment in which the HCE application is to be installed is REE, that is, the application is CA. If the application type label in the acquired resource file is <TEE-apdu-service/>, it is determined that the terminal environment in which the HCE application is to be installed is TEE, that is, the application is TA.
S1013:将所述HCE应用,安装到确定的所述终端环境中。S1013: Install the HCE application into the determined terminal environment.
本发明实施例中HCE应用安装的终端环境为REE或者TEE,若确定所述HCE应用安装的终端环境为TEE,即该应用为TA,则将所述TA安装到TEE中,若确定所述HCE应用安装的终端环境为REE,即该应用为CA,则将所述CA安装到REE中。In the embodiment of the present invention, the terminal environment in which the HCE application is installed is REE or TEE. If it is determined that the terminal environment in which the HCE application is installed is TEE, that is, the application is a TA, the TA is installed in the TEE. If it is determined that the HCE application is installed in the TEE If the terminal environment in which the application is installed is REE, that is, the application is a CA, the CA is installed into the REE.
S102:终端解析所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识。S102: The terminal parses the first identifier of the HCE application and at least one second identifier included in the HCE application.
每一HCE应用对应一个应用标识(APP ID),一般而言,CA可以使用应用的证书作为应用标识,TA可以使用通用唯一识别符(Universally Unique Identifier,UUID)作为应用标识。每一个HCE应用能处理读卡设备与HCE之间的若干个消息流,上述消息流由读卡设备发送一个SELECT AID命令开始,HCE应用收到路由管理模块路由给它的SELECT AID后,应以APDU命令应答,此后读卡设备发送其他的数据交换命令,HCE应用需要应答,直到终端再次收到一个SELECT AID命令(一般来说,这个SELECT AID命令中的AID,与上一条SELECT AID命令中的AID不同),则当前的消息流结束,一个新的消息流开始,具体由哪个HCE应用处理消息流,由路由管理模块根据新的SELECTAID命令中的AID来确定。在单次使用终端进行的刷卡交易中,终端也可能会只收到一条SELECT AID命令,命令中的AID由用户选中参与交易的支付卡来确定,此时从收到SELECT AID命令至交易结束,读卡设备与终端之间的交互也可认为是一个消息流。综上,消息流由卡应用标识(APPlication IDentifier,AID)进行标识,AID是ISO/IEC 7816-5定义的用于标识智能卡内安装的卡应用(APPlet)的标识,此标识也用于标识HCE应用可以处理的消息流或称之为HCE应用包含的卡应用,一个HCE应用可以实现一个或多个AID的处理逻辑,每一个AID处理逻辑对应一个卡应用或者说对应一段读卡设备与HCE应用之间的消息流。本发明实施例为描述方便,将标识HCE应用的应用标识称之为第一标识,该第一标识用于唯一标识一个HCE应用。将AID称之为第二标识,所述第二标识用于标识读卡设备与HCE应用之间的消息流。Each HCE application corresponds to an application identifier (APP ID). Generally speaking, the CA can use the certificate of the application as the application identifier, and the TA can use the Universally Unique Identifier (UUID) as the application identifier. Each HCE application can process several message flows between the card reader and the HCE. The above message flow starts when the card reader sends a SELECT AID command. After the HCE application receives the SELECT AID routed to it by the routing management module, it should APDU command response, after that the card reader sends other data exchange commands, the HCE application needs to respond, until the terminal receives a SELECT AID command again (generally, the AID in this SELECT AID command is the same as the one in the previous SELECT AID command. AID is different), the current message flow ends, and a new message flow starts. The specific HCE application to process the message flow is determined by the routing management module according to the AID in the new SELECTAID command. In a single card swipe transaction using the terminal, the terminal may also receive only one SELECT AID command. The AID in the command is determined by the payment card selected by the user to participate in the transaction. At this time, from the receipt of the SELECT AID command to the end of the transaction, The interaction between the card reader and the terminal can also be considered as a message flow. To sum up, the message flow is identified by the application IDentifier (AID), which is the identification defined by ISO/IEC 7816-5 to identify the card application (APPlet) installed in the smart card, and this identification is also used to identify the HCE The message flow that the application can process is called the card application contained in the HCE application. An HCE application can implement one or more AID processing logics. Each AID processing logic corresponds to a card application or a segment of card reader device and HCE application. message flow between. For the convenience of description in this embodiment of the present invention, an application identifier for identifying an HCE application is referred to as a first identifier, and the first identifier is used to uniquely identify an HCE application. The AID is called a second identifier, and the second identifier is used to identify the message flow between the card reader device and the HCE application.
本发明实施例中所述第一标识用于在终端中唯一标识所述HCE应用,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流。In the embodiment of the present invention, the first identifier is used to uniquely identify the HCE application in the terminal, and the second identifier is used to identify the message flow between the card reader device and the HCE application.
S103:终端将所述HCE应用的路由信息注册到TEE中。S103: The terminal registers the routing information of the HCE application into the TEE.
本发明实施例中终端注册到TEE中的HCE应用的路由信息包括所述第一标识、所述至少一个第二标识以及所述HCE应用安装的终端环境。In this embodiment of the present invention, the routing information of the HCE application registered by the terminal in the TEE includes the first identifier, the at least one second identifier, and the terminal environment in which the HCE application is installed.
本发明实施例中在TEE中安装TA和在REE中安装CA,都需要解析第一标识和所述HCE应用中包含的至少一个第二标识,将解析得到的所述第一标识和所述至少一个第二标识,以及所述HCE应用安装的终端环境注册到所述TEE中。In this embodiment of the present invention, when installing a TA in a TEE and installing a CA in a REE, both the first identifier and at least one second identifier included in the HCE application need to be resolved, and the first identifier obtained by parsing and the at least one second identifier A second identifier, and the terminal environment installed by the HCE application are registered in the TEE.
本发明实施例中将第一标识、第二标识以及所述HCE应用安装的终端环境注册到TEE中,是完成HCE的安装部署的必要步骤,当然所述安装部署过程还包括其他的必要步骤,本发明实施例在此不作限定。In the embodiment of the present invention, registering the first identifier, the second identifier, and the terminal environment where the HCE application is installed into the TEE is a necessary step for completing the installation and deployment of the HCE. Of course, the installation and deployment process also includes other necessary steps. The embodiments of the present invention are not limited herein.
需要说明的是,本发明实施例中涉及的注册,是指将HCE应用的第一标识,以及HCE应用相关的至少一个第二标识,以及HCE应用所在的终端环境发送给TEE中的路由管理模块,路由管理模块对接收到的信息即HCE应用相关的第二标识进行冲突检测和冲突解决处理之后(可能存在多个HCE应用处理相同的第二标识的情况,路由管理模块需要进行特殊处理,如指定多个HCE应用中的一个来处理某个第二标识),根据第一标识、第二标识、以及HCE应用安装的终端环境的对应关系,生成多条路由项,并保存到TEE路由管理模块的路由表中,后续收到外部数据时依据路由表进行路由,其中,本发明实施例中的路由信息包括第一标识、至少一个第二标识以及HCE应用安装的终端环境,由于一个HCE应用对应一个或多个第二标识,每个第二标识可以生成一条路由项,因此一个HCE应用的路由信息包括至少一条路由项。It should be noted that the registration involved in the embodiment of the present invention refers to sending the first identifier of the HCE application, at least one second identifier related to the HCE application, and the terminal environment where the HCE application is located to the routing management module in the TEE , after the routing management module performs conflict detection and conflict resolution processing on the received information, that is, the second identification related to the HCE application (there may be multiple HCE applications processing the same second identification, the routing management module needs to carry out special processing, such as Designate one of multiple HCE applications to process a certain second identifier), generate multiple routing items according to the corresponding relationship between the first identifier, the second identifier, and the terminal environment where the HCE application is installed, and save them to the TEE routing management module In the routing table, when the external data is subsequently received, the routing is performed according to the routing table, wherein the routing information in the embodiment of the present invention includes a first identifier, at least one second identifier, and the terminal environment in which the HCE application is installed. Since one HCE application corresponds to One or more second identifiers, each of which can generate a routing item, so the routing information of an HCE application includes at least one routing item.
本发明实施例中通过资源文件中的两种不同的应用类型标签,终端可以区分HCE应用的安装环境为TEE还是REE,进而终端在接收到HCE应用安装包时,可通过资源文件中的应用类型标签,确定HCE应用安装的终端环境,区分该HCE应用为TA或CA,进而将TA安装到TEE中,将CA安装到REE中,实现了基于TEE和基于REE两种不同安全级别的HCE应用。In the embodiment of the present invention, through two different application type labels in the resource file, the terminal can distinguish whether the installation environment of the HCE application is TEE or REE, and then when the terminal receives the HCE application installation package, it can pass the application type in the resource file Label, determine the terminal environment in which the HCE application is installed, distinguish the HCE application as TA or CA, and then install the TA into the TEE, and install the CA into the REE, realizing HCE applications with two different security levels based on TEE and REE.
进一步的,本发明实施例中,将安装在终端TEE和REE中的HCE应用的路由信息均注册到TEE后,还可包括如下步骤:Further, in this embodiment of the present invention, after the routing information of the HCE applications installed in the terminals TEE and REE are registered to the TEE, the following steps may be further included:
S104:终端将获取的外部数据发送至TEE中的路由管理模块。S104: The terminal sends the acquired external data to the routing management module in the TEE.
S105:所述路由管理模块将所述外部数据发送至与所述外部数据对应的HCE应用。S105: The route management module sends the external data to the HCE application corresponding to the external data.
本发明实施例中包括上述S104和S105步骤的实施流程图可参阅图4所示。Reference may be made to FIG. 4 for an implementation flowchart including steps S104 and S105 in this embodiment of the present invention.
本发明实施例中将获取的外部数据发送至TEE的路由管理模块,可采用如图5所示的数据路由方法,如图5所示,包括:In the embodiment of the present invention, the routing management module that sends the acquired external data to the TEE may adopt the data routing method shown in FIG. 5 , as shown in FIG. 5 , including:
S1041:终端通过TEE中的NFCC或者REE中的NFCC获取外部数据。S1041: The terminal acquires external data through the NFCC in the TEE or the NFCC in the REE.
终端处于卡模拟工作模式时,终端通过NFC接口,例如NFC天线,与非接触读卡设备,例如非接触POS机或者非接触读卡器,进行通信。终端使用NFCC芯片和NFCC驱动,从NFC天线获取外部数据。When the terminal is in the card simulation working mode, the terminal communicates with a contactless card reading device, such as a contactless POS machine or a contactless card reader, through an NFC interface, such as an NFC antenna. The terminal uses the NFCC chip and NFCC driver to obtain external data from the NFC antenna.
可选的,本发明实施例中可在终端的TEE中加载可信NFCC驱动,TEE环境下的可信操作系统(Trusted OS)获得NFC接口的访问控制权限,进而获取外部数据。Optionally, in the embodiment of the present invention, a trusted NFCC driver may be loaded in the TEE of the terminal, and a trusted operating system (Trusted OS) in the TEE environment obtains the access control authority of the NFC interface, and then obtains external data.
S1042:TEE中的NFCC或者REE中的NFCC将路由目标是设备主机的所述外部数据发送至TEE。S1042: The NFCC in the TEE or the NFCC in the REE sends the external data whose routing target is the device host to the TEE.
本发明实施例中,终端使用NFCC芯片和NFCC驱动,从NFC天线获取到非接触读卡器或非接触POS机等外部设备发送的外部数据后,将获得的数据发送至NFCC路由模块进行处理,NFCC路由模块为一软件实体(例如,路由模块可以实现为芯片固件),该NFCC路由模块获得外部数据中的第二标识,并根据保存在NFCC中的路由表,将需要发送至TEE中的数据转发给TEE,本发明实施例中需要发送至TEE的数据包括路由目标是设备主机的数据,设备主机(Device Host)一般是指终端的中央处理器CPU,也称之为主机中央处理器(Host CentralProcessing Unit,Host CPU)。In the embodiment of the present invention, the terminal uses an NFCC chip and an NFCC driver to obtain external data sent by an external device such as a contactless card reader or a contactless POS machine from the NFC antenna, and then sends the obtained data to the NFCC routing module for processing. The NFCC routing module is a software entity (for example, the routing module can be implemented as chip firmware), the NFCC routing module obtains the second identifier in the external data, and according to the routing table stored in the NFCC, the data that needs to be sent to the TEE Forwarded to the TEE, the data that needs to be sent to the TEE in the embodiment of the present invention includes the data whose routing target is the device host. The device host generally refers to the central processing unit CPU of the terminal, also called the host central processing unit (Host Central Processing Unit). CentralProcessing Unit, Host CPU).
NFC有卡模拟、P2P和读卡器三种工作模式,为支持以上三种工作模式NFCC芯片会工作在轮询模式(Poll模式,对应P2P和读卡器)和侦听(listen)模式,卡模拟属于侦听模式,故,通过确定NFCC芯片当前工作模式是否为卡模拟可确定是否需要执行路由,进一步地,通过获取到的外部数据中的SELECT AID命令与NFCC中配置的路由表,可以确定是否需要将获取的外部数据发送至TEE。NFC has three working modes: card simulation, P2P and card reader. To support the above three working modes, the NFCC chip will work in polling mode (Poll mode, corresponding to P2P and card reader) and listening (listen) mode. The simulation belongs to the listening mode. Therefore, it can be determined whether routing needs to be performed by determining whether the current working mode of the NFCC chip is card simulation. Further, it can be determined by the SELECT AID command in the acquired external data and the routing table configured in the NFCC. Whether the acquired external data needs to be sent to the TEE.
本发明实施例中通过TEE中的NFCC执行第一次路由,从而将路由目标是设备主机CPU的所述外部数据发送至TEE中的路由管理模块,可参阅图1B所示。通过REE中的NFCC执行第一次路由,从而将路由目标是设备主机的所述外部数据发送至TEE中的路由管理模块,可参阅图1A所示。In the embodiment of the present invention, the first routing is performed by the NFCC in the TEE, so that the external data whose routing target is the device host CPU is sent to the routing management module in the TEE, as shown in FIG. 1B . The first routing is performed through the NFCC in the REE, so that the external data whose routing target is the device host is sent to the routing management module in the TEE, as shown in FIG. 1A .
其中第一次路由是指将获取的数据发送至TEE中的路由管理模块的过程。The first routing refers to the process of sending the acquired data to the routing management module in the TEE.
本发明实施例中为实现在TEE中将所述外部数据发送至与所述外部数据对应的HCE应用,可预先进行路由信息保存,即将HCE应用的第一标识与至少一个第二标识及其对应关系进行注册,本发明实施例中可将HCE应用的第一标识与至少一个第二标识注册到TEE中的路由管理模块,然后由TEE中的路由管理模块基于保存的路由信息,将数据路由到对应的环境中的HCE应用。这样使得不同类型的HCE应用能够在不同的终端环境中处理,提高了基于不同HCE应用的安全性。In this embodiment of the present invention, in order to send the external data to the HCE application corresponding to the external data in the TEE, routing information may be stored in advance, that is, the first identifier of the HCE application and at least one second identifier and its corresponding In this embodiment of the present invention, the first identifier and at least one second identifier of the HCE application may be registered to the routing management module in the TEE, and then the routing management module in the TEE routes the data to the stored routing information based on the stored routing information. HCE application in the corresponding environment. In this way, different types of HCE applications can be processed in different terminal environments, and the security based on different HCE applications is improved.
本发明实施例中预先进行路由信息注册的过程,可参阅图6所示。一个REE中的HCE应用,可以通过静态资源文件,指定此HCE应用对应的第二标识列表,也可以使用动态注册应用程序编程接口(Application Programming Interface,API),指定此HCE应用对应的第二标识列表;无论是使用静态还是动态方法,都需要通过TEE客户端应用编程接口(TEEClient API)或共享内存将第一标识与第二标识的映射关系发送给TEE中的路由管理模块。TEE中的HCE应用,也可以使用上述静态或动态方法声明此HCE应用对应的第二标识,不同之处在于,此时无需使用TEE Client API或共享内存,而是使用TA之间的通信机制即会话(session),将第一标识与第二标识的映射关系发送给TEE中的路由管理模块,路由管理模块会从第一标识中解析得到HCE应用安装的终端环境,进而,HCE应用的第一标识、与第一标识对应的至少一个第二标识以及该HCE应用安装的终端环境作为至少一条路由项保存在路由管理模块中。图6中,对于REE,用户下载CA安装包后,终端进行应用安装配置文件的解析,解析到<host-apdu-service/>标签,获知该HCE应用为CA,进一步进行资源文件解析,读取资源文件中的第二标识,将读取到的第一标识与至少一个第二标识发送到TEE中的路由管理模块。For the process of pre-registering routing information in this embodiment of the present invention, reference may be made to FIG. 6 . An HCE application in a REE can specify the second identifier list corresponding to the HCE application through the static resource file, or use the dynamic registration application programming interface (Application Programming Interface, API) to specify the second identifier corresponding to the HCE application List; whether static or dynamic methods are used, the mapping relationship between the first identifier and the second identifier needs to be sent to the routing management module in the TEE through the TEE client application programming interface (TEEClient API) or shared memory. The HCE application in the TEE can also use the above static or dynamic method to declare the second identifier corresponding to the HCE application. The difference is that in this case, there is no need to use the TEE Client API or shared memory, but the communication mechanism between TAs is used. Session, sending the mapping relationship between the first identifier and the second identifier to the routing management module in the TEE, and the routing management module will parse the first identifier to obtain the terminal environment in which the HCE application is installed, and then, the first identifier of the HCE application is installed. The identifier, at least one second identifier corresponding to the first identifier, and the terminal environment in which the HCE application is installed are stored in the routing management module as at least one routing item. In Figure 6, for REE, after the user downloads the CA installation package, the terminal parses the application installation configuration file, parses the <host-apdu-service/> tag, learns that the HCE application is a CA, further parses the resource file, reads For the second identifier in the resource file, the read first identifier and at least one second identifier are sent to the routing management module in the TEE.
进一步的,本发明实施例中对于REE中的HCE应用(是一个CA),可通过CA运行时,调用动态第二标识加载API将第一标识与第二标识之间的映射关系发送给TEE中的路由管理模块。本发明实施例中当CA应用更新或者组件更新时,例如软件应用版本升级,或者向HCE应用中增加新的卡应用时,即新增AID时,也需将更新的信息发送到TEE中,以实现准确的路由。图6中,对于TEE中,用户下载HCE应用(是一个TA)安装包后,终端解析TA应用的第一标识与第二标识,或者调用TA运行时的动态加载第二标识的API,发送第一标识与第二标识的映射关系给TEE的路由管理模块。TEE中的路由管理模块,进行第一标识与第二标识的接收与管理,在TEE中保存或者更新HCE应用的路由信息。Further, in the embodiment of the present invention, for the HCE application (which is a CA) in the REE, the dynamic second identification loading API can be called through the CA runtime to send the mapping relationship between the first identification and the second identification to the TEE. Route management module. In this embodiment of the present invention, when a CA application is updated or a component is updated, such as a software application version upgrade, or when a new card application is added to the HCE application, that is, when an AID is added, the updated information also needs to be sent to the TEE to Implement accurate routing. In Figure 6, for the TEE, after the user downloads the HCE application (which is a TA) installation package, the terminal parses the first and second identifiers of the TA application, or calls the API for dynamically loading the second identifier when the TA is running, and sends the first and second identifiers of the TA application. The mapping relationship between the identifier and the second identifier is given to the routing management module of the TEE. The routing management module in the TEE receives and manages the first identifier and the second identifier, and saves or updates the routing information of the HCE application in the TEE.
本发明实施例中预先保存了HCE应用的路由信息后,则可等待接收数据,当接收到数据后,NFCC执行第一次路由,将数据路由到TEE中的路由管理模块,由该路由管理模块依据预先保存的路由信息进行第二次路由,将数据转发给CA或TA,如图7所示。In the embodiment of the present invention, after the routing information of the HCE application is pre-stored, it can wait to receive data. After receiving the data, the NFCC performs the first routing, and routes the data to the routing management module in the TEE, and the routing management module The second routing is performed according to the pre-stored routing information, and the data is forwarded to the CA or TA, as shown in Figure 7.
其中,第二次路由是指由路由管理模块接收数据,并将数据转发给CA或TA的过程。The second routing refers to the process that the routing management module receives the data and forwards the data to the CA or TA.
本发明实施例,在TEE的路由管理模块中根据保存的路由信息,设置路由表,路由表中包括:TA和CA的第一标识、第二标识和安装的终端环境,路由管理模块依据该路由表将数据路由到相应的HCE应用。In the embodiment of the present invention, a routing table is set in the routing management module of the TEE according to the stored routing information, and the routing table includes: the first identification, the second identification of the TA and the CA, and the installed terminal environment, and the routing management module is based on the routing information. The table routes the data to the corresponding HCE application.
图8为本发明实施例设置的路由表,如图8所示,针对每一个第二标识及其对应的第一标识,分别设置路由项,例如CA的第二标识1和第一标识1对应路由1,TA的第二标识2和第一标识2对应路由2。FIG. 8 is a routing table set up in an embodiment of the present invention. As shown in FIG. 8 , for each second identifier and its corresponding first identifier, routing items are respectively set, for example, the second identifier 1 of CA corresponds to the first identifier 1 Route 1, the second identifier 2 and the first identifier 2 of the TA correspond to route 2.
需要说明的是,本发明实施例中通过图6所示的方法,完成了CA和TA及其对应的第一标识与第二标识向TEE的注册,完成路由信息的准备工作,但是在具体实施过程中,由于TA的引入,需要对目前的HCE机制做如下改动:It should be noted that, in the embodiment of the present invention, the method shown in FIG. 6 is used to complete the registration of CA and TA and their corresponding first and second identifiers to the TEE, and complete the preparation of routing information, but in the specific implementation During the process, due to the introduction of TA, the following changes need to be made to the current HCE mechanism:
配置文件的修改:需要增加一个标识TEE中HCE应用的应用类型标签,即第一标识标签,诸如<TEE_apdu_service/>,以在配置文件中指示一个运行于TEE的HCE应用的存在。Modification of the configuration file: an application type tag identifying the HCE application in the TEE needs to be added, that is, the first identification tag, such as <TEE_apdu_service/>, to indicate the existence of an HCE application running on the TEE in the configuration file.
资源文件的修改:需要给一个标识TEE中HCE应用的应用类型标签,即第一标签,诸如<TEE-apdu-service/>标签,关联若干个第二标识标签,诸如<AID-filter>标签,以便通知服务框架,TA能够处理的读卡器与HCE应用之间的消息流。Modification of resource files: It is necessary to associate an application type tag that identifies the HCE application in the TEE, that is, the first tag, such as the <TEE-apdu-service/> tag, and associate several second identification tags, such as the <AID-filter> tag, In order to notify the service framework, the TA can handle the message flow between the reader and the HCE application.
本发明实施例中,将CA安装到REE中,将TA安装到TEE中,完成将HCE应用安装到对应环境后,在终端与非接触读卡设备进行交互时,由相应环境中的HCE进行数据的处理。In the embodiment of the present invention, the CA is installed in the REE, the TA is installed in the TEE, and after the HCE application is installed in the corresponding environment, when the terminal interacts with the contactless card reading device, the HCE in the corresponding environment performs data processing processing.
本发明实施例,终端在TEE中将所述外部数据发送至所述外部数据对应的HCE应用,或者说由TEE中的路由管理模块执行第二次路由,可采用如图9所示的方法:In this embodiment of the present invention, the terminal sends the external data to the HCE application corresponding to the external data in the TEE, or the routing management module in the TEE performs the second routing, and the method shown in FIG. 9 may be adopted:
S1051:TEE中的路由管理模块获取所述外部数据中的第二标识,所述第二标识用于标识读卡设备与终端上一个HCE应用之间的消息流。路由管理模块仅当收到SELECT AID指令时,才执行获取第二标识的操作;收到其他APDU指令时,如果之前没收到过SELECTAID,则认为是错误;如之前收到过SELECT AID指令,则将指令转发给SELECT AID指令对应的HCE应用。S1051: The routing management module in the TEE acquires a second identifier in the external data, where the second identifier is used to identify a message flow between the card reader device and an HCE application on the terminal. The routing management module only executes the operation of acquiring the second identifier when it receives the SELECT AID command; when receiving other APDU commands, if it has not received SELECT AID before, it is considered an error; if it has received the SELECT AID command before, then Forward the command to the HCE application corresponding to the SELECT AID command.
S1052:TEE中的路由管理模块,根据注册到TEE中的HCE应用的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境。路由管理模块从外部数据中获得第二标识后,将获得的第二标识与TEE路由管理模块路由表中的AID依次进行比较,直至找到相同的AID,此时将包含相同AID的路由项中的第一标识,作为外部数据第一标识,并找到与该AID对应的HCE应用安装的终端环境。S1052: The routing management module in the TEE determines, according to the routing information of the HCE application registered in the TEE, an external data first identifier corresponding to the second identifier in the external data, and a first external data identifier corresponding to the external data The terminal environment in which the HCE application is installed. After the routing management module obtains the second identifier from the external data, it sequentially compares the obtained second identifier with the AIDs in the routing table of the TEE routing management module until the same AID is found. The first identifier is used as the first identifier of external data, and the terminal environment in which the HCE application corresponding to the AID is installed is found.
S1053:TEE中的路由管理模块根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。S1053: The routing management module in the TEE sends the external data to the HCE application corresponding to the first identifier of the external data according to the determined terminal environment.
本发明实施例中,通过获取外部数据中的第二标识,可根据路由信息确定与该第二标识对应的外部数据第一标识以及HCE应用安装的终端环境。确定了HCE应用安装的终端环境后,则可将获取到的数据路由至相应环境中的HCE应用,完成支持不同安全级别的HCE应用的数据路由。In the embodiment of the present invention, by acquiring the second identifier in the external data, the first identifier of the external data corresponding to the second identifier and the terminal environment in which the HCE application is installed can be determined according to the routing information. After the terminal environment in which the HCE application is installed is determined, the acquired data can be routed to the HCE application in the corresponding environment to complete the data routing of the HCE application supporting different security levels.
需要说明的是,本发明实施例中的路由信息中还可以仅包括第一标识、第二标识,通过获取外部数据中的第二标识,确定与该第二标识对应的外部数据第一标识,通过外部数据第一标识的解析,则可确定该HCE应用是TA还是CA,进而可得知该HCE应用的安装环境,若为TA,则安装环境为TEE,若为CA,则安装环境为REE。It should be noted that the routing information in this embodiment of the present invention may also include only the first identifier and the second identifier, and by acquiring the second identifier in the external data, the first identifier of the external data corresponding to the second identifier is determined, Through the analysis of the first identifier of the external data, it can be determined whether the HCE application is a TA or a CA, and then the installation environment of the HCE application can be known. If it is TA, the installation environment is TEE, and if it is CA, the installation environment is REE .
本发明实施例,根据确定的所述HCE应用安装的终端环境,将所述数据发送至与所述外部数据第一标识对应的HCE应用,具体可采用如下方式:In this embodiment of the present invention, according to the determined terminal environment in which the HCE application is installed, the data is sent to the HCE application corresponding to the first identifier of the external data, and the specific method may be as follows:
A:若确定的所述HCE应用安装的终端环境为TEE,则通过建立的会话将所述数据发送给TEE中的与所述外部数据第一标识对应的HCE应用。A: If it is determined that the terminal environment in which the HCE application is installed is the TEE, the data is sent to the HCE application corresponding to the first identifier of the external data in the TEE through the established session.
TEE的路由管理模块根据外部数据中的第二标识在路由表中查找到对应的外部数据第一标识、该HCE应用安装的终端环境,则路由管理模块,即图1A和图1B中的Route-TA,使用TEE内部核心API(TEE Internal Core API)标准定义的内部客户端API(InternalClient API)创建到目标TA的会话(session),将数据转发给TA,如图10所示。因安装TA时,已经将该TA的第一标识、至少一个第二标识和安装的终端环境,注册到TEE中的Route-TA(即路由管理模块),故而Route-TA可以主动的将获取的外部数据发送给TA,故若在建立会话后,如果收到的数据帧不包含选择第二标识命令,则可一直通过当前已经建立的会话转发外部数据给对应的TA。The routing management module of the TEE finds the corresponding first identification of the external data and the terminal environment in which the HCE application is installed in the routing table according to the second identification in the external data, then the routing management module, namely the Route- The TA uses the internal client API (InternalClient API) defined by the TEE Internal Core API (TEE Internal Core API) standard to create a session (session) to the target TA, and forwards the data to the TA, as shown in Figure 10. When the TA is installed, the first identifier of the TA, at least one second identifier and the installed terminal environment have been registered to the Route-TA (that is, the route management module) in the TEE, so the Route-TA can actively External data is sent to the TA, so if the received data frame does not contain a command to select the second identification after the session is established, the external data can be forwarded to the corresponding TA through the currently established session.
B:若确定的所述HCE应用安装的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。B: If it is determined that the terminal environment in which the HCE application is installed is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
具体的,CA启动时,使用服务程序(REE NFC Service),这里简称作RNS-TA的第一标识UUID,创建一个CA到TA的Session,此session处于等待(pending)状态;而RNS-TA收到来自Route-TA的数据后,路由管理模块已经标注数据应由哪个CA处理,故而RNS-TA可以通过已经建立的Session将数据返回给CA。故本发明实施例中TEE的路由管理模块根据外部数据中的第二标识查找到对应的外部数据第一标识、该HCE应用安装的终端环境,则路由管理模块,即图1A和图1B中的Route-TA,将数据转发给TEE中的服务程序,进而将该外部数据转发给对应的CA,如图11A所示。本发明实施例中,若确定HCE应用的安装环境为REE,则还可直接由路由管理模块将该外部数据通过共享内存发送给CA,如图11B所示。Specifically, when the CA starts, it uses the service program (REE NFC Service), which is referred to as the first identifier UUID of the RNS-TA here, to create a session from CA to TA, and this session is in the pending state; while the RNS-TA receives After receiving the data from Route-TA, the route management module has marked which CA the data should be processed by, so RNS-TA can return the data to the CA through the established Session. Therefore, in the embodiment of the present invention, the routing management module of the TEE finds the first identification of the corresponding external data and the terminal environment in which the HCE application is installed according to the second identification in the external data. Route-TA, forwards the data to the service program in the TEE, and then forwards the external data to the corresponding CA, as shown in Figure 11A. In this embodiment of the present invention, if it is determined that the installation environment of the HCE application is REE, the routing management module may directly send the external data to the CA through the shared memory, as shown in FIG. 11B .
本发明实施例中,当再次收到外部数据,并且外部数据包含第二标识选择命令(即SELECTAID命令)时,NFCC将数据帧转发给TEE,由TEE的路由管理模块执行TEE内路由,路由管理模块判断此外部数据第二标识是否由当前已经建立Session的HCE应用进行处理,记为HCE应用1处理,如果是由HCE应用1处理,则路由管理模块直接使用当前的Session将该外部数据发送给HCE应用1;如果是由不同于当前HCE应用的其他HCE应用处理,记为HCE应用2,那么路由管理模块可以选择保持当前Session或者关闭当前的Session,但是一定要根据HCE应用2的第一标识建立第二个Session,通过第二个Session把第二标识选择命令及后续的外部数据发送给HCE应用2。In the embodiment of the present invention, when the external data is received again, and the external data contains the second identification selection command (ie, the SELECTAID command), the NFCC forwards the data frame to the TEE, and the routing management module of the TEE executes the routing within the TEE, and the routing management The module judges whether the second identifier of the external data is processed by the HCE application that has currently established a session, which is recorded as HCE application 1 processing. If it is processed by HCE application 1, the routing management module directly uses the current Session to send the external data to. HCE application 1; if it is processed by other HCE applications different from the current HCE application, it is recorded as HCE application 2, then the routing management module can choose to keep the current session or close the current session, but it must be based on the first identification of HCE application 2 A second session is established, and the second identifier selection command and subsequent external data are sent to the HCE application 2 through the second session.
本发明实施例以下将结合实际应用对上述涉及的数据路由过程进行详细说明。In the embodiments of the present invention, the data routing process involved above will be described in detail below in combination with practical applications.
本发明实施例以非接触POS机与终端之间进行通信为例进行说明。支持TEE的终端作为卡模拟设备,当非接触POS机将交易数据通过近场支付环境NFC通道发送给终端时,终端通过NFCC获取到该交易数据,并通过REE中的NFCC或者TEE中的NFCC,将该交易数据传送至TEE的路由管理模块,TEE的路由管理模块根据该交易数据中的AID即第二标识,查找与该第二标识对应的第一标识,终端根据该第一标识可知该交易数据应该由哪个TA或CA处理,进而建立session,并通过建立的session将交易数据发送AID对应的TA或CA。The embodiment of the present invention is described by taking the communication between the non-contact POS machine and the terminal as an example. The terminal that supports TEE is used as a card simulation device. When the contactless POS machine sends transaction data to the terminal through the NFC channel of the near-field payment environment, the terminal obtains the transaction data through NFCC, and passes the NFCC in REE or NFCC in TEE, The transaction data is sent to the routing management module of the TEE, and the routing management module of the TEE searches for the first identification corresponding to the second identification according to the AID in the transaction data, that is, the second identification, and the terminal knows the transaction according to the first identification. Which TA or CA should process the data, then establish a session, and send the transaction data to the TA or CA corresponding to the AID through the established session.
需要说明的是,本发明实施例,将CA安装到REE中,将TA安装到TEE中,完成将HCE应用安装到对应环境后,在终端与读卡设备进行交互,由相应环境中的HCE应用进行数据处理时,可采用上述实施例涉及的数据路由的处理流程,即本发明实施例还可提供一种数据路由方法,具体的实施过程,可参阅上述实施例的描述,本发明实施例在此不再赘述。It should be noted that, in this embodiment of the present invention, the CA is installed in the REE, the TA is installed in the TEE, and after the HCE application is installed in the corresponding environment, the terminal interacts with the card reader, and the HCE application in the corresponding environment interacts with the card reader. When performing data processing, the processing flow of the data routing involved in the above embodiments may be used, that is, the embodiments of the present invention may also provide a data routing method. For the specific implementation process, please refer to the descriptions of the above embodiments. This will not be repeated here.
本发明实施例提供的主机卡模拟方法,通过资源文件中的两种不同应用类型标签,终端可以区分HCE应用安装的终端环境为TEE还是REE,进而终端在接收到HCE应用安装包时,可通过资源文件中的应用类型标签,确定HCE应用安装的终端环境,区分该HCE应用为TA或CA,进而将TA安装到TEE中,将CA安装到REE中,实现支持TEE和REE两种不同安全级别的HCE应用,以使开发者可以根据需要选择在TEE中实现HCE功能,或者选择在REE中实现HCE功能,以满足不同应用功能的需求。In the host card simulation method provided by the embodiment of the present invention, through two different application type labels in the resource file, the terminal can distinguish whether the terminal environment in which the HCE application is installed is TEE or REE, and then when the terminal receives the HCE application installation package, it can pass The application type label in the resource file determines the terminal environment in which the HCE application is installed, distinguishes the HCE application as TA or CA, and then installs the TA into the TEE and the CA into the REE to support two different security levels of TEE and REE. The HCE application, so that developers can choose to implement the HCE function in the TEE, or choose to implement the HCE function in the REE, to meet the needs of different application functions.
基于上述实施例提供的实现主机卡模拟的方法,本发明实施例还提供一种实现主机卡模拟HCE的终端100,所述实现主机卡模拟HCE的终端100包括安装单元101、解析单元102和注册单元103,如图12A所示,本发明实施例中:Based on the method for implementing host card emulation provided by the above embodiments, the embodiment of the present invention further provides a terminal 100 for implementing host card emulation HCE, the terminal 100 implementing host card emulation HCE includes an
安装单元101,用于根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中。The
本发明实施例中,所述终端环境包括可信执行环境TEE和富执行环境REE。In this embodiment of the present invention, the terminal environment includes a trusted execution environment TEE and a rich execution environment REE.
解析单元102,用于解析所述安装单元101安装的所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识.The
本发明实施例中,所述第一标识用于在所述终端中唯一标识所述HCE应用,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流。In the embodiment of the present invention, the first identifier is used to uniquely identify the HCE application in the terminal, and the second identifier is used to identify the message flow between the card reader device and the HCE application.
注册单元103,用于将所述HCE应用的路由信息注册到TEE中,其中,所述路由信息包括所述解析单元102解析出的所述第一标识、所述至少一个第二标识以及所述HCE应用安装的终端环境。A
本发明实施例提供的实现主机卡模拟的终端100,通过不同的应用类型标签,区分HCE应用为TA或CA,进而将TA安装到TEE中,将CA安装到REE中,实现了基于TEE和基于REE两种不同安全级别的HCE应用。The terminal 100 that implements the host card simulation provided by the embodiment of the present invention distinguishes HCE applications as TA or CA through different application type labels, and then installs TA into TEE and CA into REE, so as to realize TEE-based and CA-based REE HCE applications with two different security levels.
在第一种实现方式中,本发明实施例提供的实现主机卡模拟的终端100还包括第一路由单元104和第二路由单元105,其中,In the first implementation manner, the terminal 100 for implementing the host card simulation provided by the embodiment of the present invention further includes a
所述第一路由单元104,用于将获取的外部数据发送至TEE中的第二路由单元;The
所述第二路由单元105,用于将所述外部数据发送至与所述外部数据对应的安装单元101安装的HCE应用。The
具体的,所述第一路由单元104,具体用于按如下方式将获取的外部数据发送至TEE中的第二路由单元105:Specifically, the
通过TEE中的近场通信控制器NFCC或REE中的NFCC获取外部数据;由TEE中的所述NFCC或REE中的所述NFCC将路由目标是设备主机的所述外部数据发送至TEE中的第二路由单元105。Obtain external data through the near field communication controller NFCC in the TEE or the NFCC in the REE; the external data whose routing target is the device host is sent by the NFCC in the TEE or the NFCC in the REE to the No. 1 in the TEE
进一步的,所述第二路由单元105,具体用于按如下方式将所述外部数据发送至所述外部数据对应的HCE应用:Further, the
获取所述外部数据中的第二标识;obtaining the second identifier in the external data;
根据所述注册到TEE中的信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境;According to the information registered in the TEE, determine the first identification of external data corresponding to the second identification in the external data, and the terminal environment in which the HCE application corresponding to the first identification of external data is installed;
根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。According to the determined terminal environment, the external data is sent to the HCE application corresponding to the first identifier of the external data.
具体的,所述第二路由单元105,具体用于按如下方式根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用:Specifically, the
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
本发明实施例提供的实现主机卡模拟的终端100,用于实现本发明上述实施例涉及的实现主机卡模拟的方法的功能,对于实现的具体过程,可参阅上述实施例的描述,本发明实施例在此不再赘述。The terminal 100 for implementing host card emulation provided by the embodiments of the present invention is used to implement the functions of the methods for implementing host card emulation involved in the above-mentioned embodiments of the present invention. The example will not be repeated here.
本发明实施例提供的主机卡模拟终端100,通过两种不同应用类型标签,终端可以区分HCE应用的安装环境为TEE还是REE,进而终端在接收到HCE应用安装包时,可通过应用类型标签,确定HCE应用安装的终端环境,区分该HCE应用为TA或CA,进而将TA安装到TEE中,将CA安装到REE中,实现支持TEE和REE两种不同安全级别的HCE应用,以使开发者可以根据需要选择在TEE中实现HCE功能,或者选择在REE中实现HCE功能,以满足不同应用功能的需求。In the host
基于上述实施例提供的实现主机卡模拟的方法,本发明实施例还提供一种实现主机卡模拟的终端200,如图13所示,实现主机卡模拟的终端200包括有处理器201。实现主机卡模拟的终端200中包括REE和TEE两种运行环境,两种运行环境分别有各自的处理器,即实现主机卡模拟的终端200的处理器201包括公共处理核2011和可信处理核2012,其中,公共处理核2011为REE的处理器,可信处理核2012为TEE的处理器。需要说明的是,本发明中,公共处理核2011与可信处理核2012可以是同一个实体CPU的不同核心,或者也可以是同一个实体CPU的不同CPU时间。Based on the method for implementing host card emulation provided by the above embodiments, an embodiment of the present invention further provides a terminal 200 implementing host card emulation. As shown in FIG. 13 , the terminal 200 implementing host card emulation includes a processor 201 . The terminal 200 that implements the host card emulation includes two operating environments, REE and TEE, and the two operating environments have their own processors, that is, the processor 201 of the terminal 200 that implements the host card emulation includes a common processing core 2011 and a trusted processing core. 2012, wherein the public processing core 2011 is a processor of REE, and the trusted processing core 2012 is a processor of TEE. It should be noted that, in the present invention, the common processing core 2011 and the trusted processing core 2012 may be different cores of the same physical CPU, or may be different CPU times of the same physical CPU.
进一步的,本发明实施例中提供的实现主机卡模拟的终端200还包括存储器,所述存储器包括运行在REE中的公共随机存取存储器(Random-Access Memory,RAM)2021和公共只读存储器(read-only Memory,ROM)2041,以及运行在TEE中的可信RAM2022和可信ROM2042。Further, the terminal 200 for implementing the host card simulation provided in the embodiment of the present invention further includes a memory, and the memory includes a public random-access memory (Random-Access Memory, RAM) 2021 running in the REE and a public read-only memory ( read-only Memory, ROM) 2041, and trusted RAM 2022 and trusted ROM 2042 running in the TEE.
本发明实施例中公共RAM2021、公共ROM2041、可信RAM2022以及可信ROM2042可用于存储指令和数据。存储指令区可存储操作系统、至少一个功能所需的指令等;所述指令可使处理器201执行本发明上述实施例涉及的实现主机卡模拟的方法。In this embodiment of the present invention, the public RAM 2021, the public ROM 2041, the trusted RAM 2022, and the trusted ROM 2042 may be used to store instructions and data. The storage instruction area may store an operating system, an instruction required for at least one function, and the like; the instruction may enable the processor 201 to execute the method for implementing the host card emulation involved in the foregoing embodiments of the present invention.
本发明实施例中终端实现主机卡模拟的终端200还包括有外设,所述外设包括REE中的公共外设2031和TEE中的可信外设2032。当NFCC位于REE中时,NFCC为公共外设;当NFCC位于TEE中时,NFCC为可信外设;In the embodiment of the present invention, the terminal 200 in which the terminal implements the host card simulation further includes peripheral devices, and the peripheral devices include a public peripheral device 2031 in the REE and a trusted peripheral device 2032 in the TEE. When the NFCC is located in the REE, the NFCC is a public peripheral; when the NFCC is located in the TEE, the NFCC is a trusted peripheral;
进一步的,本发明实施例中终端实现主机卡模拟的终端200还包括有位于REE中的通信单元2051。Further, in the embodiment of the present invention, the terminal 200 in which the terminal implements the host card simulation further includes a communication unit 2051 located in the REE.
本发明实施例中处理器201是实现主机卡模拟的终端200的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在公共RAM2021、公共ROM2041、可信RAM2022以及可信ROM2042内的指令以及调用存储在公共RAM2021、公共ROM2041、可信RAM2022以及可信ROM2042内的数据,通过可信外设2032、公共外设2031以及通信单元2051,执行实现主机卡模拟的终端200的各种功能和处理数据,从而对实现主机卡模拟的终端200进行整体控制。可选的,处理器201可包括一个或多个处理单元;优选的,处理器201可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器201中。在一些实施例中,处理器和存储器、可以在单一芯片上实现,在一些实施例中,他们也可以在独立的芯片上分别实现。In the embodiment of the present invention, the processor 201 is the control center of the terminal 200 that implements the host card simulation, uses various interfaces and lines to connect various parts of the entire mobile phone, and stores the data in the public RAM 2021 , the public ROM 2041 , the trusted RAM 2022 , and the available memory by running or executing the operation or execution. The instructions in the trusted ROM 2042 and the data stored in the public RAM 2021, the public ROM 2041, the trusted RAM 2022 and the trusted ROM 2042 are called, and the terminal 200 that implements the host card simulation is executed through the trusted peripherals 2032, the public peripherals 2031 and the communication unit 2051. various functions and processing data, so as to perform overall control of the terminal 200 that implements host card emulation. Optionally, the processor 201 may include one or more processing units; preferably, the processor 201 may integrate an application processor and a modulation and demodulation processor, wherein the application processor mainly processes the operating system, user interface, and application programs, etc. , the modem processor mainly deals with wireless communication. It can be understood that, the above-mentioned modulation and demodulation processor may not be integrated into the processor 201. In some embodiments, the processor and memory may be implemented on a single chip, and in some embodiments, they may be implemented separately on separate chips.
本发明实施例提供的实现主机卡模拟的终端200包括的处理器201,用于调用存储在所述公共RAM2021、公共ROM2041、可信RAM2022以及可信ROM2042内的指令以及数据,通过所述可信外设2032、所述公共外设2031以及所述通信单元2051,实现以下功能:The processor 201 included in the terminal 200 implementing the host card emulation provided by the embodiment of the present invention is configured to call the instructions and data stored in the public RAM 2021, the public ROM 2041, the trusted RAM 2022, and the trusted ROM 2042, through the trusted ROM 2042. The peripheral device 2032, the public peripheral device 2031 and the communication unit 2051 realize the following functions:
根据HCE应用的类型,将所述HCE应用安装至与所述HCE应用的类型对应的终端环境中,其中,所述终端环境包括TEE和REE;解析所述HCE应用的第一标识和所述HCE应用中包含的至少一个第二标识,所述第一标识用于在所述终端中唯一标识所述HCE应用,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流;并用于将所述HCE应用的路由信息注册到TEE中,其中,所述路由信息包括所述第一标识、所述至少一个第二标识以及所述HCE应用安装的所述终端环境。Install the HCE application into a terminal environment corresponding to the type of the HCE application according to the type of the HCE application, wherein the terminal environment includes TEE and REE; parse the first identifier of the HCE application and the HCE At least one second identifier included in the application, the first identifier is used to uniquely identify the HCE application in the terminal, and the second identifier is used to identify the message flow between the card reader device and the HCE application and is used to register the routing information of the HCE application in the TEE, wherein the routing information includes the first identifier, the at least one second identifier, and the terminal environment where the HCE application is installed.
进一步的,所述处理器201,还用于:Further, the processor 201 is further configured to:
将获取的外部数据发送至TEE中的路由管理模块,控制所述路由管理模块将所述外部数据发送至与所述外部数据对应的HCE应用。The acquired external data is sent to the routing management module in the TEE, and the routing management module is controlled to send the external data to the HCE application corresponding to the external data.
具体的,所述处理器201,具体用于采用如下方式将获取的外部数据发送至TEE中的路由管理模块:Specifically, the processor 201 is specifically configured to send the acquired external data to the routing management module in the TEE in the following manner:
通过TEE中的NFCC或REE中的NFCC获取外部数据;Obtain external data through NFCC in TEE or NFCC in REE;
由TEE中的所述NFCC或REE中的所述NFCC将路由目标是设备主机的所述外部数据发送至TEE中的路由管理模块。The external data whose routing target is a device host is sent by the NFCC in the TEE or the NFCC in the REE to a routing management module in the TEE.
其中,所述处理器201,具体用于按如下方式控制所述路由管理模块将所述外部数据发送至所述外部数据对应的HCE应用:The processor 201 is specifically configured to control the routing management module to send the external data to the HCE application corresponding to the external data in the following manner:
控制所述路由管理模块通过所述通信单元以及所述外设获取所述外部数据中的第二标识,并根据所述注册到TEE中的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境,并控制所述路由管理模块根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。Control the routing management module to obtain the second identifier in the external data through the communication unit and the peripheral device, and determine the second identifier in the external data according to the routing information registered in the TEE The corresponding external data first identification and the terminal environment in which the HCE application corresponding to the external data first identification is installed, and control the routing management module to send the external data to the terminal environment according to the determined terminal environment. The HCE application corresponding to the first identifier of the external data.
具体的,所述处理器201,具体用于按如下方式控制所述路由管理模块根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用:Specifically, the processor 201 is specifically configured to control the routing management module to send the external data to the HCE application corresponding to the first identifier of the external data according to the determined terminal environment as follows:
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
本发明实施例提供的实现主机卡模拟的终端200,具有实现本发明上述实施例涉及的实现主机卡模拟的任意方法的功能,对于具体实现的功能,可参阅上述实施例的描述,本发明实施例在此不再赘述。The terminal 200 for implementing the host card emulation provided by the embodiment of the present invention has the function of implementing any method for implementing the host card emulation involved in the above-mentioned embodiments of the present invention. The example will not be repeated here.
本发明实施例提供的主机卡模拟终端200,通过两种不同应用类型标签,终端可以区分HCE应用的安装环境为TEE还是REE,进而终端在接收到HCE应用安装包时,可通过应用类型标签,确定HCE应用安装的终端环境,区分该HCE应用为TA或CA,进而将TA安装到TEE中,将CA安装到REE中,实现支持TEE和REE两种不同安全级别的HCE应用,以使开发者可以根据需要选择在TEE中实现HCE功能,或者选择在REE中实现HCE功能,以满足不同应用功能的需求。In the host card simulation terminal 200 provided by the embodiment of the present invention, through two different application type labels, the terminal can distinguish whether the installation environment of the HCE application is TEE or REE. Determine the terminal environment in which the HCE application is installed, distinguish the HCE application as TA or CA, and then install the TA into the TEE and the CA into the REE to implement HCE applications that support two different security levels of TEE and REE, so that developers can You can choose to implement the HCE function in the TEE or choose to implement the HCE function in the REE as required to meet the needs of different application functions.
基于上述实施例提供的实现主机卡模拟方法中的数据路由过程,本发明实施例还提供一种数据路由装置300,如图14所示,数据路由装置300包括获取单元301、第一路由单元302和第二路由单元303,其中,Based on the data routing process in the host card emulation method provided by the above embodiments, an embodiment of the present invention further provides a
获取单元301,用于获取外部数据。The acquiring
第一路由单元302,用于将所述获取单元301获取的外部数据发送至TEE;a
第二路由单元303,用于将所述外部数据发送至与所述外部数据对应的HCE应用。The
在第一种实现方式中,所述第一路由单元302,具体用于按如下方式将获取的外部数据发送至TEE:In a first implementation manner, the
通过TEE中的NFCC驱动或者REE中的NFCC驱动获得所述数据,并将路由目标是设备主机的所述外部数据发送至TEE中的第二路由单元303。The data is obtained through the NFCC driver in the TEE or the NFCC driver in the REE, and the external data whose routing target is the device host is sent to the
在第二种实现方式中,所述第二路由单元303,具体用于按如下方式,将所述外部数据发送至与所述外部数据对应的HCE应用:In the second implementation manner, the
获取所述外部数据中的第二标识,所述第二标识用于标识读卡设备与所述HCE应用之间的消息流;Acquiring a second identifier in the external data, where the second identifier is used to identify a message flow between the card reader device and the HCE application;
根据注册到TEE中的所述HCE应用的路由信息,确定与所述外部数据中的第二标识对应的外部数据第一标识、以及与所述外部数据第一标识对应的HCE应用安装的终端环境,所述第一标识用于在终端中唯一标识一个HCE应用;Determine, according to the routing information of the HCE application registered in the TEE, the first identifier of external data corresponding to the second identifier in the external data, and the terminal environment in which the HCE application corresponding to the first identifier of external data is installed , the first identifier is used to uniquely identify an HCE application in the terminal;
根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用。According to the determined terminal environment, the external data is sent to the HCE application corresponding to the first identifier of the external data.
在第三种实现方式中,所述第二路由单元303,具体用于按如下方式,根据所述确定的终端环境,将所述外部数据发送至与所述外部数据第一标识对应的HCE应用:In a third implementation manner, the
若所述确定的终端环境为TEE,则通过建立的会话将所述外部数据发送给TEE中的与所述外部数据第一标识对应的HCE应用;If the determined terminal environment is a TEE, sending the external data to the HCE application corresponding to the first identifier of the external data in the TEE through the established session;
若所述确定的终端环境为REE,则通过TEE中的服务程序或者共享内存将所述外部数据发送给REE中的与所述外部数据第一标识对应的HCE应用。If the determined terminal environment is REE, the external data is sent to the HCE application corresponding to the first identifier of the external data in the REE through the service program in the TEE or the shared memory.
本发明实施例提供的数据路由装置300,用于实现本发明上述实施例涉及的实现主机卡模拟方法中的数据路由过程,对于实现的具体过程,可参阅上述实施例的描述,本发明实施例在此不再赘述。The
本发明实施例提供的数据路由装置300,通过获取外部数据中的第二标识,可确定与该第二标识对应的外部数据第一标识,通过外部数据第一标识则可确定该HCE应用是TA还是CA,进而可得知该HCE应用的安装环境,若为TA,则安装环境为TEE,若为CA,则安装环境为REE。确定了HCE应用安装环境后,则可将获取到的数据路由至相应环境中的HCE应用,完成支持不同安全级别的HCE应用的数据路由。The
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分步骤是可以通过程序来指令处理器完成,所述的程序可以存储于计算机可读存储介质中,所述存储介质是非短暂性(英文:non-transitory)介质,例如随机存取存储器,只读存储器,快闪存储器,硬盘,固态硬盘,磁带(英文:magnetic tape),软盘(英文:floppy disk),光盘(英文:optical disc)及其任意组合。Those of ordinary skill in the art can understand that all or part of the steps in the method of implementing the above embodiments can be completed by instructing the processor through a program, and the program can be stored in a computer-readable storage medium, and the storage medium is non-transitory ( English: non-transitory) media, such as random access memory, read only memory, flash memory, hard disk, solid state disk, magnetic tape (English: magnetic tape), floppy disk (English: floppy disk), optical disc (English: optical disc) and any combination thereof.
本发明是参照本发明实施例的方法和设备各自的流程图和方框图来描述的。应理解可由计算机程序指令实现流程图和方框图中的每一流程和方框、以及流程图和方框图中的流程和方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to the respective flowcharts and block diagrams of the methods and apparatuses of the embodiments of the present invention. It will be understood that each process and block in the flowchart and block diagrams, and combinations of processes and blocks in the flowchart and block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in one or more of the flowcharts and one or more blocks of the block diagrams.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。The above description is only a preferred embodiment of the present invention, but the protection scope of the present invention is not limited to this. Substitutions should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims (21)
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2015/088889 WO2017035819A1 (en) | 2015-09-02 | 2015-09-02 | Method for implementing host card emulation, terminal, and data routing method and apparatus |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN106663017A CN106663017A (en) | 2017-05-10 |
| CN106663017B true CN106663017B (en) | 2020-01-10 |
Family
ID=58186475
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201580043877.1A Active CN106663017B (en) | 2015-09-02 | 2015-09-02 | Method, terminal, data routing method and device for realizing host card simulation |
Country Status (4)
| Country | Link |
|---|---|
| US (1) | US11138027B2 (en) |
| EP (1) | EP3333701B1 (en) |
| CN (1) | CN106663017B (en) |
| WO (1) | WO2017035819A1 (en) |
Families Citing this family (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US11443323B2 (en) * | 2018-03-07 | 2022-09-13 | Samsung Electronics Co., Ltd. | System and method for secure transactions with a trusted execution environment (TEE) |
| CN111625815B (en) * | 2020-05-26 | 2023-09-26 | 牛津(海南)区块链研究院有限公司 | Data transaction method and device based on trusted execution environment |
| CN112416227B (en) * | 2020-11-19 | 2022-06-14 | Oppo(重庆)智能科技有限公司 | Configuration method, mobile terminal and computer storage medium |
| CN112822722B (en) * | 2020-12-30 | 2022-09-23 | 联想未来通信科技(重庆)有限公司 | Data message transmission method and device |
| CN114302404B (en) * | 2021-12-23 | 2024-11-19 | 汇顶科技(成都)有限责任公司 | Near field communication method, configuration method, NFC host and electronic device |
| CN114422989A (en) * | 2021-12-27 | 2022-04-29 | 无锡融卡科技有限公司 | NFC communication device and method in smart terminal |
| CN114286345B (en) * | 2021-12-27 | 2024-04-02 | 无锡融卡科技有限公司 | NFC communication device and method in intelligent terminal |
Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102047223A (en) * | 2008-03-27 | 2011-05-04 | 摩托罗拉移动公司 | Method and apparatus for automatic near field communication application selection in an electronic device |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9357332B2 (en) | 2012-06-08 | 2016-05-31 | Broadcom Corporation | Near field communication application identification routing in card emulation |
| CN103778395B (en) * | 2012-10-25 | 2016-12-21 | 中国移动通信集团公司 | Application installation method in near-field communication NFC terminal and NFC terminal |
| CN104636666A (en) | 2013-11-07 | 2015-05-20 | 中国移动通信集团公司 | Method and safety device for safely processing information of mobile terminal |
| EP3084701B1 (en) * | 2013-12-19 | 2022-05-04 | Visa International Service Association | Cloud-based transactions methods and systems |
| EP2911076A1 (en) * | 2014-02-24 | 2015-08-26 | Mastercard International Incorporated | Biometric authentication |
| US10387219B2 (en) * | 2015-03-10 | 2019-08-20 | Oracle International Corporation | Enabling multiple secure elements in a card computing device |
-
2015
- 2015-09-02 WO PCT/CN2015/088889 patent/WO2017035819A1/en active Application Filing
- 2015-09-02 CN CN201580043877.1A patent/CN106663017B/en active Active
- 2015-09-02 US US15/756,711 patent/US11138027B2/en active Active
- 2015-09-02 EP EP15902626.9A patent/EP3333701B1/en active Active
Patent Citations (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102047223A (en) * | 2008-03-27 | 2011-05-04 | 摩托罗拉移动公司 | Method and apparatus for automatic near field communication application selection in an electronic device |
Non-Patent Citations (1)
| Title |
|---|
| 基于TEE的NFC卡模拟安全方案研究;张亚飞 等;《北京电子科技学院学报》;20141215;第22卷(第4期);正文第48-53页,图2-3 * |
Also Published As
| Publication number | Publication date |
|---|---|
| WO2017035819A1 (en) | 2017-03-09 |
| EP3333701A4 (en) | 2018-09-05 |
| US11138027B2 (en) | 2021-10-05 |
| CN106663017A (en) | 2017-05-10 |
| US20180246742A1 (en) | 2018-08-30 |
| EP3333701B1 (en) | 2022-11-02 |
| EP3333701A1 (en) | 2018-06-13 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN106663017B (en) | Method, terminal, data routing method and device for realizing host card simulation | |
| CN101965597B (en) | Method and device for installing and retrieving linked MIFARE applications | |
| JP5323187B2 (en) | Application access method in a secure mobile environment | |
| US8807440B1 (en) | Routing secure element payment requests to an alternate application | |
| US8943494B2 (en) | Method for installing and managing NFC applications with pictures | |
| US11126753B2 (en) | Secure processor chip and terminal device | |
| US20100323681A1 (en) | Sharing or reselling nfc applications among mobile communication devices | |
| US9021055B2 (en) | Nonconforming web service policy functions | |
| CN107251069B (en) | Near field communication payment method and terminal | |
| US10032050B2 (en) | Electronic device, system and method for NFC | |
| CN109766152B (en) | Interaction method and device | |
| JP6573672B2 (en) | NFC communication apparatus and method | |
| US10387219B2 (en) | Enabling multiple secure elements in a card computing device | |
| WO2016202108A1 (en) | Nfc payment method, nfc payment system and mobile terminal | |
| JP6923582B2 (en) | Information processing equipment, information processing methods, and programs | |
| US9807595B2 (en) | Terminal read with smart card update list | |
| US9870217B2 (en) | Toolkit event configuration of applets on a card computing device with installation parameters | |
| US20140298411A1 (en) | Accessing a secure element through a manageablity engine | |
| JP6397200B2 (en) | Management server, data processing method, and program | |
| US20150074105A1 (en) | Mobile application data storage allocation | |
| US8369894B1 (en) | Confirming certification of combinations of secure elements and mobile devices | |
| JP6807817B2 (en) | Terminal | |
| EP3086256A1 (en) | Method of managing a secure element in a nfc device | |
| JPWO2017038821A1 (en) | Information processing apparatus, information processing method, program, and information processing system | |
| CN114968185A (en) | Smart card and operation method and device of application thereof, storage medium and product |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |