CN111443991A - 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
CN111443991A
CN111443991A CN202010227343.7A CN202010227343A CN111443991A CN 111443991 A CN111443991 A CN 111443991A CN 202010227343 A CN202010227343 A CN 202010227343A CN 111443991 A CN111443991 A CN 111443991A
Authority
CN
China
Prior art keywords
application
preset
area
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.)
Granted
Application number
CN202010227343.7A
Other languages
Chinese (zh)
Other versions
CN111443991B (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, a device and a smart card, wherein the method comprises the following steps: when an application selection instruction is received, detecting the type of a target application selected by the application selection instruction; 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; if yes, operating the virtual machine in a preset first area; and if the code does not exist, copying the code of the virtual machine into the preset first area, and operating the virtual machine in the preset first area. Therefore, the virtual machine can be operated in the RAM, so that the operating speed of the virtual machine is greatly increased, the smart card can operate quickly for the selected target application, the operating efficiency of the first type of application in the smart card is increased, and the problem of slow operating speed of the application program in the smart card is solved to a certain extent.

Description

Smart card control method and device and smart card
Technical Field
The application relates to the field of intelligent control, in particular to a smart card control method and device and a smart card.
Background
Smart cards are a type of card that people often touch in life. The smart card is equipped with a CPU (central processing Unit), a RAM (Random Access Memory), a nonvolatile Memory, a Coprocessor, an I/O (Input/Output) module, and the like, and can process a large amount of data without interfering with the operation of the CPU of the host computer. The smart card may also filter out erroneous data to relieve the host CPU of the burden. The user can complete the common key, identity recognition, fund settlement, attendance and certain control operations through one intelligent card, such as various activities of opening doors, dining, shopping, entertainment, meeting, parking, night watching, office work, toll service and the like by using the intelligent card.
Currently, some smart cards can run multiple applets (such as Java programs), and a set of running environment, virtual machine and API (Application Programming Interface) is provided in such smart cards, so that multiple applets can safely coexist in one smart card. However, because the RAM resources in the smart card are limited, the virtual machine in the smart card is executed in the non-volatile memory at present, which results in a slow running speed of the virtual machine and a low running efficiency of the application program in the smart card.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for controlling a smart card, and a smart card, so as to alleviate the problem that an application program runs slowly in the smart card.
The embodiment of the application provides a smart card control method, which comprises the following steps: when an application selection instruction is received, detecting the type of a target application selected by the application selection instruction; 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; if yes, operating the virtual machine in the preset first area; and if the virtual machine does not exist, copying the code of the virtual machine to the preset first area, and operating 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 a traditional smart card control mode, the virtual machine can be operated in the RAM, and therefore the operation speed of the virtual machine is greatly increased, the smart card can operate quickly 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: when the type of the target application is a second type, judging whether a virtual machine exists in a preset first area of the RAM or not; if the application program exists in the first preset region, clearing codes of the virtual machine in the first preset region, recovering API codes of the second type of application in the first preset region, and operating the virtual machine in the nonvolatile memory; and if not, operating the virtual machine in the nonvolatile memory.
It will be appreciated that in most cases the RAM resources within the smart card are limited and it is difficult to provide a dedicated area to store the code of the virtual machine at all times. In this embodiment of the present application, in consideration of classifying applications in the smart card, API codes corresponding to the applications of the second type are placed in the first area, which is specially divided, in the RAM. 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, the API code corresponding to the second type application in the preset first area is not needed 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 increased, the operation efficiency of the target application is improved, and the utilization rate of the RAM is also improved; and when the target application selected by the received application selection instruction is the second type of application, restoring to store the API code corresponding to the second type of application in the preset first area, and operating the virtual machine in the nonvolatile memory, thereby ensuring that the target application can normally operate. Therefore, time-sharing multiplexing of the preset first area in the RAM is realized, and the utilization rate of the RAM is improved.
Further, when copying the code of the virtual machine into the preset first region, the method further includes: and setting an effective mark of the preset first area.
In the implementation process, when the code of the virtual machine is copied to the preset first area, the effective mark of the preset first area is set, so that whether the code of the virtual machine exists in the preset first area can be effectively identified through the effective mark, and the identification is facilitated.
Further, after clearing the code of the virtual machine in the preset first region and restoring the API code of the application of the second type in the preset first region, 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 code of the virtual machine in the preset first area is cleared and the API code of the second type of application in the preset first area is recovered, the valid flag of the preset first area is cleared, so that the state of the preset first area is conveniently identified.
Further, the determining whether a virtual machine exists in a preset first area of the RAM includes: judging whether the valid mark is arranged in the preset first area or not; when the valid flag is set in the preset first area, determining that the virtual machine exists in the preset first area of the RAM; and when the effective 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, whether the virtual machine exists in the preset first area or not can be rapidly judged by judging whether the effective mark is arranged in the preset first area or not, and the execution efficiency of the scheme is improved.
Further, the 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 a second type, determining that the virtual machine does not exist in a preset first area of the RAM.
In the implementation process, the type of the previous application is obtained, and the determination of whether the virtual machine exists in the preset first area is realized through the type of the previous application, so that the state of the preset first area is rapidly judged, and the execution efficiency of the scheme is improved.
Further, the method further comprises: and when the smart card is powered on, copying the code of the virtual machine into the preset first area.
It should be understood that, in the embodiment of the present application, in terms of RAM utilization, the classification of the applications in the smart card preferentially classifies the applications commonly used by the user into the first type of applications, and the rest of the applications are the second type of applications, so that RAM resources can be maximally utilized in 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 code of the virtual machine can be copied to the preset first area by default, so that the response speed of the application program when the user uses the smart card under the normal condition is improved.
An embodiment of the present application further provides a smart card, including: 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 a 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 a second type; the nonvolatile memory is internally provided with codes of the virtual machine; the CPU is used for controlling the virtual machine to operate 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 operate in the nonvolatile memory when the target application is an application of a second type.
In the smart card, when the target application is the second type of application, the API code of the second type of application is placed in the first area in advance, and the virtual machine runs in the nonvolatile memory; when the target application is the first type of application, the code of the virtual machine is placed in the preset first area, and the virtual machine runs in the preset first area. Therefore, the smart card can realize time division 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 of slow running speed of the application program in the smart card is solved to a certain extent.
Further, the code of the virtual machine is a code written in assembly language.
In the above-described smart card, the code of the virtual machine is written in the assembly language, so that the code amount of the virtual machine portion 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 an application 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 applications other than the card management application are set as the first type of application. Therefore, the area, in which the API codes of the card management application which are not normally used by the user are stored in the RAM, can be used as the multiplexing area, so that various common applications commonly used by the user can enable the virtual machine to run in the RAM, and the running speed of the application program of the smart 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 codes used for placing the first type of application are arranged in the RAM, so that when the first type of application runs, the virtual machine and the API run in the RAM, and the first type of application is ensured to run quickly.
The embodiment of the present application further provides a smart card control apparatus, including: the device comprises a receiving module, a detection module, a judgment 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 a Random Access Memory (RAM) or not when the type of the target application is a first type; the processing module 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 a preset first area of the RAM, copying codes of the virtual machine to the preset first area, and operating 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 increased, the smart card can operate quickly for the first type of application, the operation efficiency of the first type of application in the smart card is increased, and the problem of slow operation speed of the application program in the smart card is solved to a certain extent.
Also provided in an embodiment of the present application is a readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement 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 required to be used 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 therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic structural diagram of a smart card provided in an embodiment of the present application;
fig. 2 is a schematic flowchart of a smart card control method according to an embodiment of the present disclosure;
fig. 3 is a flowchart illustrating a more specific smart card control method according to an embodiment of the present application;
fig. 4 is a schematic diagram illustrating an internal hierarchical structure of a smart card according to an embodiment of the present application;
fig. 5 is a schematic view illustrating an instruction processing flow 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.
The first embodiment is as follows:
referring to fig. 1, an embodiment of the present application provides a smart card, including: I/O module, CPU, RAM and nonvolatile memory. Wherein:
the I/O module may receive commands from outside the smart card, such as application selection commands.
It should 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 is not lost. Therefore, in the embodiment of the present application, the code of the virtual machine is stored in the nonvolatile memory. The non-volatile Memory that can be used in the embodiments of the present application includes, but is not limited to, Flash Memory, ROM (Read-Only Memory), EEPROM (Electrically erasable programmable Read-Only Memory).
The RAM is an internal memory that directly exchanges data with the CPU, can be read and written at any time, and is fast in speed, so that if a virtual machine is placed in the RAM for operation, the operation efficiency of the virtual machine can be improved, thereby improving the operation speed of the currently operated application. 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 is operated in the RAM, and the effect of improving the operation speed of the currently operated application is achieved.
The CPU, namely the central processing unit, is used for controlling the running of the virtual machine 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, in the case that the RAM resource is sufficient, the first area may be set to be dedicated to storing the code of the virtual machine in the embodiment of the present application, so as to achieve the improvement of the running speed of all applications in the smart card as a whole. However, in most practical scenarios, the RAM resource is limited, and therefore, in order to improve the utilization rate of the RAM resource and to solve the problem that the running speed of the application program in the smart card is slow to a certain extent, the embodiment of the present application provides a multiplexing scheme of the RAM resource, which specifically includes:
in the embodiment of the application, the applications in the smart card can be classified, and the applications in the smart card can be classified into two types. When classifying, the engineer may classify the applications that are commonly used by the user into a first type of application and the less commonly used applications as a second type of application based on statistics or estimates of the frequency used by the user for the different applications. And then writing corresponding APIs for the two types of applications respectively, and placing the API codes of the second type of application into 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 first type of application, the API code of the second type of application in the preset first region does not actually need to be called to be executed currently, and then the code of the virtual machine may be copied to the first region, so that the virtual machine may run in the RAM. And when the target application selected by the application selection instruction received by the I/O module is the second type of application, the API code of the second type of application in the preset first area needs to be restored, and the virtual machine is run in the nonvolatile memory to ensure that the second type of application can run normally.
It should be understood that, when the application runs, in addition to the virtual machine needing to run the application, an API corresponding to the application is also available. Only when the API corresponding to the application is available, the application can call the corresponding API to enable the operating system to execute the corresponding command, thereby implementing the corresponding function. Therefore, when the target application is the second type application, it is required to ensure that the API code of the second type application in the preset first region is available.
Similarly, in order to ensure that the API code of the first type application is available when the target application is the first type application, in this embodiment of the present application, the API code of the first type application is built inside the smart card outside the first area. In order to ensure the operational reliability of the application, in the embodiment of the present application, a second area (where the second area is not overlapped with the first area) may be preset in the RAM, and the API code of the application of the first type may be placed in the second area.
It should also be understood that, since the RAM will lose its memory content when the power is off, in the embodiment of the present application, the code of the virtual machine, the API code of the first type application, and the API code of the second type application all need to have a backup in the non-volatile memory in order to copy to the RAM.
Illustratively, 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 in Flash memory.
In the embodiment of the application, in consideration of application management and user popularity, the card management application may be set as the application of the second type, and other applications (i.e., common applications) except the card management application may be set as the applications of the first type, and the API used by the card management application is specially configured for the card management application, and the corresponding API is 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, and a uniform API is provided for all the applications. However, in this method, since the API needs to take account of the card management function and the normal use requirements of the user (such as opening a door, dining, shopping, meeting, parking, night watching, working, etc., which are usually implemented by different common applications), some applications may have compatibility problems. In the embodiment of the application, the API which is used correspondingly is specially configured for the card management application, the corresponding API is constructed for the common application, the API constructed for the common application only needs to be compatible with the normal use requirement of a user, and the compatibility is better.
In consideration of the limited RAM resources, in the embodiment of the present application, the code of the virtual machine may be written in assembly language, so that the code amount of the virtual machine is reduced, and the running speed of the virtual machine is increased.
It should be noted that, in the actual application process, the smart card may receive other instructions besides the application selection finger, such as an application running instruction. In the embodiment of the present application, the receiving of the instruction may be implemented by the 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 also send the processing result to the corresponding device. That is, the I/O module provided in the embodiment of the present application is further configured to receive the remaining instructions except the application selection finger, and send the processing result of the instruction after the instruction processing is completed.
It is also worth noting that when a non-application selection instruction such as an application running instruction is selected, the CPU of the smart card can directly run the instruction according to a preset environment, so that the smart card can effectively process each instruction.
It should be noted that the solution provided in the embodiment of the present application can be applied to various smart cards on which a plurality of applications can be installed, for example, to Java cards.
By 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 first type of application, since the API code of the second type of application does not need to be called and executed currently, the code of the virtual machine can be copied to the first area, 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 application of the second type can be normally operated. Therefore, the smart card can realize time division 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 of slow running speed of the application program in the smart card is solved to a certain extent.
Example two:
based on the smart card described in the first embodiment, an embodiment of the present application provides a smart card control method, which is shown in fig. 2 and includes:
s201: and when receiving the application selection instruction, detecting the type of the target application selected by the application selection instruction.
S202: and 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. If yes, go to step S203; if not, go to step S204.
S203: and running the virtual machine in a preset first area.
S204: copying the code of the virtual machine to a preset first area, and operating 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 application, while other applications (i.e., common applications) than the card management application are used as the first type application, and the API used by the card management application is specially configured for the card management application, and the corresponding API is constructed for the common applications.
Of course, it should be understood that the above is only one possible application classification scheme in the embodiments of the present application, and does not represent that the application classification in the embodiments of the present application can only be performed in the above manner. The specific classification manner may be set by an engineer according to actual needs, and is not limited in the embodiment of the present application.
Accordingly, referring to fig. 3, based on the process disclosed in fig. 2, the smart card control method may further include:
s205: and when the type of the target application is a second type, judging whether a virtual machine exists in a preset first area of the RAM. If yes, go to step S206; otherwise, go to step S207.
S206: and clearing codes of the virtual machine in the preset first area, recovering API codes of the second type of application in the preset first area, and operating the virtual machine in the nonvolatile memory.
S207: a virtual machine is run within the non-volatile memory.
It is to be understood that, referring to the description in embodiment one, the code of the virtual machine and the API code of the second type of application are backed up in a non-volatile memory (e.g., Flash memory) of the smart card. Therefore, it can be ensured that the code of the virtual machine or the API code of the second type of application is available in the preset first area by copying or the like.
In a possible implementation manner of the embodiment of the present application, when copying the code of the virtual machine into the preset first area, a valid flag of the preset first area may be set. 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 flag in the preset first area may be cleared. In this way, in the embodiment of the present application, it may be implemented by determining whether the valid flag is set in the preset first area of the RAM. Specifically, when the valid flag is set in the preset first area, it is determined that a virtual machine exists in the preset first area of the RAM; and when the preset first area is not provided with the valid mark, determining that no virtual machine exists in the preset first area of the RAM.
Furthermore, it is considered that if the last application is the first type of application, the virtual machine must be within the preset first region when the last application runs. On the contrary, if the previous application is the second type of application, the API code of the second type of application, which must be 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 also be implemented by a type of the last application, instead of setting the valid flag of the preset first area.
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 previous application, in this embodiment of the present application, a record table may be set, and a type flag of the previous application is recorded in the record table, and when the type of the previous application changes, the flag is updated accordingly, so that the type of the previous application may be quickly determined through the type flag in the record table.
It will be appreciated that both of the above-described possible embodiments may be employed simultaneously, thereby ensuring the reliability of the implementation of the scheme by means of double verification. It should be noted that, when the verification results of the two manners are inconsistent at a certain time, 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 may be cleared, the code of the virtual machine may be copied to the preset first area, and the virtual machine may be run 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 second type of application 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, the applications commonly used by the user are classified into the applications of the first type, and the applications not commonly used are used as the applications of the second type. Therefore, for the convenience of the user, when the smart card is powered on, the code of the virtual machine can be copied to 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 first feasible embodiment is used to determine whether a virtual machine exists in the preset first region, an effective flag for presetting the first region needs to be set when the smart card is powered on. When the second feasible implementation manner is used to determine whether a virtual machine exists in the preset first area, the type of the last application needs to be set as the first type when the smart card is powered on.
It should be understood that, the steps in the method provided by the embodiment of the present application may be written in the smart card through 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, embodiments of the present application further provide 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) Card, an MMC (Multimedia Card) Card, and the like. The steps of the method provided by the embodiment of the present application may be written as programs, and the programs may be stored in the readable storage medium, so that the one or more programs are written into the smart card through the readable storage medium, and are executed by the CPU in the smart card, thereby implementing the method provided by the embodiment 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 increased, the intelligent card can operate quickly for the selected target application, the operation efficiency of the first type of application in the intelligent card is increased, and the problem of slow operation speed of the application program in the intelligent card is solved to a certain extent.
In addition, the use of the preset first area of the RAM is realized in a time-sharing multiplexing mode, and the utilization rate of the RAM is improved.
Example three:
based on the descriptions of the first embodiment and the second embodiment, the present embodiment further exemplifies the scheme of the embodiment of the present application by taking a smart card control process as an example when a smart card is a Java card.
Referring to fig. 4, the Java card provided in the embodiment of the present application divides the in-card application into a general application and a card management application.
In the embodiment of the application, firstly, the codes of the virtual machine are written by using the assembly language, so that the code amount of the virtual machine is smaller, the execution efficiency is higher, and the codes are conveniently put into the RAM for execution. For convenience of illustration, the nonvolatile memory in this embodiment is implemented by a Flash memory.
Then, in the compilation stage, the virtual machine code is defined with the following two execution domains:
VMFLASH: the card management application is positioned in the Flash memory and used for running the card management application;
VMRAM(i.e., first region): located in RAM for running common applications.
In the compiling stage, the card management API (API corresponding to the card management application) is separated out separately and positioned in the first area, and the card management API and the execution domain of the virtual machine in the RAM area are multiplexed.
In addition, a CARD management API and a JAVA CARD API (API corresponding to a general application) are linked to different areas of the RAM, respectively.
After the above preparation is completed, see fig. 5:
after receiving an instruction from outside the card, it is first determined whether the instruction indicates selection of an application as a target application. If not, ending; if yes, judging whether the target application is a common application.
And when the target application is the common application, judging whether the mark of the last application is the common application. If the last application is a common application, the running environment of the virtual machine is not changed and the virtual machine is continuously run in the RAM without changing the mark of the last application or switching the running environment of the virtual machine; if the last application is not the common application, the mark of the last application is changed into the common application, and the VM is setRAMValid flag, copying code of virtual machine to VMRAMAnd running the virtual machine in the RAM.
And when the target application is not the common application, judging whether the mark of the last application is the card management application. If the last application is the card management application, the virtual machine operation environment is not changed or switched, and the virtual machine continues to operate in the Flash memory; if the last application is not the card management application, the mark of the last application is changed into the card management application, and the VM is clearedRAMValid flag, clear VMRAMCode of the virtual machine inside, and resume the VMRAMThe card in the Flash memory manages API and runs a virtual machine in the Flash memory.
It should be noted that, in practical applications, a default application is usually set in the Java card, for example, the UICC of the communication smart card is the default application, and the electronic cash is the default application for the financial cardThese industrial applications are considered to be common applications. Therefore, in the 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 as the normal application, and the VM is locatedRAMValid flag, copying code of virtual machine to VMRAMThereby improving the response speed of the application program when the user uses the smart card under the normal condition.
According to the scheme of the embodiment of the application, as the common application is run on the JAVA card most of time, the virtual machine is placed in the RAM to be executed, and the execution speed of the virtual machine can be greatly improved when the common application is run. According to the scheme of the embodiment of the application, the limited RAM resources in the card are multiplexed by a time-sharing multiplexing method, the use 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 code by using the assembly language, the running speed is greatly improved, and the code is reduced.
Example 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 shows a smart card control apparatus 100 corresponding to the method shown in fig. 2. It should be understood that the specific functions of the smart card control device 100 can be referred to the above description, and the detailed description is omitted here as appropriate to avoid redundancy. The smart card control apparatus 100 includes at least one software functional module that can be stored in a memory in the form of software or firmware or solidified in an operating system of the smart card control apparatus 100. Specifically, the method comprises the following steps:
referring to fig. 6, the smart card control apparatus 100 includes: the device comprises 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 the type of the target application selected by the application selection instruction when the receiving module 101 receives the application selection instruction.
The determining module 103 is 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 first type.
The processing module 104 is configured to run 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 the code of the virtual machine into the preset first area, and operating 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 codes of the virtual machine in the preset first area, recover API codes 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 copying the code of the virtual machine into the preset first area.
In a feasible 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 a feasible implementation manner of the embodiment of the present application, the determining module 103 is specifically configured to determine whether a valid flag is set in a preset first area; 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 preset first area is not provided with the valid mark, determining that no virtual machine exists in the preset first area of the RAM.
In this embodiment of the present application, the determining module 103 is specifically configured to obtain a type of a previous application; when the type of the last application is a 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 a preset first area of the RAM.
In this embodiment, the processing module 104 is further configured to copy the code of the virtual machine into the preset first area when the smart card is powered on.
It should be understood that, for the sake of brevity, the contents described in some embodiments are not repeated 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 ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
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.
In this context, a plurality means two or more.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (12)

1. A smart card control method, comprising:
when an application selection instruction is received, detecting the type of a target application selected by the application selection instruction;
when the type of the target application is a first type, judging whether a virtual machine exists in a preset first area of a Random Access Memory (RAM);
if yes, operating the virtual machine in the preset first area;
and if the virtual machine does not exist, copying the code of the virtual machine to the preset first area, and operating the virtual machine in the preset first area.
2. The smartcard control method according to claim 1, characterized in that after detecting the type of target application selected by the application selection instruction, the method further comprises:
when the type of the target application is a second type, judging whether a virtual machine exists in a preset first area of the RAM or not;
if the second type of application exists in the first preset area, clearing codes of the virtual machine in the first preset area, recovering Application Programming Interface (API) codes of the second type of application in the first preset area, and operating the virtual machine in the nonvolatile memory;
and if not, operating the virtual machine in the nonvolatile memory.
3. 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 an effective mark of the preset first area.
4. The smartcard control method of claim 2, wherein after clearing code of the virtual machine within the pre-defined first region and restoring API code of the application of the second type within the pre-defined first region, 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.
5. The smart card control method of claim 4, wherein the determining whether the virtual machine exists in the preset first area of the RAM comprises:
judging whether the valid mark is arranged in the preset first area or not;
when the valid flag is set in the preset first area, determining that the virtual machine exists in the preset first area of the RAM;
and when the effective 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.
6. The smart card control method of any one of claims 1 to 4, wherein the determining whether a virtual machine exists in the preset first area of the RAM comprises:
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 a second type, determining that the virtual machine does not exist in a preset first area of the RAM.
7. The smartcard control method according to any of the claims 1-5, characterised in that the method further comprises:
and when the smart card is powered on, copying the code of the virtual machine into the preset first area.
8. 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 a 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 a second type;
the nonvolatile memory is internally provided with codes of the virtual machine;
the CPU is used for controlling the virtual machine to operate 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 operate in the nonvolatile memory when the target application is an application of a second type.
9. The smart card of claim 8, wherein the code of the virtual machine is code written in assembly language.
10. The smart card of claim 8, wherein the second type of application is a card management application; the first type of application is an application other than the card management application.
11. The smart card of any of claims 8-10, wherein 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.
12. A smartcard control device, comprising: the device comprises a receiving module, a detection module, a judgment 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 a Random Access Memory (RAM) or not when the type of the target application is a first type;
the processing module 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 a preset first area of the RAM, copying codes of the virtual machine to the preset first area, and operating the virtual machine in the preset first area.
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 true CN111443991A (en) 2020-07-24
CN111443991B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114579208A (en) * 2022-05-05 2022-06-03 广州万协通信息技术有限公司 Self-adaptive adjustment execution speed increasing method for Java card
CN115599409A (en) * 2022-11-30 2023-01-13 紫光同芯微电子有限公司(Cn) Method and device for installing application program 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

Cited By (3)

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

Also Published As

Publication number Publication date
CN111443991B (en) 2023-06-23

Similar Documents

Publication Publication Date Title
US9075758B2 (en) Removable storage device with transactional operation support and system including same
CN1241120C (en) Method for backing up and recovering data in hard disk of computer
US7222214B2 (en) Device-level address translation within a programmable non-volatile memory device
RU2445676C2 (en) Method of communication with multifunctional memory card
CN100561452C (en) A kind of card operating system carries out method of operating and smart card to the data file
CN111443991B (en) Smart card control method and device and smart card
CN109710317A (en) System start method, device, electronic equipment and storage medium
US9930207B2 (en) Information processing apparatus, method of initializing a non-volatile storage device, and storage medium
KR20140108666A (en) Writing data in a non-volatile memory of a smart card
CN111989656A (en) Configurable recovery state
EP2280348B1 (en) Method and system for saving operational state of running applications when unexpected shutdown events occur
CN109905770A (en) Terminal starting up method, apparatus and terminal
CN105425997A (en) Method for displaying interface after reboot of user terminal and user terminal
KR101258589B1 (en) Information storage medium recording data according to journaling file system, method and apparatus of writing/recovering data using journaling file system
KR20080066381A (en) Method for upgrading software
CN112199042A (en) Storage space management method, device, chip, equipment and storage medium
KR100605031B1 (en) A method for upgrading and restoring embeded systems by using usb memory device
CN110058938B (en) Memory processing method and device, electronic equipment and readable medium
KR20060080266A (en) System for updating a file on a mobile phone, and boot management system for preventing the fatal error by loss of a file header in the efs area, and method for updating a file on a mobile phone, and booting method for preventing the fatal error by loss of a file header in the efs area
CN111868698A (en) Free space direct connection
CN113469678B (en) Transaction reminding method, card swiping method and DESFire card
CN104615387A (en) Vehicle-mounted equipment based on XPE system and design method of vehicle-mounted equipment
CN102063381B (en) Data writing method for flash memory, and controller and storage system thereof
KR101532654B1 (en) Recovery method of mass storage device and mass storage device having recovery function
CN105677412A (en) Method for providing PCIE card configuration capacity in OpenPower CPU architecture server BOOT

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