Detailed Description
The embodiment of the invention provides a method for realizing multiple applications of a smart card, which realizes multiple applications of a Native smart card by establishing a mapping relation among an application code, an application file and an instruction, thus avoiding operating the application file corresponding to another application under the current application and ensuring the independence of each application.
The Native smart card in the embodiment of the invention has a plurality of applications, such as application A, application B, application C, application D and application E. In this way, each application supports some instructions, so that the corresponding relation between the application and the instructions can be established on the Native smart card. In this embodiment of the present invention, the correspondence between the application and the instruction may include: the first correspondence of the application with the instruction and/or the second correspondence of the application with the instruction. Wherein, the first corresponding relationship, that is, one application corresponds to at least one instruction, see fig. 1; the second correspondence, i.e. one instruction corresponds to at least one application, see fig. 2. And a corresponding application file system is established for each application on the Native smart card, that is, a third corresponding relationship between the application code and the application file, as shown in fig. 3.
In the embodiment of the invention, the COS is still adopted to operate the corresponding application file through the instruction so as to realize the specific functional application. After the current application is determined according to the actual application environment, referring to fig. 4, the specific implementation process of the multi-application of the Native smart card includes:
step 401: a current instruction is received.
Native smart cards can be used for contact applications as well as for contactless applications. Then, the Native smart card can receive data from the card reader and obtain the current instruction from the data; or receiving data from the wireless network through the antenna, and obtaining the current instruction from the data.
Step 402: judging the type of the current instruction, and if the current instruction is an application type instruction, executing step 403; otherwise, step 406 is performed.
Specific instructions specified in the industry, such as specific instructions in the 7816-4 specification, are stored in the Native smart card, and when the current instruction is received, the current instruction is firstly searched in the stored specific instructions, and when the current instruction cannot be searched in the specific instructions, the current instruction is an application-type instruction, and step 403 is executed. Otherwise, the current instruction is a non-application type instruction, and step 406 is executed.
The non-application type instruction may specifically include: an application instruction or a channel instruction is selected. When the received current instruction is an application selection instruction, the Native smart card can determine the application selected by the current instruction from the multiple applications according to the received current instruction and update the selected application to the current application; when the received current instruction is a channel instruction, the Native smart card can close or open the corresponding channel according to the received current instruction.
Step 403: and according to the stored corresponding relation between the application and the instruction, carrying out validity verification on the received current instruction under the current application, and executing the step 404 when the verification is passed, otherwise, executing the step 405.
When the first corresponding relationship between the application and the instruction as shown in fig. 1 has been established on the Native smart card, then when the received current instruction is an application-type instruction and the current application on the Native smart card is also determined, the first instruction list corresponding to the current application may be determined according to the stored first corresponding relationship. And searching the received current instruction in the determined first instruction list, when the current instruction can be searched in the first instruction list, indicating that the current instruction is legal, passing the verification, and executing the step 404, otherwise, failing the verification, and executing the step 405.
For example, if the current application is a, then according to the first corresponding relationship shown in fig. 1, determine a first instruction list, see table 1:
applications of |
Instructions |
Applications A |
Instructions 1, 2, 4, 5, 7, 12 |
TABLE 1
If the current instruction is instruction 5, the first instruction list includes instruction 5, the verification is passed, the instruction 5 is legal, and step 404 is executed. If the current instruction is instruction 6, the first instruction list does not include instruction 6, and the instruction 6 is illegal, step 405 is performed.
In the embodiment of the present invention, when the second corresponding relationship between the application and the instruction as shown in fig. 2 has been established on the Native smart card, when the received current instruction is an application-type instruction and the current application on the Native smart card is also determined, the second application list corresponding to the current instruction may be determined according to the stored second corresponding relationship. And searching the determined current application in the determined second application list, when the current application can be found in the second application list, indicating that the current instruction has validity, and executing the step 405 if the verification is passed, otherwise, executing the step 405 if the verification fails.
For example, if the current command is 5, then according to the second corresponding relationship shown in fig. 2, a second application list is determined, see table 2:
instructions |
Applications of |
Instruction 5 |
Using A, B, D, E |
TABLE 2
If the current instruction is application a, the second application list includes application a, the verification is passed, the instruction 5 is legal, and step 404 is executed. If the current application is application C, the second application list does not include application C, and the instruction 5 is illegal, step 405 is performed.
Of course, in the embodiment of the present invention, the first corresponding relationship and the second corresponding relationship are simultaneously stored, and then any one corresponding relationship may be selected, and the validity of the received current instruction is verified under the current application.
Step 404: and operating the application file corresponding to the current application through the received current instruction.
The Native smart card has established a corresponding application file system for each application, that is, a third correspondence between the application code and the application file as shown in fig. 3.
Therefore, the COS of the Native smart card firstly obtains the application code corresponding to the current application, then determines the application file corresponding to the application code according to the third corresponding relation between the application code and the application file, and finally operates the determined application file according to the current instruction.
For example: if the corresponding code corresponding to the current application a is obtained, the application file corresponding to the application a code is determined according to the third corresponding relationship between the application code and the application file shown in fig. 3, as shown in table 3:
application code |
Application files |
Application A code |
ADF1 |
TABLE 3
Thus, the COS can operate the file ADF1 according to the received current instruction, and implement the function corresponding to the application a.
Step 405: and discarding the received current instruction or returning an error code, and ending the application process.
Here, if the current instruction cannot be found in the first instruction list, it indicates that the current instruction is not a legal instruction, and the verification fails, so that the received current instruction is discarded, or an error code is returned to the interface device, and the current application process is ended.
Step 406: and operating the Native smart card through the current instruction.
Here, the received current instruction is a non-application type instruction, so that it is not necessary to scan an application list supported by the current instruction, the current instruction can be executed in any case, and the Native smart card is operated instead of the specified application file.
When the received current instruction is an application selection instruction, the application selected by the current instruction can be determined from the stored multiple applications, and the selected application is updated to be the current application, so that the current application is updated when the instruction is received next time; when the received current instruction is a channel instruction, the corresponding channel can be closed or opened according to the received current instruction.
In step 404 of the foregoing embodiment, there may be multiple ways to obtain the application code corresponding to the current application, where the multiple ways include:
when only the first corresponding relationship between the application and the instruction is stored in the Native smart card, or when the first corresponding relationship between the application and the instruction is stored in the Native smart card, all applications corresponding to the current instruction can be searched in the first corresponding relationship, a second application list is formed by all searched applications, and then the current application is searched in the formed second application list, so that the application code of the current application can be obtained.
When only the second corresponding relationship between the application and the instruction is stored in the Native smart card, or when the first and second corresponding relationships between the application and the instruction are stored in the Native smart card at the same time, the second application list corresponding to the current instruction can be directly determined from the stored second corresponding relationship between the application and the instruction, and then the current application is searched in the determined second application list, so that the application code of the current application is known.
According to the method for realizing multiple applications of the smart card, a multi-application Native smart card can be determined, and referring to fig. 5, the method includes: an authentication unit 100 and an operation unit 200. Wherein,
and the verification unit 100 is configured to, when the received current instruction is an application-type instruction, perform validity verification on the received current instruction under the current application according to the stored correspondence between the application and the instruction.
And an operation unit 200, configured to, when the verification passes, operate the application file corresponding to the current application through the current instruction.
The verification unit 100 may determine a first instruction list corresponding to the current application according to the stored first corresponding relationship between the application and the instruction, and determine that the current instruction is legal when the determined first instruction list includes the current instruction.
Alternatively, the verification unit 100 may determine a second application list corresponding to the current instruction according to the stored second corresponding relationship between the application and the instruction, and determine that the current instruction is legal when the determined second application list includes the current application.
Of course, the verification unit 100 performs validity verification on the received current instruction, and when the verification fails, the Native smart card may also discard the current instruction or return an error code.
The operation unit 200 includes: acquisition subunit 210, determination subunit 220, and operation subunit 230
An obtaining subunit 210, configured to obtain an application code corresponding to the current application.
The determining subunit 220 is configured to determine, according to the third corresponding relationship between the application code and the application file, the application file corresponding to the application code.
And an operation subunit 230, configured to operate the determined application file according to the current instruction.
The obtaining sub-unit 210 may search a second application list corresponding to the current instruction according to the stored first corresponding relationship between the application and the instruction, and determine an application code corresponding to the current application according to the second application list. Or,
the obtaining sub-unit 210 may determine a second application list corresponding to the current instruction from the stored second corresponding relationship between the application and the instruction, and determine an application code corresponding to the current application according to the second application list.
Of course, the Native smart card in the embodiment of the present invention may further include:
and the updating unit is used for determining the application selected by the current instruction from the stored multiple applications and updating the selected application to the current application when the received current instruction is the instruction for selecting the application.
In the embodiment of the invention, the Native smart card for realizing multi-application can also be a Native electronic key and other similar Native devices with a safety processing function in practical application.
In summary, in the embodiment of the present invention, the Native smart card performs validity verification on the received current instruction under the current application according to the stored corresponding relationship between the application and the instruction, and when the verification is passed, operates the application file corresponding to the current application through the current instruction. Therefore, by establishing the mapping relation among the application codes, the application files and the instructions, the application file corresponding to another application is prevented from being operated under the current application, the independence of each application is ensured, and the safety of each application is improved.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is intended to include such modifications and variations.