WO2019056967A1 - Smart card, control method thereof, and computer readable storage medium - Google Patents

Smart card, control method thereof, and computer readable storage medium Download PDF

Info

Publication number
WO2019056967A1
WO2019056967A1 PCT/CN2018/105143 CN2018105143W WO2019056967A1 WO 2019056967 A1 WO2019056967 A1 WO 2019056967A1 CN 2018105143 W CN2018105143 W CN 2018105143W WO 2019056967 A1 WO2019056967 A1 WO 2019056967A1
Authority
WO
WIPO (PCT)
Prior art keywords
main control
command
protocol type
control module
smart card
Prior art date
Application number
PCT/CN2018/105143
Other languages
French (fr)
Chinese (zh)
Inventor
陈柳章
Original Assignee
深圳市文鼎创数据科技有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 深圳市文鼎创数据科技有限公司 filed Critical 深圳市文鼎创数据科技有限公司
Publication of WO2019056967A1 publication Critical patent/WO2019056967A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/067Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components
    • G06K19/07Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components with integrated circuit chips
    • G06K19/0723Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components with integrated circuit chips the record carrier comprising an arrangement for non-contact communication, e.g. wireless communication circuits on transponder cards, non-contact smart cards or RFIDs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/067Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components
    • G06K19/07Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components with integrated circuit chips
    • G06K19/077Constructional details, e.g. mounting of circuits in the carrier
    • G06K19/07701Constructional details, e.g. mounting of circuits in the carrier the record carrier comprising an interface suitable for human interaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K19/00Record carriers for use with machines and with at least a part designed to carry digital markings
    • G06K19/06Record carriers for use with machines and with at least a part designed to carry digital markings characterised by the kind of the digital marking, e.g. shape, nature, code
    • G06K19/067Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components
    • G06K19/07Record carriers with conductive marks, printed circuits or semiconductor circuit elements, e.g. credit or identity cards also with resonating or responding marks without active components with integrated circuit chips
    • G06K19/077Constructional details, e.g. mounting of circuits in the carrier
    • G06K19/07745Mounting details of integrated circuit chips
    • G06K19/07747Mounting details of integrated circuit chips at least one of the integrated circuit chips being mounted as a module

Definitions

  • the present invention relates to the field of smart card technologies, and in particular, to a smart card capable of running a JAVA card program, a control method thereof, and a computer readable storage medium.
  • the JAVA card is a smart card that can run the JACard applet (JavaCard Applet). Using the platform independence of the JAVA language, the idea of "writing once, running anywhere" of JAVA technology can be realized on the smart card. After several generations of JAVA card technical specifications, the JAVA Card 2.0 specification was released at the end of 1997. This version of the specification defines the specific API (Application Program Interface (application programming interface) interface function, and introduce a JAVA card virtual machine that is much smaller than the JAVA card virtual machine, but also meets the basic characteristics of the JAVA language.
  • API Application Program Interface
  • the JAVA card with the virtual machine makes the JAVA card platform and application completely separate.
  • a card with JAVA card platform can download the application after the platform is released.
  • This is a JAVA card has a more convenient advantage than a native language such as C.
  • a JAVA card can adapt to different application scenarios. Without developing multiple versions of COS (Chip Operation System, on-chip operating system).
  • COS Chip Operation System, on-chip operating system.
  • the separation of platforms and applications is achieved through a unified API.
  • the platform layer implements the API function, and the application calls the API interface to implement the function.
  • the existing JAVA card generally only includes a communication interface for smart cartoons, that is, at least one of an ISO7816 interface unit or an NFC (Near Field Communication) interface unit, and is only connected through an ISO7816 interface unit or an NFC interface unit.
  • a communication interface for smart cartoons that is, at least one of an ISO7816 interface unit or an NFC (Near Field Communication) interface unit, and is only connected through an ISO7816 interface unit or an NFC interface unit.
  • an ISO7816 interface unit or an NFC (Near Field Communication) interface unit In the case of a card reader terminal, information interaction and data processing can be performed, which limits the use scenario of the JAVA smart card.
  • the main object of the present invention is to provide a smart card and a control method thereof, and a computer readable storage medium, which are intended to expand the function and use range of the smart card.
  • a smart card control method provided by the present invention is applied to a smart card, and the smart card includes an application module and a main control module, and includes the following steps:
  • the application module receives a command sent by the main control module
  • the application module detects a current command protocol type of a command sent by the main control module
  • the application module executes a command sent by the main control module.
  • the application module includes a Java Card virtual machine
  • the step of the application module receiving the command sent by the main control module includes:
  • the application module receives a command sent by the main control module through the Java Card virtual machine.
  • step of the application module detecting the current command protocol type of the command sent by the main control module includes:
  • the Java card virtual machine records a current command protocol type to cause the application module to detect the current command protocol type of the command sent by the main control module.
  • the application module further includes an applet
  • the step of the application module detecting the current command protocol type of the command sent by the main control module includes:
  • the Java card virtual machine records a current command protocol type
  • the Java Card virtual machine provides an API for obtaining a current command protocol type
  • the applet invokes an API provided by the Java Card virtual machine to obtain a current command protocol type.
  • the step of determining whether the current command protocol type is a preset protocol type includes:
  • the step of the application module responding to and executing the command sent by the main control module includes:
  • the applet executes a command sent by the main control module.
  • main control module and the application module are connected through an I2C or SPI interface.
  • command sent by the main control module includes an APDU command.
  • the preset protocol type is a communication protocol of a current APDU transmission channel between the main control module and the application module.
  • the method further includes:
  • the main control module generates a corresponding command in response to the user's input and sends the command to the application module.
  • the smart card includes a UI interface
  • the step of the main control module responding to the user's input, generating the corresponding command, and sending the command to the application module includes:
  • the main control module receives a user UI operation instruction through the UI interface, and parses the operation command to generate the command;
  • the smart card includes an IO interface
  • the step of the main control module responding to the user's input, generating the corresponding command, and sending the command to the application module includes:
  • the main control module receives an instruction sent by the host computer through the IO interface, and parses the IO protocol, acquires an input of the user, and generates the command;
  • the IO interface is a Bluetooth communication interface.
  • the application module is disposed in a smart card security chip, and the main control module is disposed in the microcontroller.
  • the invention also provides a smart card, comprising a storage module, a main control module and a computer program stored on the storage module and operable on the main control module, wherein the main control module implements the control of the smart card when the computer program is executed The steps of the method.
  • it also includes a 7816 interface or an NFC interface for performing normal smart card communication functions.
  • the present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of the above-described method of controlling a smart card.
  • the application module performs data interaction with the main control module, and the application module detects a current command protocol type of the command sent by the main control module, and Determining whether the current command protocol type is a preset protocol type; and when determining that the current command protocol type is a preset protocol type, the application module responds to and executes the command sent by the main control module.
  • the application module can determine whether the default protocol type is met by obtaining the current command protocol type, which is equivalent to establishing a direct communication channel between the application module and the main control module, thereby facilitating the application module to use the corresponding application. Handle the corresponding function.
  • the smart card does not need to be connected to a card reading device such as a card reader, which expands the scope of use of the smart card; for example, the user selects the balance function by the user, and the MCU organizes the inquiry of the balance command to obtain the balance and displays it to the user.
  • a card reading device such as a card reader
  • FIG. 1 is a schematic structural diagram of a module of a smart card according to a first embodiment of the present invention
  • FIG. 2 is a flowchart of a method for controlling a smart card in FIG. 1 according to a first embodiment of the present invention
  • FIG. 3 is a flowchart of a method for controlling a smart card in FIG. 1 according to a second embodiment of the present invention
  • step S22 is a sub-flow chart of step S22 in the second embodiment of the present invention.
  • FIG. 5 is a flowchart of a method for controlling a smart card in FIG. 1 according to a third embodiment of the present invention.
  • FIG. 1 is a schematic structural diagram of a module of a smart card 100 according to a first embodiment of the present invention
  • FIG. 2 is a flowchart of a method for controlling a method 200 of the smart card 100 of FIG.
  • the smart card 100 is a Java card that can run a Java Card Applet (JavaCard Applet).
  • the smart card 100 includes a security chip 20 and a microcontroller (Micro Controller Unit (MCU).
  • the microcontroller is provided with a microcontroller.
  • An application module 21 is run on the security chip 20.
  • the smart card 100 further includes a peripheral device 30 connected to the main control module 10, an IO interface 41 connected to the main control module 10, and a UI interface 42.
  • the application module 21 is configured to receive a data unit according to an application protocol (Application)
  • the Protocol Data Unit (APDU) command performs the corresponding operation and generates the corresponding processing result.
  • Application Application
  • APDU Protocol Data Unit
  • the smart card 100 may further include an international smart card 7816 communication interface or a near field communication (NFC) interface.
  • the smart card 100 can communicate with a card reader (not shown) through the 7816 interface or the NFC interface, receive a control command sent by the card reader, and send a corresponding APDU command to the application module 21 according to the control command.
  • the application module 21 performs a corresponding operation according to the received APDU command, thereby implementing a corresponding function.
  • the peripheral device 30 can include an input device (not labeled) and an output device (not labeled).
  • the input device is configured to respond to a control command input by a user and send the control command to the main control module 10, wherein the input device may be a button, a keyboard, or the like.
  • the output device is configured to output corresponding content according to the control of the main control module 10.
  • the output device may be a peripheral device having an output function of sound, light, etc., such as a display screen or an indicator light.
  • the IO interface 41 is in communication with the main control module 41, and the IO interface 41 is configured to receive a command sent by the host computer and transmit it to the main control module 10.
  • the IO interface 41 can be a Bluetooth communication interface.
  • the UI interface 42 is configured to receive a user UI operation command, and parse the operation command and transmit it to the main control module 10.
  • the smart card control method 200 includes the following steps:
  • step S10 the application module receives the command sent by the main control module.
  • the main control module 10 may generate an APDU command according to the preset control protocol according to the received control command, and send an APDU command including the control command to the application module through a corresponding APDU transmission channel. twenty one.
  • the control instruction may be input by the user through the peripheral device 30 (input device), input through the UI interface 42, or may be sent through the IO interface 41.
  • Step S20 the application module detects a current command protocol type of the command sent by the main control module.
  • Step S30 Determine whether the current command protocol type is a preset protocol type.
  • the application module 21 determines different response modes by detecting whether the current command protocol type is a preset protocol type.
  • the preset protocol type may correspond to a communication protocol of a current APDU transmission channel between the main control module 10 and the application module 21, and may determine the current APDU by detecting whether the current command protocol type is a preset protocol type.
  • the manner of the type of the transmission channel may determine the transmission source of the APDU command, and determine whether the APDU command is sent by the main control module 10 or the smart card communication interface connected to the application module 21, so that the selection is different according to different transmission sources. The way to respond.
  • Step S40 When it is determined that the current command protocol type is a preset protocol type, the application module responds to and executes the command sent by the main control module.
  • the current command protocol type is a preset protocol type
  • the current command protocol type is determined as a communication protocol of a current APDU transmission channel between the main control module 10 and the application module 21
  • the application module 21 responds to and executes the command sent by the main control module.
  • the main control module 10 interacts with the user through the peripheral device 30, the UI interface 42 or the IO interface 41, and accepts a control command input by the user;
  • the application module detects a current command protocol type of the command sent by the main control module, and determines whether the current command protocol type is a preset protocol type; when determining that the current command protocol type is a preset protocol type, The application module responds to and executes a command sent by the main control module.
  • the application module 21 can determine whether the current protocol protocol type is consistent with the preset protocol type, and is equivalent to establishing a direct communication channel between the application module 21 and the main control module 10, thereby facilitating the application module 21 to invoke the corresponding The app to handle the corresponding functionality.
  • the smart card does not need to be connected to a card reading device such as a card reader, and the scope of use of the smart card 100 is expanded; for example, the user selects a balance check function, and the MCU organizes a query for a balance command to obtain a balance and display it to the user.
  • FIG. 3 and FIG. 4 are flowcharts of a method for controlling a smart card in a second embodiment of the present invention.
  • the application module 21 includes a Java Card virtual machine 22 for defining and normalizing different API interface functions; the API interface provided by the Java Card Virtual Machine 22 can be used to detect the Current command protocol type.
  • step S12 may include: the application module receiving, by the Java card virtual machine, a command sent by the main control module;
  • Step S22 may include: the Java card virtual machine recording a current command protocol type, so that the application module detects the current command protocol type of the command sent by the main control module.
  • the Java card virtual machine 22 can extend the APDU.getProtocol interface defined in the standard specification, and add a custom command protocol based on this.
  • the application module 21 may further include an applet. twenty three;
  • the step 22 may specifically include:
  • Step 221 The Java card virtual machine records a current command protocol type.
  • Step 222 The Java Card virtual machine provides an API for acquiring a current command protocol type.
  • Step 223 the applet invokes an API provided by the Java card virtual machine to obtain a current command protocol type.
  • Step S32 may include: determining, by the applet 23, whether the current command protocol type is a preset protocol type;
  • Step S42 may include: when determining that the current command protocol type is a preset protocol type, the applet 23 executing the command sent by the main control module.
  • the applet 23 in the application module 21 calls the API interface provided by the Java card virtual machine module 22 to acquire the current command protocol type, so that the application module 21 detects the command sent by the main control module 10. Current command protocol type.
  • the main control module 10 and the application module 21 are connected by an I2C or SPI interface.
  • FIG. 5 is a flowchart of a method for controlling a smart card in a third embodiment of the present invention, in which steps S10 to S40 and the first method of the smart card control method 203 in the third embodiment are performed.
  • the step 10 includes:
  • step S00 the main control module generates a corresponding command in response to the user's input, and sends the command to the application module.
  • the smart card 100 can receive a control command through the IO interface 41, the UI interface 42, or the peripheral device 30, and the main control module 10 generates a corresponding command in response to the user's input. And send the command to the application module 21.
  • the main control module 10 may include a UI interface 42;
  • the step S00 may include:
  • Step S01 the main control module receives a user UI operation command through the UI interface, and parses the operation command to generate the command;
  • Step S02 the command is sent to the application module.
  • the main control module 10 may include an IO interface 41;
  • the step S00 may include:
  • Step S03 the main control module receives the command sent by the host computer through the IO interface, and parses the command sent by the host computer to acquire the input of the user, and generates the command;
  • step S04 the command is sent to the application module.
  • the IO interface 41 can be a Bluetooth communication interface.
  • the smart card 100 includes a storage module 50 and a computer program stored on the storage module 50 and operable on the main control module 10, the main control module 10 executes
  • the computer program implements the steps of the control method of the smart card 100 described in any of the above embodiments.
  • Step S10 the application module 21 receives the command sent by the main control module 10;
  • Step S20 the application module 21 detects a current command protocol type of the command sent by the main control module 10;
  • Step S30 Determine whether the current command protocol type is a preset protocol type.
  • Step S40 The application module 21 responds to and executes the command sent by the main control module 10 when determining that the current command protocol type is a preset protocol type.
  • the main control module 10 interacts with the user through the peripheral device 30, the UI interface 42 or the IO interface 41, and accepts a control command input by the user; the application module detects the The current command protocol type of the command sent by the main control module, and determining whether the current command protocol type is a preset protocol type; when determining that the current command protocol type is a preset protocol type, the application module responds and Execute the command sent by the main control module.
  • the application module 21 can determine whether the current protocol protocol type is consistent with the preset protocol type, and is equivalent to establishing a direct communication channel between the application module 21 and the main control module 10, thereby facilitating the application module 21 to invoke the corresponding The app to handle the corresponding functionality.
  • the smart card does not need to be connected to a card reading device such as a card reader, and the scope of use of the smart card 100 is expanded; for example, the user selects a balance check function, and the MCU organizes a query for a balance command to obtain a balance and display it to the user.
  • the application module 21 includes a Java Card virtual machine 22 for defining and normalizing different API interface functions; the current command protocol type can be recorded by calling an API interface provided by the Java Card Virtual Machine 22.
  • the step S12 may include: the application module receiving, by the Java card virtual machine, a command sent by the main control module;
  • the step S22 may include: the Java card virtual machine recording a current command protocol type, so that the application module detects the current command protocol type of the command sent by the main control module.
  • the Java card virtual machine 22 can extend the APDU.getProtocol interface defined in the standard specification, and add a custom command protocol based on this.
  • the application module 21 may further include an Applet 23;
  • the step 22 may specifically include:
  • Step 221 the current command protocol type recorded by the Java card virtual machine
  • Step 222 The Java Card virtual machine provides an API for acquiring a current command protocol type.
  • Step 223 the applet invokes an API provided by the Java card virtual machine to obtain a current command protocol type.
  • Step S32 may include: the applet 23 acquires a current command protocol type according to an API provided by the Java card virtual machine, and determines whether the current command protocol type is a preset protocol type; and the step S42 may include: determining the current When the command protocol type is a preset protocol type, the applet 23 responds and executes the command sent by the main control module.
  • the applet 23 in the application module 21 calls the API interface provided by the Java card virtual machine module 22 to acquire the current command protocol type, so that the application module 21 detects the command sent by the main control module 10. Current command protocol type.
  • the application module 21 of the main control module 10 is connected through an I2C or SPI interface.
  • the method includes:
  • step S00 the main control module generates a corresponding command in response to the user's input, and sends the command to the application module.
  • the main control module 10 may include a UI interface 42;
  • the step S00 may include:
  • Step S01 the main control module receives a user UI operation command through the UI interface, and parses the operation command to generate the command;
  • Step S02 the command is sent to the application module.
  • the main control module 10 may include an IO interface 41;
  • the step S00 may include:
  • Step S03 the main control module receives the command sent by the host computer through the IO interface, and parses the IO protocol, acquires the input of the user, and generates the command;
  • step S04 the command is sent to the application module.
  • the IO interface 41 can be a Bluetooth communication interface.
  • the smart card 100 further includes a 7816 interface or an NFC interface for performing a normal smart card communication function.
  • the smart card 100 can communicate with a card reader (not shown) through the 7816 interface or the NFC interface, receive a control command sent by the card reader, and send a corresponding APDU command to the application module 21 according to the control command.
  • the application module 21 performs a corresponding operation according to the received APDU command, thereby implementing a corresponding function.
  • the present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of a method of controlling a smart card in any of the above embodiments.
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal (which may be a cell phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Microelectronics & Electronic Packaging (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Stored Programmes (AREA)

Abstract

A smart card (100), a control method (200) thereof, and a computer readable storage medium. The method comprises the following steps: an application module (21) receives a command sent by a main control module (10) (S10); the application module (21) detects the current command protocol type of the command sent by the main control module (10) (S20); determine whether the current command protocol type is a preset protocol type (S30); if it is determined that the current command protocol type is the preset protocol type, the application module (21) responds to and executes the command sent by the main control module (20) (S40). According to the smart card (100), a card reading device such as a card reader is not needed for connection, and the application range of the smart card (100) is expanded.

Description

智能卡及其控制方法、计算机可读存储介质Smart card and control method thereof, computer readable storage medium 技术领域Technical field
本发明涉及智能卡技术领域,尤其涉及一种可以运行JAVA卡程序的智能卡及其控制方法、计算机可读存储介质。The present invention relates to the field of smart card technologies, and in particular, to a smart card capable of running a JAVA card program, a control method thereof, and a computer readable storage medium.
背景技术Background technique
在JAVA卡是一种可以运行JAVA卡程序(JavaCard Applet)的智能卡,利用JAVA语言的平台无关性,使得JAVA技术“一次编写,随处运行”的思想在智能卡上得以实现。经过数代JAVA卡技术规范的发展,1997年底发布了JAVA卡2.0规范,此版规范定义了具体的API (Application Program Interface,应用程序编程接口)接口函数,并引入一个比JAVA卡虚拟机小得多、但同样满足JAVA语言基本特性的JAVA卡虚拟机。The JAVA card is a smart card that can run the JACard applet (JavaCard Applet). Using the platform independence of the JAVA language, the idea of "writing once, running anywhere" of JAVA technology can be realized on the smart card. After several generations of JAVA card technical specifications, the JAVA Card 2.0 specification was released at the end of 1997. This version of the specification defines the specific API (Application Program Interface (application programming interface) interface function, and introduce a JAVA card virtual machine that is much smaller than the JAVA card virtual machine, but also meets the basic characteristics of the JAVA language.
拥有虚拟机的JAVA卡,使得JAVA卡平台和应用完全分离。一张搭载JAVA卡平台的卡片,能够在平台发行后再下载应用,这是JAVA卡比使用本地语言如C语言的Native卡有着更为便利的优势,一张JAVA卡能够适应不同的应用场景,而不需要开发多个版本的COS (Chip Operation System,片上操作系统)。而平台和应用的分离,是通过统一的API 来实现的。想要制定出一个版本的JAVA卡API国际标准,平台层实现API函数,而应用调用API接口来实现功能。The JAVA card with the virtual machine makes the JAVA card platform and application completely separate. A card with JAVA card platform can download the application after the platform is released. This is a JAVA card has a more convenient advantage than a native language such as C. A JAVA card can adapt to different application scenarios. Without developing multiple versions of COS (Chip Operation System, on-chip operating system). The separation of platforms and applications is achieved through a unified API. To develop a version of the JAVA card API international standard, the platform layer implements the API function, and the application calls the API interface to implement the function.
但是,现有的JAVA卡一般只包含智能卡通用的通信接口,即ISO7816接口单元或者NFC(Near Field Communication,近场通信)接口单元中的至少一个,只有在通过ISO7816接口单元或者NFC接口单元连接有读卡器终端的情况下,才能进行信息的交互和数据的处理,限制了JAVA智能卡的使用场景。However, the existing JAVA card generally only includes a communication interface for smart cartoons, that is, at least one of an ISO7816 interface unit or an NFC (Near Field Communication) interface unit, and is only connected through an ISO7816 interface unit or an NFC interface unit. In the case of a card reader terminal, information interaction and data processing can be performed, which limits the use scenario of the JAVA smart card.
技术问题technical problem
本发明的主要目的在于提供一种智能卡及其控制方法、以及计算机可读存储介质,旨在扩展了智能卡的功能和使用范围。The main object of the present invention is to provide a smart card and a control method thereof, and a computer readable storage medium, which are intended to expand the function and use range of the smart card.
技术解决方案Technical solution
为实现上述目的,本发明提供的一种智能卡的控制方法,应用于智能卡,所述智能卡包括应用程序模块以及主控制模块,包括如下步骤:To achieve the above objective, a smart card control method provided by the present invention is applied to a smart card, and the smart card includes an application module and a main control module, and includes the following steps:
所述应用程序模块接收所述主控制模块发送的命令;The application module receives a command sent by the main control module;
所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型;The application module detects a current command protocol type of a command sent by the main control module;
判断所述当前命令协议类型是否为预设协议类型;Determining whether the current command protocol type is a preset protocol type;
在确定所述当前命令协议类型为所述预设协议类型时,所述应用程序模块执行所述主控制模块发送的命令。When it is determined that the current command protocol type is the preset protocol type, the application module executes a command sent by the main control module.
进一步地,所述应用程序模块包括Java卡虚拟机;Further, the application module includes a Java Card virtual machine;
所述应用程序模块接收主控制模块发送的命令的步骤包括:The step of the application module receiving the command sent by the main control module includes:
所述应用程序模块通过所述Java卡虚拟机接收主控制模块发送的命令。The application module receives a command sent by the main control module through the Java Card virtual machine.
进一步地,所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型的步骤包括:Further, the step of the application module detecting the current command protocol type of the command sent by the main control module includes:
所述Java卡虚拟机记录当前命令协议类型,以使所述应用程序模块检测到所述主控制模块发送的命令的所述当前命令协议类型。The Java card virtual machine records a current command protocol type to cause the application module to detect the current command protocol type of the command sent by the main control module.
进一步地,所述应用程序模块还包括Applet;Further, the application module further includes an applet;
所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型的步骤包括:The step of the application module detecting the current command protocol type of the command sent by the main control module includes:
所述Java卡虚拟机记录当前命令协议类型;The Java card virtual machine records a current command protocol type;
所述Java卡虚拟机提供获取当前命令协议类型的API;The Java Card virtual machine provides an API for obtaining a current command protocol type;
所述Applet调用所述Java卡虚拟机提供的API获取当前命令协议类型。The applet invokes an API provided by the Java Card virtual machine to obtain a current command protocol type.
进一步地,所述判断所述当前命令协议类型是否为预设协议类型的步骤包括:Further, the step of determining whether the current command protocol type is a preset protocol type includes:
所述Applet判断所述当前命令协议类型是否为预设协议类型;Determining, by the applet, whether the current command protocol type is a preset protocol type;
所述在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块响应并执行所述主控制模块发送的命令的步骤包括:When the determining that the current command protocol type is a preset protocol type, the step of the application module responding to and executing the command sent by the main control module includes:
在所述Applet确定所述当前命令协议类型为预设协议类型时,所述Applet执行所述主控制模块发送的命令。When the applet determines that the current command protocol type is a preset protocol type, the applet executes a command sent by the main control module.
进一步地,所述主控制模块与所述应用程序模块通过I2C或者SPI接口连接。Further, the main control module and the application module are connected through an I2C or SPI interface.
进一步地,所述主控制模块发送的命令包括APDU命令。Further, the command sent by the main control module includes an APDU command.
进一步地,所述预设协议类型为所述主控制模块与所述应用程序模块之间的当前APDU传输通道的通信协议。Further, the preset protocol type is a communication protocol of a current APDU transmission channel between the main control module and the application module.
进一步地,所述应用程序模块接收主控制模块发送的命令的步骤之前还包括:Further, before the step of the application module receiving the command sent by the main control module, the method further includes:
所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块。The main control module generates a corresponding command in response to the user's input and sends the command to the application module.
进一步地,所述智能卡包括UI接口;Further, the smart card includes a UI interface;
所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块的步骤包括:The step of the main control module responding to the user's input, generating the corresponding command, and sending the command to the application module includes:
所述主控制模块通过所述UI接口,接收用户UI操作指令,并解析该操作命令,产生所述命令;The main control module receives a user UI operation instruction through the UI interface, and parses the operation command to generate the command;
将所述命令发送至应用程序模块。Send the command to the application module.
进一步地,所述智能卡包括IO接口;Further, the smart card includes an IO interface;
所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块的步骤包括:The step of the main control module responding to the user's input, generating the corresponding command, and sending the command to the application module includes:
所述主控制模块通过所述IO接口接收上位机发送的指令,并解析该IO协议,获取用户的输入,产生所述命令;The main control module receives an instruction sent by the host computer through the IO interface, and parses the IO protocol, acquires an input of the user, and generates the command;
将所述命令发送至应用程序模块。Send the command to the application module.
进一步地,所述IO接口是蓝牙通信接口。Further, the IO interface is a Bluetooth communication interface.
进一步地,所述应用程序模块设于智能卡安全芯片中,所述主控制模块设于微控制器中。Further, the application module is disposed in a smart card security chip, and the main control module is disposed in the microcontroller.
本发明还提供一种智能卡,包括存储模块、主控制模块及存储在存储模块上并可在主控制模块上运行的计算机程序,所述主控制模块执行所述计算机程序时实现上述的智能卡的控制方法的步骤。The invention also provides a smart card, comprising a storage module, a main control module and a computer program stored on the storage module and operable on the main control module, wherein the main control module implements the control of the smart card when the computer program is executed The steps of the method.
进一步地,还包括7816接口或NFC接口,用于完成正常的智能卡通信功能Further, it also includes a 7816 interface or an NFC interface for performing normal smart card communication functions.
本发明还提供一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述的智能卡的控制方法的步骤。The present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of the above-described method of controlling a smart card.
有益效果Beneficial effect
本发明中的智能卡及其控制方法中,智能卡上电后,所述应用程序模块与主控制模块进行数据交互,所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型,并判断所述当前命令协议类型是否为预设协议类型;在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块响应并执行所述主控制模块发送的命令。应用程序模块可以通过获取当前命令协议类型来判断是否符合预设协议类型,相当于在应用程序模块与主控制模块之间建立了一个直接地通信通道,从而便于应用程序模块用相应的应用程序来处理对应功能。此过程智能卡不需要连接读卡器等读卡设备,扩展了智能卡的使用范围;比如,用户通过选择查询余额的功能,MCU组织查询余额命令,获取余额后,显示给用户。In the smart card and the control method thereof, after the smart card is powered on, the application module performs data interaction with the main control module, and the application module detects a current command protocol type of the command sent by the main control module, and Determining whether the current command protocol type is a preset protocol type; and when determining that the current command protocol type is a preset protocol type, the application module responds to and executes the command sent by the main control module. The application module can determine whether the default protocol type is met by obtaining the current command protocol type, which is equivalent to establishing a direct communication channel between the application module and the main control module, thereby facilitating the application module to use the corresponding application. Handle the corresponding function. In this process, the smart card does not need to be connected to a card reading device such as a card reader, which expands the scope of use of the smart card; for example, the user selects the balance function by the user, and the MCU organizes the inquiry of the balance command to obtain the balance and displays it to the user.
附图说明DRAWINGS
图1为本发明第一实施方式中的智能卡的模块结构示意图;1 is a schematic structural diagram of a module of a smart card according to a first embodiment of the present invention;
图2为本发明第一实施方式中用于图1中的智能卡的控制方法的方法流程图;2 is a flowchart of a method for controlling a smart card in FIG. 1 according to a first embodiment of the present invention;
图3为本发明第二实施方式中用于图1中的智能卡的控制方法的方法流程图;3 is a flowchart of a method for controlling a smart card in FIG. 1 according to a second embodiment of the present invention;
图4为本发明第二实施方式中的步骤S22的子流程图;4 is a sub-flow chart of step S22 in the second embodiment of the present invention;
图5为本发明第三实施方式中用于图1中的智能卡的控制方法的方法流程图。FIG. 5 is a flowchart of a method for controlling a smart card in FIG. 1 according to a third embodiment of the present invention.
本发明的实施方式Embodiments of the invention
应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
在后续的描述中,使用用于表示元件的诸如“模块”、“部件”或“单元”的后缀仅为了有利于本发明的说明,其本身没有特定的意义。因此,“模块”、“部件”或“单元”可以混合地使用。In the following description, the use of suffixes such as "module", "component" or "unit" for indicating an element is merely an explanation for facilitating the present invention, and has no specific meaning per se. Therefore, "module", "component" or "unit" can be used in combination.
请参考图1~2,图1为本发明第一实施方式中的智能卡100的模块结构示意图,图2为图1中智能卡100的控制方法200的方法流程图。1 to 2, FIG. 1 is a schematic structural diagram of a module of a smart card 100 according to a first embodiment of the present invention, and FIG. 2 is a flowchart of a method for controlling a method 200 of the smart card 100 of FIG.
在本实施方式中,所述智能卡100为一种可以运行JAVA卡程序(JavaCard Applet)的Java卡,所述智能卡100包括安全芯片20以及微控制器 (Microcontroller Unit;MCU),微控制器设有主控制模块10。所述安全芯片20上运行有应用程序模块21。所述智能卡100还包括与主控制模块10连接的外设30、与主控制模块10连接的IO接口41以及UI接口42。In this embodiment, the smart card 100 is a Java card that can run a Java Card Applet (JavaCard Applet). The smart card 100 includes a security chip 20 and a microcontroller (Micro Controller Unit (MCU). The microcontroller is provided with a microcontroller. Main control module 10. An application module 21 is run on the security chip 20. The smart card 100 further includes a peripheral device 30 connected to the main control module 10, an IO interface 41 connected to the main control module 10, and a UI interface 42.
所述应用程序模块21用于根据接收到的应用协议数据单元(Application Protocol Data Unit,APDU)命令执行相应的操作,并生成相应的处理结果。The application module 21 is configured to receive a data unit according to an application protocol (Application) The Protocol Data Unit (APDU) command performs the corresponding operation and generates the corresponding processing result.
其中,所述智能卡100还可以包括国际智能卡7816通信接口,或者近场通信(Near Field Communication,NFC)接口。通常智能卡100可以通过该7816接口或者NFC接口与读卡器(图未示出)通信,接收读卡器发送的控制指令,并根据所述控制指令组织相应的APDU命令发送至应用程序模块21,所述应用程序模块21根据接收到的APDU命令执行相应的操作,从而实现相应的功能。The smart card 100 may further include an international smart card 7816 communication interface or a near field communication (NFC) interface. Generally, the smart card 100 can communicate with a card reader (not shown) through the 7816 interface or the NFC interface, receive a control command sent by the card reader, and send a corresponding APDU command to the application module 21 according to the control command. The application module 21 performs a corresponding operation according to the received APDU command, thereby implementing a corresponding function.
所述外设30可以包括输入设备(图未标号)和输出设备(图未标号)。所述输入设备用于响应用户输入的控制指令,并将所述控制指令发送至主控制模块10,其中,所述输入设备可以是按键、键盘等。所述输出设备用于根据主控制模块10的控制输出相应的内容,所述输出设备可以是显示屏、指示灯等具有声、光等输出功能的外设。The peripheral device 30 can include an input device (not labeled) and an output device (not labeled). The input device is configured to respond to a control command input by a user and send the control command to the main control module 10, wherein the input device may be a button, a keyboard, or the like. The output device is configured to output corresponding content according to the control of the main control module 10. The output device may be a peripheral device having an output function of sound, light, etc., such as a display screen or an indicator light.
所述IO接口41与主控制模块41通信,IO接口41用于接收上位机发送的命令,并将其传输到所述主控制模块10。其中,所述IO接口41可以是蓝牙通信接口。The IO interface 41 is in communication with the main control module 41, and the IO interface 41 is configured to receive a command sent by the host computer and transmit it to the main control module 10. The IO interface 41 can be a Bluetooth communication interface.
所述UI接口42用于接收用户UI操作命令,并解析该操作命令,并将其传输到所述主控制模块10。The UI interface 42 is configured to receive a user UI operation command, and parse the operation command and transmit it to the main control module 10.
其中,所述智能卡的控制方法200包括如下步骤:The smart card control method 200 includes the following steps:
步骤S10,应用程序模块接收主控制模块发送的命令。In step S10, the application module receives the command sent by the main control module.
具体的,所述主控制模块10可以根据接收到的控制指令,按照预设的通信协议生成APDU命令,并将包含所述控制指令的APDU命令通过对应的APDU传输通道发送至所述应用程序模块21。其中,所述控制指令可以是用户通过外设30(输入设备)输入的,或者通过所述UI接口42输入的,也可以是通过所述IO接口41发送的。Specifically, the main control module 10 may generate an APDU command according to the preset control protocol according to the received control command, and send an APDU command including the control command to the application module through a corresponding APDU transmission channel. twenty one. The control instruction may be input by the user through the peripheral device 30 (input device), input through the UI interface 42, or may be sent through the IO interface 41.
步骤S20,所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型。Step S20, the application module detects a current command protocol type of the command sent by the main control module.
步骤S30,判断所述当前命令协议类型是否为预设协议类型。Step S30: Determine whether the current command protocol type is a preset protocol type.
具体的,应用程序模块21通过检测当前命令协议类型是否为预设协议类型来确定不同的响应方式。例如,所述预设协议类型可以对应为主控制模块10与所述应用程序模块21之间的当前APDU传输通道的通信协议,可以通过检测当前命令协议类型是否为预设协议类型来确定当前APDU传输通道的类型的方式,可以确定APDU命令的发送来源,判断出APDU命令是主控制模块10所发送的还是与应用程序模块21连接的智能卡通信接口所发送的,从而根据不同的发送来源选择不同的响应方式。Specifically, the application module 21 determines different response modes by detecting whether the current command protocol type is a preset protocol type. For example, the preset protocol type may correspond to a communication protocol of a current APDU transmission channel between the main control module 10 and the application module 21, and may determine the current APDU by detecting whether the current command protocol type is a preset protocol type. The manner of the type of the transmission channel may determine the transmission source of the APDU command, and determine whether the APDU command is sent by the main control module 10 or the smart card communication interface connected to the application module 21, so that the selection is different according to different transmission sources. The way to respond.
步骤S40,在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块响应并执行所述主控制模块发送的命令。Step S40: When it is determined that the current command protocol type is a preset protocol type, the application module responds to and executes the command sent by the main control module.
具体的,当确定所述当前命令协议类型为预设协议类型时,例如,确定所述当前命令协议类型为主控制模块10与所述应用程序模块21之间的当前APDU传输通道的通信协议时,所述应用程序模块21响应并执行所述主控制模块发送的命令。Specifically, when it is determined that the current command protocol type is a preset protocol type, for example, when the current command protocol type is determined as a communication protocol of a current APDU transmission channel between the main control module 10 and the application module 21, The application module 21 responds to and executes the command sent by the main control module.
在本发明第一实施方式的智能卡100的控制方法200中,智能卡100上电后,主控制模块10通过外设30、UI接口42或者IO接口41与用户进行交互,接受用户输入的控制指令;所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型,并判断所述当前命令协议类型是否为预设协议类型;在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块响应并执行所述主控制模块发送的命令。应用程序模块21可以通过获取当前命令协议类型来判断是否符合预设协议类型,相当于在应用程序模块21与主控制模块10之间建立了一个直接地通信通道,从而便于应用程序模块21调用相应的应用程序来处理对应功能。此过程智能卡不需要连接读卡器等读卡设备,扩展了智能卡100的使用范围;比如,用户通过选择查询余额的功能,MCU组织查询余额命令,获取余额后,显示给用户。In the control method 200 of the smart card 100 according to the first embodiment of the present invention, after the smart card 100 is powered on, the main control module 10 interacts with the user through the peripheral device 30, the UI interface 42 or the IO interface 41, and accepts a control command input by the user; The application module detects a current command protocol type of the command sent by the main control module, and determines whether the current command protocol type is a preset protocol type; when determining that the current command protocol type is a preset protocol type, The application module responds to and executes a command sent by the main control module. The application module 21 can determine whether the current protocol protocol type is consistent with the preset protocol type, and is equivalent to establishing a direct communication channel between the application module 21 and the main control module 10, thereby facilitating the application module 21 to invoke the corresponding The app to handle the corresponding functionality. In this process, the smart card does not need to be connected to a card reading device such as a card reader, and the scope of use of the smart card 100 is expanded; for example, the user selects a balance check function, and the MCU organizes a query for a balance command to obtain a balance and display it to the user.
进一步地,请参考图3和4,为本发明第二实施方式中的智能卡的控制方法202的方法流程图。 Further, please refer to FIG. 3 and FIG. 4, which are flowcharts of a method for controlling a smart card in a second embodiment of the present invention.
在该第二实施例中,所述应用程序模块21包括有Java卡虚拟机22,用于定义和规范不同的API接口函数;通过调用所述Java卡虚拟机22提供的API接口可以检测所述当前命令协议类型。In the second embodiment, the application module 21 includes a Java Card virtual machine 22 for defining and normalizing different API interface functions; the API interface provided by the Java Card Virtual Machine 22 can be used to detect the Current command protocol type.
具体的,步骤S12可以包括:所述应用程序模块通过所述Java卡虚拟机接收主控制模块发送的命令;Specifically, step S12 may include: the application module receiving, by the Java card virtual machine, a command sent by the main control module;
步骤S22可以包括:所述Java卡虚拟机记录当前命令协议类型,以使所述应用程序模块检测到所述主控制模块发送的命令的所述当前命令协议类型。Step S22 may include: the Java card virtual machine recording a current command protocol type, so that the application module detects the current command protocol type of the command sent by the main control module.
其中,所述Java卡虚拟机22可以扩展标准规范中所定义的APDU.getProtocol接口,在此基础上增加自定义命令协议。The Java card virtual machine 22 can extend the APDU.getProtocol interface defined in the standard specification, and add a custom command protocol based on this.
优选地,在该第二实施例中,所述应用程序模块21还可以包括Applet 23;Preferably, in the second embodiment, the application module 21 may further include an applet. twenty three;
具体的,所述步骤22可以具体包括:Specifically, the step 22 may specifically include:
步骤221,所述Java卡虚拟机记录当前命令协议类型;Step 221: The Java card virtual machine records a current command protocol type.
步骤222,所述Java卡虚拟机提供获取当前命令协议类型的API;Step 222: The Java Card virtual machine provides an API for acquiring a current command protocol type.
步骤223,所述Applet调用所述Java卡虚拟机提供的API获取当前命令协议类型;Step 223, the applet invokes an API provided by the Java card virtual machine to obtain a current command protocol type.
步骤S32可以包括:所述Applet 23判断所述当前命令协议类型是否为预设协议类型;Step S32 may include: determining, by the applet 23, whether the current command protocol type is a preset protocol type;
步骤S42可以包括:在确定所述当前命令协议类型为预设协议类型时,所述Applet 23执行所述主控制模块发送的命令。Step S42 may include: when determining that the current command protocol type is a preset protocol type, the applet 23 executing the command sent by the main control module.
其中,应用程序模块21中的所述Applet 23调用Java卡虚拟机模块22提供的API接口来获取当前命令协议类型,从而使得所述应用程序模块21检测出所述主控制模块10发送的命令的当前命令协议类型。The applet 23 in the application module 21 calls the API interface provided by the Java card virtual machine module 22 to acquire the current command protocol type, so that the application module 21 detects the command sent by the main control module 10. Current command protocol type.
优选地,在一实施例中,所述主控制模块10和所述应用程序模块21通过I2C或者SPI接口连接。Preferably, in an embodiment, the main control module 10 and the application module 21 are connected by an I2C or SPI interface.
进一步地,请参考图5,为本发明第三实施方式中的智能卡的控制方法203的方法流程图,其中,在第三实施方式中所述智能卡的控制方法203的步骤S10~S40与第一实施方式中相同,在此不再赘述;其不同在于,所述步骤10之前包括:Further, please refer to FIG. 5, which is a flowchart of a method for controlling a smart card in a third embodiment of the present invention, in which steps S10 to S40 and the first method of the smart card control method 203 in the third embodiment are performed. The same is true in the embodiment, and details are not described herein; the difference is that the step 10 includes:
步骤S00,所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块。In step S00, the main control module generates a corresponding command in response to the user's input, and sends the command to the application module.
在本发明第三实施方式的智能卡100的控制方法203中,智能卡100可以通过IO接口41、UI接口42或者外设30接收控制指令,主控制模块10响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块21。In the control method 203 of the smart card 100 according to the third embodiment of the present invention, the smart card 100 can receive a control command through the IO interface 41, the UI interface 42, or the peripheral device 30, and the main control module 10 generates a corresponding command in response to the user's input. And send the command to the application module 21.
可选地,在一实施例中,所述主控制模块10可以包括UI接口42;Optionally, in an embodiment, the main control module 10 may include a UI interface 42;
所述步骤S00可以包括:The step S00 may include:
步骤S01,所述主控制模块通过所述UI接口,接收用户UI操作命令,并解析该操作命令,产生所述命令;Step S01, the main control module receives a user UI operation command through the UI interface, and parses the operation command to generate the command;
步骤S02,将所述命令发送至应用程序模块。Step S02, the command is sent to the application module.
可选地,在另一实施例中,所述主控制模块10可以包括IO接口41;Optionally, in another embodiment, the main control module 10 may include an IO interface 41;
所述步骤S00可以包括:The step S00 may include:
步骤S03,所述主控制模块通过所述IO接口接收上位机发送的命令,并解析该上位机发送的命令,获取用户的输入,产生所述命令;Step S03, the main control module receives the command sent by the host computer through the IO interface, and parses the command sent by the host computer to acquire the input of the user, and generates the command;
步骤S04,将所述命令发送至应用程序模块。In step S04, the command is sent to the application module.
其中,所述IO接口41可以是蓝牙通信接口。The IO interface 41 can be a Bluetooth communication interface.
请一并结合图1~4,在本发明一实施方式中,智能卡100包括存储模块50及存储在存储模块50上并可在主控制模块10上运行的计算机程序,所述主控制模块10执行所述计算机程序时实现上述任一实施方式中所述的智能卡100的控制方法的步骤。1 to 4, in an embodiment of the present invention, the smart card 100 includes a storage module 50 and a computer program stored on the storage module 50 and operable on the main control module 10, the main control module 10 executes The computer program implements the steps of the control method of the smart card 100 described in any of the above embodiments.
具体的,所述主控制模块10执行所述计算机程序时用于实现如下步骤:Specifically, when the main control module 10 executes the computer program, the following steps are implemented:
步骤S10,应用程序模块21接收主控制模块10发送的命令;Step S10, the application module 21 receives the command sent by the main control module 10;
步骤S20,所述应用程序模块21检测所述主控制模块10发送的命令的当前命令协议类型; Step S20, the application module 21 detects a current command protocol type of the command sent by the main control module 10;
步骤S30,判断所述当前命令协议类型是否为预设协议类型。Step S30: Determine whether the current command protocol type is a preset protocol type.
步骤S40,在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块21响应并执行所述主控制模块10发送的命令。Step S40: The application module 21 responds to and executes the command sent by the main control module 10 when determining that the current command protocol type is a preset protocol type.
在本发明中的智能卡100中,智能卡100上电后,主控制模块10通过外设30、UI接口42或者IO接口41与用户进行交互,接受用户输入的控制指令;所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型,并判断所述当前命令协议类型是否为预设协议类型;在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块响应并执行所述主控制模块发送的命令。应用程序模块21可以通过获取当前命令协议类型来判断是否符合预设协议类型,相当于在应用程序模块21与主控制模块10之间建立了一个直接地通信通道,从而便于应用程序模块21调用相应的应用程序来处理对应功能。此过程智能卡不需要连接读卡器等读卡设备,扩展了智能卡100的使用范围;比如,用户通过选择查询余额的功能,MCU组织查询余额命令,获取余额后,显示给用户。In the smart card 100 of the present invention, after the smart card 100 is powered on, the main control module 10 interacts with the user through the peripheral device 30, the UI interface 42 or the IO interface 41, and accepts a control command input by the user; the application module detects the The current command protocol type of the command sent by the main control module, and determining whether the current command protocol type is a preset protocol type; when determining that the current command protocol type is a preset protocol type, the application module responds and Execute the command sent by the main control module. The application module 21 can determine whether the current protocol protocol type is consistent with the preset protocol type, and is equivalent to establishing a direct communication channel between the application module 21 and the main control module 10, thereby facilitating the application module 21 to invoke the corresponding The app to handle the corresponding functionality. In this process, the smart card does not need to be connected to a card reading device such as a card reader, and the scope of use of the smart card 100 is expanded; for example, the user selects a balance check function, and the MCU organizes a query for a balance command to obtain a balance and display it to the user.
进一步地,所述应用程序模块21包括有Java卡虚拟机22,用于定义和规范不同的API接口函数;通过调用所述Java卡虚拟机22提供的API接口可以记录所述当前命令协议类型。Further, the application module 21 includes a Java Card virtual machine 22 for defining and normalizing different API interface functions; the current command protocol type can be recorded by calling an API interface provided by the Java Card Virtual Machine 22.
具体的,所述步骤S12可以包括:所述应用程序模块通过所述Java卡虚拟机接收主控制模块发送的命令;Specifically, the step S12 may include: the application module receiving, by the Java card virtual machine, a command sent by the main control module;
所述步骤S22可以包括:所述Java卡虚拟机记录当前命令协议类型,以使所述应用程序模块检测到所述主控制模块发送的命令的所述当前命令协议类型。The step S22 may include: the Java card virtual machine recording a current command protocol type, so that the application module detects the current command protocol type of the command sent by the main control module.
其中,所述Java卡虚拟机22可以扩展标准规范中所定义的APDU.getProtocol接口,在此基础上增加自定义命令协议。The Java card virtual machine 22 can extend the APDU.getProtocol interface defined in the standard specification, and add a custom command protocol based on this.
进一步地,所述应用程序模块21还可以包括Applet 23;Further, the application module 21 may further include an Applet 23;
具体的,所述步骤22可以具体包括:Specifically, the step 22 may specifically include:
步骤221,所述Java卡虚拟机记录的当前命令协议类型;Step 221, the current command protocol type recorded by the Java card virtual machine;
步骤222,所述Java卡虚拟机提供获取当前命令协议类型的API;Step 222: The Java Card virtual machine provides an API for acquiring a current command protocol type.
步骤223,所述Applet调用所述Java卡虚拟机提供的API获取当前命令协议类型;Step 223, the applet invokes an API provided by the Java card virtual machine to obtain a current command protocol type.
步骤S32可以包括:所述Applet 23根据调用所述Java卡虚拟机提供的API获取当前命令协议类型,判断所述当前命令协议类型是否为预设协议类型;步骤S42可以包括:在确定所述当前命令协议类型为预设协议类型时,所述Applet 23响应并执行所述主控制模块发送的命令。Step S32 may include: the applet 23 acquires a current command protocol type according to an API provided by the Java card virtual machine, and determines whether the current command protocol type is a preset protocol type; and the step S42 may include: determining the current When the command protocol type is a preset protocol type, the applet 23 responds and executes the command sent by the main control module.
其中,应用程序模块21中的所述Applet 23调用Java卡虚拟机模块22提供的API接口来获取当前命令协议类型,从而使得所述应用程序模块21检测出所述主控制模块10发送的命令的当前命令协议类型。The applet 23 in the application module 21 calls the API interface provided by the Java card virtual machine module 22 to acquire the current command protocol type, so that the application module 21 detects the command sent by the main control module 10. Current command protocol type.
优选地,在一实施例中,所述主控制模块10所述应用程序模块21通过I2C或者SPI接口连接。Preferably, in an embodiment, the application module 21 of the main control module 10 is connected through an I2C or SPI interface.
进一步地,所述主控制模块10执行所述计算机程序时:Further, when the main control module 10 executes the computer program:
所述步骤10之前包括:Before the step 10, the method includes:
步骤S00,所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块。In step S00, the main control module generates a corresponding command in response to the user's input, and sends the command to the application module.
可选地,在一实施例中,所述主控制模块10可以包括UI接口42;Optionally, in an embodiment, the main control module 10 may include a UI interface 42;
所述步骤S00可以包括:The step S00 may include:
步骤S01,所述主控制模块通过所述UI接口,接收用户UI操作命令,并解析该操作命令,产生所述命令;Step S01, the main control module receives a user UI operation command through the UI interface, and parses the operation command to generate the command;
步骤S02,将所述命令发送至应用程序模块。Step S02, the command is sent to the application module.
可选地,在另一实施例中,所述主控制模块10可以包括IO接口41;Optionally, in another embodiment, the main control module 10 may include an IO interface 41;
所述步骤S00可以包括:The step S00 may include:
步骤S03,所述主控制模块通过所述IO接口接收上位机发送的命令,并解析该IO协议,获取用户的输入,产生所述命令;Step S03, the main control module receives the command sent by the host computer through the IO interface, and parses the IO protocol, acquires the input of the user, and generates the command;
步骤S04,将所述命令发送至应用程序模块。In step S04, the command is sent to the application module.
可选地,其中,所述IO接口41可以是蓝牙通信接口。Optionally, wherein the IO interface 41 can be a Bluetooth communication interface.
可选地,所述智能卡100还包括7816接口或NFC接口,用于完成正常的智能卡通信功能。通常智能卡100可以通过该7816接口或者NFC接口与读卡器(图未示出)通信,接收读卡器发送的控制指令,并根据所述控制指令组织相应的APDU命令发送至应用程序模块21,所述应用程序模块21根据接收到的APDU命令执行相应的操作,从而实现相应的功能。Optionally, the smart card 100 further includes a 7816 interface or an NFC interface for performing a normal smart card communication function. Generally, the smart card 100 can communicate with a card reader (not shown) through the 7816 interface or the NFC interface, receive a control command sent by the card reader, and send a corresponding APDU command to the application module 21 according to the control command. The application module 21 performs a corresponding operation according to the received APDU command, thereby implementing a corresponding function.
本发明还提供一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述任意一实施方式中的智能卡的控制方法的步骤。The present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of a method of controlling a smart card in any of the above embodiments.
在本说明书的描述中,参考术语“一实施例”、“另一实施例”、“其他实施例”、 或“第一实施例~第X实施例”等的描述意指结合该实施例或示例描述的具体特征、 结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施例或示例。而且,描述的具体特征、结构、材料、方法步骤或者特点可以在任何的一个或多个实施例或示例中以合适的方式结合。In the description of the present specification, the descriptions of the terms "one embodiment", "another embodiment", "other embodiment", or "first embodiment to an Xth embodiment", etc. are meant to be combined with the embodiment or The specific features, structures, materials, or characteristics described in the examples are included in at least one embodiment or example of the invention. In the present specification, the schematic representation of the above terms does not necessarily mean the same embodiment or example. Furthermore, the particular features, structures, materials, method steps or features described may be combined in a suitable manner in any one or more embodiments or examples.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It is to be understood that the term "comprises", "comprising", or any other variants thereof, is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes those elements. It also includes other elements that are not explicitly listed, or elements that are inherent to such a process, method, article, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present invention are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, The optical disc includes a number of instructions for causing a terminal (which may be a cell phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present invention.
上面结合附图对本发明的实施例进行了描述,但是本发明并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本发明的启示下,在不脱离本发明宗旨和权利要求所保护的范围情况下,还可做出很多形式,这些均属于本发明的保护之内。The embodiments of the present invention have been described above with reference to the drawings, but the present invention is not limited to the specific embodiments described above, and the specific embodiments described above are merely illustrative and not restrictive, and those skilled in the art In the light of the present invention, many forms may be made without departing from the spirit and scope of the invention as claimed.

Claims (16)

  1. 一种智能卡的控制方法,由所述智能卡执行,其特征在于,所述智能卡包括应用程序模块以及主控制模块,所述方法包括如下步骤:A smart card control method is performed by the smart card, wherein the smart card includes an application module and a main control module, and the method includes the following steps:
    所述应用程序模块接收所述主控制模块发送的命令;The application module receives a command sent by the main control module;
    所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型;The application module detects a current command protocol type of a command sent by the main control module;
    判断所述当前命令协议类型是否为预设协议类型;Determining whether the current command protocol type is a preset protocol type;
    在确定所述当前命令协议类型为所述预设协议类型时,所述应用程序模块执行所述主控制模块发送的命令。When it is determined that the current command protocol type is the preset protocol type, the application module executes a command sent by the main control module.
  2. 如权利要求1所述的智能卡的控制方法,其特征在于,所述应用程序模块包括Java卡虚拟机;The method for controlling a smart card according to claim 1, wherein the application module comprises a Java Card virtual machine;
    所述应用程序模块接收主控制模块发送的命令的步骤包括:The step of the application module receiving the command sent by the main control module includes:
    所述应用程序模块通过所述Java卡虚拟机接收主控制模块发送的命令。The application module receives a command sent by the main control module through the Java Card virtual machine.
  3. 如权利要求2所述的智能卡的控制方法,其特征在于,所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型的步骤包括:The method for controlling a smart card according to claim 2, wherein the step of detecting, by the application module, the current command protocol type of the command sent by the main control module comprises:
    所述Java卡虚拟机记录当前命令协议类型,以使所述应用程序模块检测到所述主控制模块发送的命令的所述当前命令协议类型。The Java card virtual machine records a current command protocol type to cause the application module to detect the current command protocol type of the command sent by the main control module.
  4. 如权利要求2所述的智能卡的控制方法,其特征在于,所述应用程序模块还包括Applet;The method of controlling a smart card according to claim 2, wherein the application module further comprises an applet;
    所述应用程序模块检测所述主控制模块发送的命令的当前命令协议类型的步骤包括:The step of the application module detecting the current command protocol type of the command sent by the main control module includes:
    所述Java卡虚拟机记录当前命令协议类型;The Java card virtual machine records a current command protocol type;
    所述Java卡虚拟机提供获取当前命令协议类型的API;The Java Card virtual machine provides an API for obtaining a current command protocol type;
    所述Applet调用所述Java卡虚拟机提供的API获取当前命令协议类型。The applet invokes an API provided by the Java Card virtual machine to obtain a current command protocol type.
  5. 如权利要求4所述的智能卡的控制方法,其特征在于,A method of controlling a smart card according to claim 4, wherein
    所述判断所述当前命令协议类型是否为预设协议类型的步骤包括:The step of determining whether the current command protocol type is a preset protocol type includes:
    所述Applet判断所述当前命令协议类型是否为预设协议类型;Determining, by the applet, whether the current command protocol type is a preset protocol type;
    所述在确定所述当前命令协议类型为预设协议类型时,所述应用程序模块响应并执行所述主控制模块发送的命令的步骤包括:When the determining that the current command protocol type is a preset protocol type, the step of the application module responding to and executing the command sent by the main control module includes:
    在所述Applet确定所述当前命令协议类型为预设协议类型时,所述Applet执行所述主控制模块发送的命令。When the applet determines that the current command protocol type is a preset protocol type, the applet executes a command sent by the main control module.
  6. 如权利要求1所述的智能卡的控制方法,其特征在于,所述主控制模块与所述应用程序模块通过I2C或者SPI接口连接。The method of controlling a smart card according to claim 1, wherein the main control module and the application module are connected through an I2C or SPI interface.
  7. 如权利要求1所述的智能卡的控制方法,其特征在于,所述主控制模块发送的命令包括APDU命令。The method for controlling a smart card according to claim 1, wherein the command sent by the main control module comprises an APDU command.
  8. 如权利要求1所述的智能卡的控制方法,其特征在于,所述预设协议类型为所述主控制模块与所述应用程序模块之间的当前APDU传输通道的通信协议。The method for controlling a smart card according to claim 1, wherein the preset protocol type is a communication protocol of a current APDU transmission channel between the main control module and the application module.
  9. 如权利要求1所述的智能卡的控制方法,其特征在于,所述应用程序模块接收主控制模块发送的命令的步骤之前还包括:The method for controlling a smart card according to claim 1, wherein the step of the application module receiving the command sent by the main control module further comprises:
    所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块。The main control module generates a corresponding command in response to the user's input and sends the command to the application module.
  10. 如权利要求6所述的智能卡的控制方法,其特征在于,所述智能卡包括UI接口;The smart card control method according to claim 6, wherein the smart card comprises a UI interface;
    所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块的步骤包括:The step of the main control module responding to the user's input, generating the corresponding command, and sending the command to the application module includes:
    所述主控制模块通过所述UI接口,接收用户UI操作指令,并解析该操作命令,产生所述命令;The main control module receives a user UI operation instruction through the UI interface, and parses the operation command to generate the command;
    将所述命令发送至应用程序模块。Send the command to the application module.
  11. 如权利要求10所述的智能卡的控制方法,其特征在于,所述智能卡包括IO接口;The smart card control method according to claim 10, wherein the smart card comprises an IO interface;
    所述主控制模块响应用户的输入,产生相应的所述命令,并将所述命令发送至应用程序模块的步骤包括:The step of the main control module responding to the user's input, generating the corresponding command, and sending the command to the application module includes:
    所述主控制模块通过所述IO接口接收上位机发送的指令,并解析该IO协议,获取用户的输入,产生所述命令;The main control module receives an instruction sent by the host computer through the IO interface, and parses the IO protocol, acquires an input of the user, and generates the command;
    将所述命令发送至应用程序模块。Send the command to the application module.
  12. 如权利要求11所述的智能卡的控制方法,其特征在于,所述IO接口是蓝牙通信接口。The method of controlling a smart card according to claim 11, wherein the IO interface is a Bluetooth communication interface.
  13. 如权利要求1所述的智能卡的控制方法,其特征在于,所述应用程序模块设于智能卡安全芯片中,所述主控制模块设于微控制器中。The method of controlling a smart card according to claim 1, wherein the application module is disposed in a smart card security chip, and the main control module is disposed in the microcontroller.
  14. 一种智能卡,包括存储模块、主控制模块及存储在存储模块上并可在主控制模块上运行的计算机程序,其特征在于,所述主控制模块执行所述计算机程序时实现如权利要求1至13中任一项所述的智能卡的控制方法的步骤。A smart card comprising a storage module, a main control module, and a computer program stored on the storage module and operable on the main control module, wherein the main control module executes the computer program as claimed in claim 1 The step of the control method of the smart card according to any one of the preceding claims.
  15. 如权利要求14所述的智能卡,其特征在于,还包括7816接口或NFC接口。The smart card of claim 14 further comprising a 7816 interface or an NFC interface.
  16. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该计算机程序被处理器执行时实现如权利要求1至13中任一项所述的智能卡的控制方法的步骤。A computer readable storage medium having stored thereon a computer program, characterized in that the computer program is executed by a processor to implement the steps of the control method of the smart card according to any one of claims 1 to 13.
PCT/CN2018/105143 2017-09-22 2018-09-12 Smart card, control method thereof, and computer readable storage medium WO2019056967A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710871137.8A CN107844821B (en) 2017-09-22 2017-09-22 Smart card, control method thereof, and computer-readable storage medium
CN201710871137.8 2017-09-22

Publications (1)

Publication Number Publication Date
WO2019056967A1 true WO2019056967A1 (en) 2019-03-28

Family

ID=61661860

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/105143 WO2019056967A1 (en) 2017-09-22 2018-09-12 Smart card, control method thereof, and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN107844821B (en)
WO (1) WO2019056967A1 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107844821B (en) * 2017-09-22 2020-09-22 深圳市文鼎创数据科技有限公司 Smart card, control method thereof, and computer-readable storage medium
CN108733487A (en) * 2018-04-19 2018-11-02 深圳市文鼎创数据科技有限公司 The more application management methods of Java card and Java card
CN110719581A (en) * 2018-07-12 2020-01-21 中兴通讯股份有限公司 Control method, device and system for terminal application
CN109240711B (en) * 2018-08-06 2021-12-14 飞天诚信科技股份有限公司 JAVA card and method for downloading application thereof
CN111045750B (en) * 2019-12-19 2023-07-07 飞天诚信科技股份有限公司 Method for automatically matching application programs on multi-application device and electronic device
CN113283898A (en) * 2021-05-27 2021-08-20 武汉天喻信息产业股份有限公司 Smart card scheduling method and device based on multiple operating systems

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101964068A (en) * 2009-07-22 2011-02-02 深圳市江波龙电子有限公司 SD card and method for controlling data access thereof
CN103702451A (en) * 2013-12-17 2014-04-02 中国联合网络通信集团有限公司 Multi-mode control method and multi-mode control device of SIM (subscriber identity model)
CN106446744A (en) * 2016-09-30 2017-02-22 金邦达有限公司 Identification chip circuit board, intelligent card storage apparatus, intelligent card system, and work attendance system
CN107844821A (en) * 2017-09-22 2018-03-27 深圳市文鼎创数据科技有限公司 Smart card and its control method, computer-readable recording medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101964068A (en) * 2009-07-22 2011-02-02 深圳市江波龙电子有限公司 SD card and method for controlling data access thereof
CN103702451A (en) * 2013-12-17 2014-04-02 中国联合网络通信集团有限公司 Multi-mode control method and multi-mode control device of SIM (subscriber identity model)
CN106446744A (en) * 2016-09-30 2017-02-22 金邦达有限公司 Identification chip circuit board, intelligent card storage apparatus, intelligent card system, and work attendance system
CN107844821A (en) * 2017-09-22 2018-03-27 深圳市文鼎创数据科技有限公司 Smart card and its control method, computer-readable recording medium

Also Published As

Publication number Publication date
CN107844821A (en) 2018-03-27
CN107844821B (en) 2020-09-22

Similar Documents

Publication Publication Date Title
WO2019056967A1 (en) Smart card, control method thereof, and computer readable storage medium
CN110651241B (en) Connecting multiple mobile devices to a smart home assistant account
US11803451B2 (en) Application exception recovery
US10963211B2 (en) Electronic device and method for controlling audio path thereof
EP3370144A1 (en) Electronic device for processing user input and method for processing user input
EP3367708B1 (en) Sharing contents
CN109429102B (en) Electronic device and server for displaying applications
KR20170046958A (en) Electronic apparatus and Method for executing function using speech recognition thereof
CN111045969B (en) Accessory device operation with user mobile device
US11838445B2 (en) Electronic apparatus for providing voice recognition control and operating method therefor
EP3499684B1 (en) Electronic device and method for controlling wireless charging
JP2012123591A5 (en)
CN110096370B (en) Control inversion component service model for virtual environments
US20230094172A1 (en) Cross-Device Application Invoking Method and Electronic Device
KR100750117B1 (en) Method and apparatus for setting the class of USB device
US20190324279A1 (en) Electronic device, mobile electronic device, and display device, which are controlled on basis of user gaze and input
KR20160071826A (en) Method for connecting wireless network and electronic device thereof
CN112055424A (en) Electronic device and method for switching electronic device
WO2019061798A1 (en) Display control method and system, and virtual reality device
US20190369825A1 (en) Electronic device and method for providing information related to image to application through input unit
WO2017035819A1 (en) Method for implementing host card emulation, terminal, and data routing method and apparatus
US11010749B2 (en) Payment processing method and electronic device supporting the same
KR20150128256A (en) Server system having virtual android apparatus for interworking between application and real smart device
US11322158B2 (en) Electronic device and communication connection method using voice thereof
US20200218710A1 (en) Electronic device and data management method thereof

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18859538

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18859538

Country of ref document: EP

Kind code of ref document: A1