CN111443991B - Smart card control method and device and smart card - Google Patents

Smart card control method and device and smart card Download PDF

Info

Publication number
CN111443991B
CN111443991B CN202010227343.7A CN202010227343A CN111443991B CN 111443991 B CN111443991 B CN 111443991B CN 202010227343 A CN202010227343 A CN 202010227343A CN 111443991 B CN111443991 B CN 111443991B
Authority
CN
China
Prior art keywords
application
area
preset
virtual machine
type
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
Application number
CN202010227343.7A
Other languages
Chinese (zh)
Other versions
CN111443991A (en
Inventor
底明辉
何碧波
尤洪松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hengbao Co Ltd
Original Assignee
Hengbao Co Ltd
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 Hengbao Co Ltd filed Critical Hengbao Co Ltd
Priority to CN202010227343.7A priority Critical patent/CN111443991B/en
Publication of CN111443991A publication Critical patent/CN111443991A/en
Application granted granted Critical
Publication of CN111443991B publication Critical patent/CN111443991B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Facsimiles In General (AREA)

Abstract

The application provides a smart card control method and device and a smart card, wherein the method comprises the following steps: detecting the type of the target application selected by the application selection instruction when the application selection instruction is received; judging whether a virtual machine exists in a preset first area of the RAM when the type of the target application is a first type; if the virtual machine exists, running the virtual machine in a preset first area; if the virtual machine does not exist, copying codes of the virtual machine into a preset first area, and running the virtual machine in the preset first area. Therefore, the virtual machine can be operated in the RAM, so that the operation speed of the virtual machine is greatly improved, the intelligent card can rapidly operate on the selected target application, the operation efficiency of the first type of application in the intelligent card is improved, and the problem that the operation speed of the application program in the intelligent card is slow is solved to a certain extent.

Description

Smart card control method and device and smart card
Technical Field
The present application relates to the field of intelligent control, and in particular, to a method and apparatus for controlling an intelligent card, and an intelligent card.
Background
Smart cards are a type of card that people often come into contact with in their lives. The smart card is equipped with a CPU (Central Processing Unit ), RAM (Random Access Memory, random access memory), nonvolatile memory, coprocessor (co-processor), I/O (Input/Output) module, etc., and can process a large amount of data by itself without interfering with the operation of the host CPU. The smart card may also filter erroneous data to ease the host CPU burden. The user can complete the usual key, identification, fund settlement, attendance checking and some control operations by using a smart card, such as opening a door, dining, shopping, entertainment, meeting, parking, patrol, office, charging service and other activities.
While some smart cards can run various applets (such as Java programs), a set of running environments, virtual machines and APIs (Application Programming Interface, application programming interfaces) are provided in the smart cards, so that various applets can safely coexist in one smart card. However, because the RAM resources in the smart card are limited, the virtual machines in the smart card are all executed in the nonvolatile memory, which results in slower running speed of the virtual machines and lower running efficiency of the application program in the smart card.
Disclosure of Invention
An object of the embodiment of the application is to provide a smart card control method and device and a smart card, which are used for relieving the problem that the running speed of an application program in the smart card is slow.
The embodiment of the application provides a smart card control method, which comprises the following steps: detecting the type of a target application selected by an application selection instruction when the application selection instruction is received; judging whether a virtual machine exists in a preset first area of the RAM or not when the type of the target application is a first type; if the virtual machine exists, running the virtual machine in the preset first area; if the virtual machine does not exist, copying codes of the virtual machine into the preset first area, and running the virtual machine in the preset first area.
Through the implementation process, when the selected target application is the first type of application, the virtual machine can be operated in the preset first area of the RAM, compared with the traditional smart card control mode, the virtual machine can be operated in the RAM, so that the operation speed of the virtual machine is greatly improved, the smart card can be operated rapidly for the selected target application, the operation efficiency of the first type of application in the smart card is improved, and the problem that the operation speed of an application program in the smart card is slow is solved to a certain extent.
Further, after detecting the type of the target application selected by the application selection instruction, the method further includes: judging whether a virtual machine exists in a preset first area of the RAM or not when the type of the target application is a second type; if the application program exists, the codes of the virtual machines in the preset first area are cleared, the API codes of the second type of application in the preset first area are restored, and the virtual machines are operated in the nonvolatile memory; and if the virtual machine does not exist, running the virtual machine in the nonvolatile memory.
It will be appreciated that in most cases, RAM resources within the smart card are limited, and it is difficult to provide a dedicated area to always store the code of the virtual machine. For this reason, in the embodiment of the present application, it is considered to classify applications in the smart card, and the API code corresponding to the second type of application is stored in the RAM in the first area that is specially divided. Thus, through the implementation process, the following steps can be realized: when the target application selected by the received application selection instruction is the first type application, API codes corresponding to the second type application in the preset first area are not required to be used, and the virtual machine is operated in the preset first area, so that the operation speed of the virtual machine can be improved, the operation efficiency of the target application is improved, and meanwhile, the utilization rate of the RAM is also improved; and when the target application selected by the received application selection instruction is the application of the second type, restoring and storing the API code corresponding to the application of the second type in the first area, and running the virtual machine in the nonvolatile memory, thereby ensuring that the target application can run normally. Therefore, time division multiplexing of a preset first area in the RAM is realized, and the utilization rate of the RAM is improved.
Further, when the code of the virtual machine is copied into the preset first area, the method further includes: and setting a valid mark of the preset first area.
In the implementation process, when the codes of the virtual machine are copied into the preset first area, the effective mark of the preset first area is set, so that whether the codes of the virtual machine exist in the preset first area or not can be effectively marked through the effective mark, and the identification is convenient.
Further, after clearing the codes of the virtual machines in the preset first area and restoring the API codes of the second type of application in the preset first area, the method further includes: clearing the effective mark of the preset first area; the valid flag of the preset first area is a flag set when the code of the virtual machine is copied into the preset first area.
In the implementation process, after the codes of the virtual machines in the preset first area are cleared and the API codes of the second type of application in the preset first area are recovered, the valid mark of the preset first area is cleared, so that the state of the preset first area is conveniently identified.
Further, the determining whether the virtual machine exists in the preset first area of the RAM includes: judging whether the preset first area is provided with the effective mark or not; when the valid mark is set in the preset first area, determining that the virtual machine exists in the preset first area of the RAM; and when the valid mark is not set in the preset first area, determining that the virtual machine does not exist in the preset first area of the RAM.
In the implementation process, by judging whether the preset first area is provided with the valid mark or not, the judgment of whether the virtual machine exists in the preset first area or not can be quickly realized, and the implementation efficiency of the scheme is improved.
Further, the determining whether the virtual machine exists in the preset first area of the RAM includes: acquiring the type of the last application; when the type of the last application is a first type, determining that the virtual machine exists in a preset first area of the RAM; and when the type of the last application is the second type, determining that the virtual machine does not exist in the preset first area of the RAM.
In the implementation process, the determination of whether the virtual machine exists in the preset first area is realized by acquiring the type of the last application and the type of the last application, so that the quick judgment of the state of the preset first area is realized, and the execution efficiency of the scheme is improved.
Further, the method further comprises: and when the smart card is powered on, copying codes of the virtual machine into the preset first area.
It should be understood that, in the embodiment of the present application, for the purpose of RAM utilization, applications commonly used by a user may be preferentially classified into a first type of application and the rest of applications are used as a second type of application, so that RAM resources can be utilized to the greatest extent during the process of using the smart card by the user. In order to further facilitate the use of the user, when the smart card is powered on, the codes of the virtual machine can be copied into the preset first area by default, so that the response speed of the application program when the user uses the smart card under normal conditions is improved.
The embodiment of the application also provides a smart card, which comprises: I/O module, CPU, RAM and nonvolatile memory; the I/O module is used for receiving an application selection instruction; the application selection instruction is used for selecting a target application; the RAM comprises a preset first area; the preset first area is used for placing codes of the virtual machine when the target application is an application of a first type, and placing Application Programming Interface (API) codes of an application of a second type when the target application is an application of the second type; the nonvolatile memory stores codes of the virtual machine; the CPU is used for controlling the virtual machine to run in a preset first area of the RAM when the target application is an application of a first type, and controlling the virtual machine to run in the nonvolatile memory when the target application is an application of a second type.
In the smart card, when the target application is a second type application, presetting an API code of the second type application in a first area, and running a virtual machine in a nonvolatile memory; when the target application is the first type of application, the codes of the virtual machines are placed in the preset first area, and the virtual machines run in the preset first area. Therefore, the smart card can realize time-sharing multiplexing of the RAM according to the target application selected by the received application selection instruction, the running efficiency of the first type of application is improved, and the problem that the running speed of the application program in the smart card is slow is solved to a certain extent.
Further, the codes of the virtual machine are codes written in assembly language.
In the smart card, the codes of the virtual machine are written in the assembly language, so that the code amount of the virtual machine part can be greatly reduced and the running speed can be improved.
Further, the second type of application is a card management application; the first type of application is other than the card management application.
In the above-described smart card, the second type of application is set as the card management application, and other applications than the card management application are set as the first type of application. Therefore, the area where the API codes of the card management application which is not normally used by the user are stored in the RAM is used as the multiplexing area, so that common applications commonly used by various users can enable the virtual machine to run in the RAM, and the application running speed of the intelligent card perceived by the user is improved under most conditions.
Further, the RAM further comprises a preset second area; the preset second area is used for placing the API codes of the first type of application.
In the smart card, the API code for placing the first type of application is set in the RAM, so that when the first type of application runs, the virtual machine and the API run in the RAM, thereby ensuring that the first type of application can run quickly.
The embodiment of the application also provides a smart card control device, which comprises: the device comprises a receiving module, a detecting module, a judging module and a processing module; the receiving module is used for receiving an application selection instruction; the detection module is used for detecting the type of the target application selected by the application selection instruction when the receiving module receives the application selection instruction; the judging module is used for judging whether a virtual machine exists in a preset first area of the RAM or not when the type of the target application is a first type; the processing module is used for running the virtual machine in a preset first area of the RAM when the virtual machine exists in the preset first area; copying codes of the virtual machine into a preset first area of the RAM when the virtual machine does not exist in the preset first area, and running the virtual machine in the preset first area.
Through the implementation structure, the virtual machine can be operated in the RAM, so that the operation speed of the virtual machine is greatly improved, the intelligent card can rapidly operate the first type of application, the operation efficiency of the first type of application in the intelligent card is improved, and the problem that the operation speed of an application program in the intelligent card is slow is solved to a certain extent.
The embodiment of the application also provides a readable storage medium, wherein the readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to realize the smart card control method of any one of the above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic structural diagram of a smart card according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a smart card control method according to an embodiment of the present application;
fig. 3 is a schematic flow chart of a more specific smart card control method according to an embodiment of the present application;
fig. 4 is a schematic diagram of an internal hierarchical structure of a smart card according to an embodiment of the present application;
fig. 5 is a schematic instruction processing flow diagram of a smart card according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a smart card control device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Embodiment one:
referring to fig. 1, in an embodiment of the present application, there is provided a smart card, including: I/O module, CPU, RAM and nonvolatile memory. Wherein:
the I/O module may receive instructions from outside the smart card, such as application selection instructions.
It is to be understood that the nonvolatile memory is a nonvolatile memory, and data stored in the nonvolatile memory can be stored for a long time without current supply and cannot be lost. Thus, in the embodiment of the present application, the code of the virtual machine is stored in the nonvolatile memory. Non-volatile Memory that may be employed in embodiments of the present application include, but are not limited to, flash Memory, ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), electrically erasable programmable Read-Only Memory.
The RAM is an internal memory for directly exchanging data with the CPU, and can be read and written at any time and has high speed, so that if the virtual machine is placed in the RAM for running, the running efficiency of the virtual machine can be improved, and the running speed of the currently running application can be improved. Therefore, in the embodiment of the application, a first area is preset in the RAM, and the first area can be used for storing codes of the virtual machine, so that the virtual machine can be operated in the RAM, and the effect of improving the operation speed of the currently operated application is achieved.
And the CPU, namely the central processing unit, is used for controlling the virtual machine to run according to the application selection instruction received by the I/O module so as to realize the running of the target application selected by the application selection instruction.
It should be noted that, under the condition of sufficient RAM resources, in the embodiment of the present application, the first area may be set to be dedicated to storing codes of virtual machines, so as to improve the running speed of all applications in the smart card as a whole. However, in most practical situations, the RAM resources are limited, so in order to improve the utilization rate of the RAM resources, the problem that the running speed of the application program in the smart card is slow is solved to a certain extent, and in the embodiment of the application, a multiplexing scheme of the RAM resources is provided, which specifically includes the following steps:
in the embodiment of the application, applications in the smart card can be classified into two types. In classifying, engineers may classify applications commonly used by users into a first type of application and applications not commonly used as a second type of application based on statistics or estimates of frequencies that the users will use for different applications. And writing corresponding APIs for the two types of applications respectively, and placing the API codes of the second type of application in the preset first area when the application needs to be used.
In this way, when the target application selected by the application selection instruction received by the I/O module is the application of the first type, the preset API code of the application of the second type in the first area does not need to be called and executed at present, and then the code of the virtual machine can be copied into the first area, so that the virtual machine can run in the RAM. When the target application selected by the application selection instruction received by the I/O module is the application of the second type, the API code of the application of the second type in the preset first area needs to be restored, and the virtual machine is operated in the nonvolatile memory, so as to ensure that the application of the second type can be operated normally.
It should be understood here that, when an application is running, in addition to the virtual machine needing to run the application, the API corresponding to the application is also available. Only when the API corresponding to the application is available, the application may enable the operating system to execute the corresponding command by calling the corresponding API, thereby implementing the corresponding function. Therefore, when the target application is the second type application, it is necessary to ensure that the API code of the second type application is available in the preset first area.
Similarly, in order to ensure that when the target application is the first type of application, the API code of the first type of application is available, in this embodiment of the present application, the API code of the first type of application is built in the smart card outside the first area. In order to ensure the running reliability of the application, in the embodiment of the present application, a second area may be preset in the RAM (where the second area does not overlap with the first area), and the API code of the first type of application is placed in the second area.
It should also be appreciated that, because RAM will lose its memory content when powered down, in embodiments of the present application, the code of the virtual machine, the API code of the first type of application, and the API code of the second type of application all require that there be a backup in non-volatile memory in order to be copied into RAM.
For example, the code of the virtual machine, the API code of the first type of application, and the API code of the second type of application may be backed up within Flash memory.
In this embodiment of the present application, for the purposes of application management and user commonality, the card management application may be set as the second type of application, and applications other than the card management application (i.e. common applications) are used as the first type of application, and the corresponding APIs are specifically configured for the card management application, and the corresponding APIs are constructed for the common applications.
It should be noted that, in the conventional smart card, the applications are not distinguished, but a hybrid compiling manner is adopted to provide a unified API for all applications. However, this approach may have compatibility problems for some applications because the API needs to compromise the card management function and the normal usage requirements of the user (e.g., opening a door, dining, shopping, meeting, parking, patrol, office, etc., typically implemented by different common applications). In the embodiment of the application, the corresponding API is specially configured for the card management application, the corresponding API is built for the common application, and the built API for the common application only needs to be compatible with the normal use requirement of a user, so that the compatibility is better.
In view of limited RAM resources, in the embodiment of the application, codes of the virtual machine can be written in assembly language, so that the code quantity of the virtual machine is reduced, and the running speed of the virtual machine is improved.
It should be noted that, in addition to receiving the application selection instruction, the smart card may also receive some other instructions, such as an application running instruction, etc. during the actual application process. In the embodiment of the application, the receiving of the instruction can be realized through an I/O module. In addition, after the smart card processes the task corresponding to the instruction according to the received instruction, the I/O module may further send the processing result to the corresponding device. Namely, the I/O module provided in the embodiment of the present application is further configured to receive the remaining instructions except the application selection instruction, and send the processing result of the instruction after the instruction processing is completed.
It is also worth noting that when instructions are selected for non-application, such as application running instructions, the CPU of the smart card can also run the instructions directly according to a preset environment, so that the smart card can effectively process various instructions.
It should be noted that the solution provided by the embodiment of the present application may be applied to various smart cards that may install multiple applications, for example, may be applied to Java cards.
According to the smart card provided by the embodiment of the application, when the target application selected by the application selection instruction received by the I/O module is the application of the first type, the code of the virtual machine can be copied into the first area because the API code of the application of the second type is not required to be called and executed at present, so that the virtual machine can run in the RAM. And when the target application selected by the application selection instruction received by the I/O module is the application of the second type, the API code of the application of the second type can be recovered in the preset first area, and the virtual machine is operated in the nonvolatile memory, so that the normal operation of the application of the second type is ensured. Therefore, the smart card can realize time-sharing multiplexing of the RAM according to the target application selected by the received application selection instruction, the running efficiency of the first type of application is improved, and the problem that the running speed of the application program in the smart card is slow is solved to a certain extent.
Embodiment two:
based on the smart card described in the first embodiment, the embodiment of the present application provides a smart card control method, as shown in fig. 2, including:
s201: and detecting the type of the target application selected by the application selection instruction when the application selection instruction is received.
S202: and when the type of the target application is the first type, judging whether a virtual machine exists in a preset first area of the RAM. If so, go to step S203; if not, go to step S204.
S203: and running the virtual machine in a preset first area.
S204: copying codes of the virtual machine into a preset first area, and running the virtual machine in the preset first area.
It should be understood that, in the embodiment of the present application, the card management application may be set as the second type of application, and applications other than the card management application (i.e., the normal application) are used as the first type of application, and the corresponding APIs are specifically configured for the card management application, and are constructed for the normal application.
It should be understood, of course, that the above is only one possible application classification scheme in the embodiments of the present application, and is not representative of the application classification that can only be performed in the manner described above in the embodiments of the present application. Specific classification modes can be set by engineers according to actual needs, and the embodiment of the application is not limited.
Accordingly, referring to fig. 3, on the basis of the process disclosed in fig. 2, the smart card control method may further include:
s205: and when the type of the target application is the second type, judging whether a virtual machine exists in a preset first area of the RAM. If so, go to step S206; otherwise, go to step S207.
S206: and clearing codes of the virtual machines in the preset first area, recovering API codes of the second type of application in the preset first area, and running the virtual machines in the nonvolatile memory.
S207: the virtual machine is run in nonvolatile memory.
It should be understood that, referring to the description in the first embodiment, the code of the virtual machine and the API code of the second type of application are backed up in the nonvolatile memory (e.g., flash memory) of the smart card. Thus, it may be ensured by copying or the like that the code of the virtual machine existing in the preset first area is available or that the API code of the second type of application is available.
In a possible implementation manner of the embodiment of the present application, when the code of the virtual machine is copied into the preset first area, a valid flag of the preset first area may be set. And after the codes of the virtual machines in the preset first area are cleared and the API codes of the second type of application in the preset first area are restored, the valid mark of the preset first area can be cleared. In this way, in the embodiment of the present application, the determination of whether the virtual machine exists in the preset first area of the RAM may be implemented by determining whether the preset first area is provided with the valid flag. Specifically, when the valid mark is set in the preset first area, determining that a virtual machine exists in the preset first area of the RAM; and when the valid mark is not set in the preset first area, determining that no virtual machine exists in the preset first area of the RAM.
Further, it is considered that if the last application is an application of the first type, the virtual machine must have been within the preset first area at the time of the last application run. In contrast, if the previous application is the second type of application, the API code of the second type of application, which is necessarily set in the first area, is preset when the previous application runs. Therefore, in another possible implementation manner of the embodiment of the present application, the determination of whether the virtual machine exists in the preset first area of the RAM may be implemented by not setting the valid flag of the preset first area, but by the type of the last application.
For example, the type of the previous application may be obtained, and then when the type of the previous application is the first type, it is determined that the virtual machine exists in the preset first area of the RAM, and when the type of the previous application is the second type, it is determined that the virtual machine does not exist in the preset first area of the RAM.
It should be noted that, in this embodiment of the present application, in order to facilitate obtaining the type of the last application, a record table may be set in this embodiment of the present application, and from the type flag of the last application recorded in the record table, the flag is updated accordingly when the type of the last application changes, so that the type of the last application can be quickly determined through the type flag in the record table.
It should be appreciated that both of the above-described possible implementations may be employed simultaneously, thereby ensuring reliability of the implementation of the scheme through double verification. It should be noted that when the verification results of the two ways are inconsistent at a certain moment, according to the type of the target application, when the type of the target application is the first type, the content in the preset first area can be cleared, the codes of the virtual machine are copied into the preset first area, and the virtual machine is operated in the preset first area; and when the type of the target application is the second type, the content in the preset first area can be cleared, the API code of the application of the second type in the preset first area is recovered, and the virtual machine is operated in the nonvolatile memory.
In the embodiment of the application, when the applications are classified, applications commonly used by a user are classified into a first type of application, and applications not commonly used are used as a second type of application. Therefore, in order to facilitate the use of the user, when the smart card is powered on, the codes of the virtual machine can be copied into the preset first area by default, so that the response speed of the application program when the user uses the smart card under normal conditions is improved.
It should be noted that, when the determination of whether the virtual machine exists in the preset first area is implemented through the first possible implementation manner, a valid flag of the preset first area needs to be set when the smart card is powered on. When the judgment of whether the virtual machine exists in the preset first area is realized through the second possible implementation manner, the type of the last application needs to be set to be the first type when the smart card is powered on.
It should be understood that each step in the method provided by the embodiment of the present application may be written in the smart card by a program and executed by the CPU of the smart card, so as to implement the method provided by the embodiment of the present application.
In addition, the embodiment of the application also provides a readable storage medium, such as a floppy disk, an optical disk, a hard disk, a flash memory, a usb disk, an SD (Secure Digital Memory Card, secure digital Card) Card, an MMC (Multimedia Card) Card, and the like. Various steps in the method provided by the embodiments of the present application may be written as programs, where the programs may be stored in the readable storage medium, so that the one or more programs are written in the smart card through the readable storage medium, and are executed by the CPU in the smart card, so as to implement the method provided by the embodiments of the present application.
By the intelligent card control method provided by the embodiment of the application, the virtual machine can be operated in the RAM, so that the operation speed of the virtual machine is greatly improved, the intelligent card can be operated rapidly for the selected target application, the operation efficiency of the first type of application in the intelligent card is improved, and the problem that the operation speed of the application program in the intelligent card is slow is solved to a certain extent.
In addition, the use of a first area preset for the RAM is realized in a time-sharing multiplexing mode, and the utilization rate of the RAM is improved.
Embodiment III:
based on the description of the first embodiment and the second embodiment, in this embodiment, in the case where a smart card is a Java card, a smart card control process is taken as an example, and a scheme of the embodiment of the present application is further illustrated.
Referring to fig. 4, the Java card provided in the embodiment of the present application classifies in-card applications into general applications and card management applications.
In the embodiment of the application, firstly, the assembly language is used for writing the codes of the virtual machine, so that the code quantity of the virtual machine is smaller, the execution efficiency is higher, and the virtual machine is convenient to put into the RAM for execution. For convenience of explanation, the nonvolatile memory in this embodiment is implemented by using a Flash memory.
Next, at the compilation stage, the virtual machine code is defined into two execution domains:
VM FLASH : the card management system is positioned in the Flash memory and used for running a card management application;
VM RAM (i.e., first region): in RAM for running common applications.
In the compiling stage, the card management API (the API corresponding to the card management application) is also separated and positioned in the first area, so that the multiplexing of the execution domain of the virtual machine in the RAM area is realized.
In addition, the CARD management API and the JAVA CARD API (API corresponding to the normal application) are respectively linked in different areas of the RAM.
After the above preparation, see fig. 5:
after receiving an instruction from outside the card, it is first determined whether the instruction indicates that a certain application is selected as a target application. If not, ending; if yes, judging whether the target application is a common application.
When the target application is the normal application, judging whether the mark of the last application is the normal application or not. If the last application is normalThe application does not change the mark of the last application and switch the running environment of the virtual machine, and the virtual machine is continuously run in the RAM; if the last application is not the normal application, changing the mark of the last application into the normal application, setting the VM RAM Valid flag to copy code of virtual machine to VM RAM And running the virtual machine in RAM.
And when the target application is not the common application, judging whether the mark of the last application is a card management application or not. If the last application is a card management application, the mark of the last application is not changed, the running environment of the virtual machine is not switched, and the virtual machine is continuously run in the Flash memory; if the last application is not the card management application, changing the mark of the last application into the card management application, and clearing the VM RAM Valid flag, clear VM RAM Code of virtual machine in and resume VM RAM And managing the API by the card in the Flash memory, and running the virtual machine in the Flash memory.
It should be noted that in practical applications, default applications are usually set in Java cards, for example, a communication smart card UICC is a default application, a financial card electronic cash is a default application, and all industrial applications are common applications. Therefore, in this embodiment of the present application, when the Java card is powered on, after the CPU and the operating system of the Java card are initialized, the flag of the previous application may be set to be a normal application, and the VM is located RAM Valid flag to copy code of virtual machine to VM RAM Thereby improving the response speed of the application program when the user uses the smart card in normal cases.
According to the scheme of the embodiment of the application, as the JAVA card runs the common application most of the time, the virtual machine is put into the RAM for execution, and the execution speed of the virtual machine can be greatly improved when the common application is run. According to the scheme, the limited RAM resources in the card are multiplexed by a time-sharing multiplexing method, so that the utilization efficiency of the RAM is improved, and meanwhile, the limited RAM resources of the card are multiplexed by an application classification multiplexing method, so that the operation efficiency of the application is improved. In addition, by writing the virtual machine codes by using assembly language, the running speed is greatly improved and the codes are reduced.
Embodiment four:
based on the same inventive concept, the embodiment of the application also provides a smart card control device. Referring to fig. 6, fig. 6 illustrates a smart card control device 100 corresponding to the method illustrated in fig. 2. It should be appreciated that the specific functions of the smart card control device 100 may be found in the above description, and detailed descriptions thereof are appropriately omitted for the sake of avoiding repetition. The smart card control device 100 includes at least one software functional module that can be stored in memory in the form of software or firmware or cured in the operating system of the smart card control device 100. Specifically:
referring to fig. 6, the smart card control device 100 includes: a receiving module 101, a detecting module 102, a judging module 103 and a processing module 104. Wherein:
the receiving module 101 is configured to receive an application selection instruction.
The detecting module 102 is configured to detect, when the receiving module 101 receives the application selection instruction, a type of the target application selected by the application selection instruction.
And the judging module 103 is configured to judge whether a virtual machine exists in a preset first area of the RAM when the type of the target application is the first type.
The processing module 104 runs the virtual machine in a preset first area when the virtual machine exists in the preset first area of the RAM; when the virtual machine does not exist in the preset first area of the RAM, copying codes of the virtual machine into the preset first area, and running the virtual machine in the preset first area.
In a possible implementation manner of the embodiment of the present application, the determining module 103 is further configured to determine whether a virtual machine exists in a preset first area of the RAM when the type of the target application is the second type. The processing module 104 is further configured to, when a virtual machine exists in a preset first area of the RAM, clear a code of the virtual machine in the preset first area, and restore an API code of a second type of application in the preset first area, and run the virtual machine in the nonvolatile memory; and when the virtual machine does not exist in the preset first area of the RAM, the virtual machine is operated in the nonvolatile memory.
In a possible implementation manner of the embodiment of the present application, the processing module 104 is further configured to set a valid flag of the preset first area when the code of the virtual machine is copied into the preset first area.
In a possible implementation manner of the embodiment of the present application, the processing module 104 is further configured to clear the valid flag of the preset first area after clearing the code of the virtual machine in the preset first area and restoring the API code of the second type of application in the preset first area; the valid flag of the preset first area is a flag set when the code of the virtual machine is copied into the preset first area.
In one possible implementation manner of the embodiment of the present application, the determining module 103 is specifically configured to determine whether the preset first area is provided with a valid flag; when the effective mark is set in the preset first area, determining that a virtual machine exists in the preset first area of the RAM; and when the valid mark is not set in the preset first area, determining that no virtual machine exists in the preset first area of the RAM.
In this embodiment of the present application, the judging module 103 is specifically configured to obtain a type of a previous application; when the type of the last application is the first type, determining that a virtual machine exists in a preset first area of the RAM; and when the type of the last application is the second type, determining that no virtual machine exists in the preset first area of the RAM.
In this embodiment of the present application, the processing module 104 is further configured to copy, when the smart card is powered on, a code of the virtual machine into a preset first area.
It should be understood that, for simplicity of description, the descriptions in the first embodiment are omitted in this embodiment.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
Further, the units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Furthermore, functional modules in various embodiments of the present application may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
Herein, a plurality refers to two or more.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application, and various modifications and variations may be suggested to one skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims (11)

1. A smart card control method, comprising:
detecting the type of a target application selected by an application selection instruction when the application selection instruction is received;
judging whether a virtual machine exists in a preset first area of the RAM when the type of the target application is a first type; if the virtual machine exists, running the virtual machine in the preset first area; if the virtual machine does not exist, copying codes of the virtual machine into the preset first area, and running the virtual machine in the preset first area;
judging whether a virtual machine exists in a preset first area of the RAM or not when the type of the target application is a second type; if the virtual machine exists, the codes of the virtual machines in the preset first area are cleared, the Application Programming Interface (API) codes of the second type of application in the preset first area are recovered, and the virtual machines are operated in a nonvolatile memory; and if the virtual machine does not exist, running the virtual machine in the nonvolatile memory.
2. The smart card control method of claim 1, wherein when copying the code of the virtual machine into the preset first area, the method further comprises: and setting a valid mark of the preset first area.
3. The smart card control method of claim 1, wherein after clearing the code of the virtual machine in the preset first area and restoring the API code of the second type of application in the preset first area, the method further comprises:
clearing the effective mark of the preset first area; the valid flag of the preset first area is a flag set when the code of the virtual machine is copied into the preset first area.
4. The smart card control method of claim 3, wherein determining whether a virtual machine exists in a preset first area of the RAM comprises:
judging whether the preset first area is provided with the effective mark or not;
when the valid mark is set in the preset first area, determining that the virtual machine exists in the preset first area of the RAM;
and when the valid mark is not set in the preset first area, determining that the virtual machine does not exist in the preset first area of the RAM.
5. A method for controlling a smart card according to any one of claims 1 to 3, wherein determining whether a virtual machine exists in a preset first area of the RAM includes:
acquiring the type of the last application;
when the type of the last application is a first type, determining that the virtual machine exists in a preset first area of the RAM;
and when the type of the last application is the second type, determining that the virtual machine does not exist in the preset first area of the RAM.
6. A smart card control method according to any one of claims 1-4, wherein the method further comprises:
and when the smart card is powered on, copying codes of the virtual machine into the preset first area.
7. A smart card, comprising: an input/output I/O module, a central processing unit CPU, a random access memory RAM and a nonvolatile memory;
the I/O module is used for receiving an application selection instruction; the application selection instruction is used for selecting a target application;
the RAM comprises a preset first area; the preset first area is used for placing codes of the virtual machine when the target application is an application of a first type, and placing Application Programming Interface (API) codes of an application of a second type when the target application is an application of the second type;
the nonvolatile memory stores codes of the virtual machine;
the CPU is used for controlling the virtual machine to run in a preset first area of the RAM when the target application is an application of a first type, and controlling the virtual machine to run in the nonvolatile memory when the target application is an application of a second type.
8. The smart card of claim 7, wherein the code of the virtual machine is code written in assembly language.
9. The smart card of claim 7, wherein the second type of application is a card management application; the first type of application is other than the card management application.
10. A smart card according to any one of claims 7-9, wherein the RAM further comprises a pre-set second area;
the preset second area is used for placing the API codes of the first type of application.
11. A smart card control device, comprising: the device comprises a receiving module, a detecting module, a judging module and a processing module;
the receiving module is used for receiving an application selection instruction;
the detection module is used for detecting the type of the target application selected by the application selection instruction when the receiving module receives the application selection instruction;
the judging module is used for judging whether a virtual machine exists in a preset first area of the RAM or not when the type of the target application is a first type; judging whether a virtual machine exists in a preset first area of the RAM or not when the type of the target application is a second type;
the processing module is used for running the virtual machine in a preset first area of the RAM when the type of the target application is a first type and the virtual machine exists in the preset first area; when the type of the target application is a first type and the virtual machine does not exist in a preset first area of the RAM, copying codes of the virtual machine into the preset first area, and running the virtual machine in the preset first area; and when the type of the target application is a second type and a virtual machine exists in a preset first area of the RAM, clearing codes of the virtual machine in the preset first area, and recovering Application Programming Interface (API) codes of the second type application in the preset first area, and running the virtual machine in a nonvolatile memory; and when the type of the target application is the second type and the virtual machine does not exist in the preset first area of the RAM, running the virtual machine in the nonvolatile memory.
CN202010227343.7A 2020-03-26 2020-03-26 Smart card control method and device and smart card Active CN111443991B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010227343.7A CN111443991B (en) 2020-03-26 2020-03-26 Smart card control method and device and smart card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010227343.7A CN111443991B (en) 2020-03-26 2020-03-26 Smart card control method and device and smart card

Publications (2)

Publication Number Publication Date
CN111443991A CN111443991A (en) 2020-07-24
CN111443991B true CN111443991B (en) 2023-06-23

Family

ID=71650868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010227343.7A Active CN111443991B (en) 2020-03-26 2020-03-26 Smart card control method and device and smart card

Country Status (1)

Country Link
CN (1) CN111443991B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114579208B (en) * 2022-05-05 2022-08-26 广州万协通信息技术有限公司 Self-adaptive adjustment execution speed increasing method for Java card
CN115599409B (en) * 2022-11-30 2023-03-21 紫光同芯微电子有限公司 Application program installation method and device of Java card

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008021682A2 (en) * 2006-08-08 2008-02-21 Sandisk Corporation Portable mass storage with virtual machine activation
CN102681866A (en) * 2011-11-22 2012-09-19 飞天诚信科技股份有限公司 Method and device for running Java programs
CN104346132A (en) * 2013-08-08 2015-02-11 上海复旦微电子集团股份有限公司 Control device applied to running of intelligent card virtual machine and intelligent card virtual machine
CN109032960A (en) * 2018-06-29 2018-12-18 北京中电华大电子设计有限责任公司 A kind of dynamic allocation method and data structure of smart card RAM

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008021682A2 (en) * 2006-08-08 2008-02-21 Sandisk Corporation Portable mass storage with virtual machine activation
CN102681866A (en) * 2011-11-22 2012-09-19 飞天诚信科技股份有限公司 Method and device for running Java programs
CN104346132A (en) * 2013-08-08 2015-02-11 上海复旦微电子集团股份有限公司 Control device applied to running of intelligent card virtual machine and intelligent card virtual machine
CN109032960A (en) * 2018-06-29 2018-12-18 北京中电华大电子设计有限责任公司 A kind of dynamic allocation method and data structure of smart card RAM

Also Published As

Publication number Publication date
CN111443991A (en) 2020-07-24

Similar Documents

Publication Publication Date Title
US9075758B2 (en) Removable storage device with transactional operation support and system including same
US9342243B2 (en) Method and electronic apparatus for implementing multi-operating system
CN111443991B (en) Smart card control method and device and smart card
US7721064B1 (en) Memory allocation in memory constrained devices
CN109710317A (en) System start method, device, electronic equipment and storage medium
EP2366152A2 (en) Ruggedized memory device
CN1545657A (en) Computer hard disk data backup and recovery method
CN100573480C (en) A kind of hard disk data protection method and system
CN110489357B (en) Method and system for hiding data on removable storage device
WO2017161795A1 (en) Method and system for processing chronological file
CN106126277A (en) Multi-microprocessor and the upgrade method of external memory system
KR101258589B1 (en) Information storage medium recording data according to journaling file system, method and apparatus of writing/recovering data using journaling file system
WO2022187043A1 (en) Advanced memory tracking for kernel mode drivers
CN105425997A (en) Method for displaying interface after reboot of user terminal and user terminal
CN112199042A (en) Storage space management method, device, chip, equipment and storage medium
CN105279094A (en) NAND Flash operation processing method, NAND Flash operation processing device and logic device
KR100605031B1 (en) A method for upgrading and restoring embeded systems by using usb memory device
CN106557572A (en) A kind of extracting method and system of Android application program file
CN110058938B (en) Memory processing method and device, electronic equipment and readable medium
CN102855162A (en) Data updating method, data updating system and memory
CN103914263A (en) SD card and device and method for accessing SD card
WO2020037982A1 (en) Data deleting method based on fat file, and data storage device and system
RU2235356C2 (en) Device for storing different versions of data sets in separate memory areas and method for refreshing data sets in memory
CN101853193B (en) Data protection restoration method, system and card based on hard disk controller
KR20030060342A (en) Booting method for personal digital assistant

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