WO2014173298A1 - 一种管理卡片上应用的方法 - Google Patents

一种管理卡片上应用的方法 Download PDF

Info

Publication number
WO2014173298A1
WO2014173298A1 PCT/CN2014/076030 CN2014076030W WO2014173298A1 WO 2014173298 A1 WO2014173298 A1 WO 2014173298A1 CN 2014076030 W CN2014076030 W CN 2014076030W WO 2014173298 A1 WO2014173298 A1 WO 2014173298A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
command
card
data block
application
Prior art date
Application number
PCT/CN2014/076030
Other languages
English (en)
French (fr)
Inventor
陆舟
于华章
Original Assignee
飞天诚信科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN201310146939.4A external-priority patent/CN103218560B/zh
Priority claimed from CN201310399702.7A external-priority patent/CN103473093B/zh
Application filed by 飞天诚信科技股份有限公司 filed Critical 飞天诚信科技股份有限公司
Priority to US14/786,213 priority Critical patent/US10324781B2/en
Publication of WO2014173298A1 publication Critical patent/WO2014173298A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/0736Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in functional embedded systems, i.e. in a data processing system designed as a combination of hardware and software dedicated to performing a certain function
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0772Means for error signaling, e.g. using interrupts, exception flags, dedicated error registers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/71Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
    • G06F21/74Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information operating in dual or compartmented mode, i.e. at least one secure mode
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/71Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information
    • G06F21/77Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure computing or processing of information in smart cards

Definitions

  • the invention belongs to the field of smart cards, and in particular relates to a method for managing applications on a card. Background technique
  • the card issuer does not manage all the card contents, especially the card is not issued.
  • the card content of the party therefore, requires a mechanism for the third party to manage the card content by pre-authentication, such as loading, installing, extradition and deletion.
  • the object of the present invention is to overcome the deficiencies of the prior art and to provide a method of managing applications on a card.
  • a method of managing applications on a card the basic implementation process is as follows:
  • Step A Check the card status. If it is the first preset state or the second preset state, step B: Check whether the received data conforms to the preset format. If the first preset format is met, perform step C. The second preset format performs step D. If the third preset format is met, step E is performed. If the fourth preset format is met, step F is performed. If the fifth preset format is met, step G is performed. The preset format is executed in step H. If the seventh preset format is met, step I is performed. If the preset format is not met, the data error status code is generated and returned to the operating environment, and the process ends.
  • Step C Continue to receive the data sent by the operating environment to obtain a complete first command, parse the first command, obtain a load file identifier and a load file associated security domain identifier, create a load file structure, and parse the obtained load file identifier and The load file associated domain identifier is populated into the created load file structure. If successful, the generated success status code and return result are sent to the running environment, and the process ends. If the operation is unsuccessful, it is generated and returned according to the failure reason. The corresponding status code is given to the operating environment, and ends;
  • Step D Continue to receive the data sent by the operating environment to obtain a complete second command, parse the second command, obtain a load file data block, obtain component data according to the load file data block, and store, and fill the storage address to the load In the file structure, if successful, generate and return the success status code and return result to the running environment, and end. If the operation is unsuccessful, generate and return the corresponding status code to the running environment according to the failure reason, and end;
  • Step E Continue to receive the data sent by the operating environment to obtain a complete third command, parse the third command, and obtain an executable load file identifier, an executable module identifier, an application identifier, and an application permission, and the executable load file obtained according to the parsing
  • the identifier searches for the load file structure, searches for an executable module corresponding to the parsed executable module identifier in the storage space corresponding to the storage address in the found load file structure, and creates an application of the found executable module, and uses the parsing
  • the obtained application identifier identifies the created application, and gives the created application the right specified by the parsed application permission, and sets the created application.
  • the associated security domain is an associated security domain of the executable load file corresponding to the parsed executable load file identifier. If successful, the success status code is generated and returned, and the result is returned to the running environment. If it is unsuccessful, it generates and returns the corresponding status code to the running environment according to the failure reason, and ends;
  • Step F Continue to receive the data sent by the operating environment to obtain a complete fourth command, parse the fourth command, obtain an application identifier and an application permission, and find an application corresponding to the parsed application identifier in the card, and update the found application.
  • the state of the application is a selectable state, and the permission of the newly-applied application is the permission specified by the parsed application permission. If the operation succeeds, the success status code is generated and returned, and the returned result is sent to the running environment, and ends. If the operation is unsuccessful, the corresponding status code is generated and returned to the running environment according to the failure reason, and the process ends.
  • Step G Continue to receive the data sent by the operating environment to obtain a complete fifth command, parse the fifth command, obtain the security domain identifier and the application identifier, and find the application and the parsing corresponding to the parsed application identifier in the card.
  • the security domain identifies the corresponding application, and updates the associated security domain of the found application to the application corresponding to the parsed security domain identifier. If successful, generates and returns the success status code and returns the result to the running. Environment, end, if the operation is unsuccessful, generate and return the corresponding status code to the running environment according to the failure reason, and end;
  • Step H Continue to receive the data sent by the operating environment to obtain a complete sixth command, parse the sixth command, obtain an application identifier, search for an application corresponding to the parsed application identifier in the card, and set the found application as an individual.
  • Application if successful, generate and return the success status code and return the result to the running environment, and end, if the operation is unsuccessful, generate and return the corresponding status code to the running environment according to the failure reason, and end;
  • Step I Continue to receive the data sent by the operating environment to obtain a complete seventh command, parse the seventh command, obtain a data domain identifier, and search for an application corresponding to the parsed data domain identifier and an executable loading file in the card. Delete the found application and executable load file, if successful, generate and return the success status code and return the result to Run environment, end, if the operation is unsuccessful, generate and return the corresponding status code to the running environment according to the failure reason, and end.
  • the preparing the loading application according to the first command specifically includes:
  • Step C1 determining whether the first data block of the first command is legal, and if it is legal, checking whether there is an executable file corresponding to the first data block in the card, if the condition is not satisfied, ⁇ Fails, otherwise step C2 is performed; if it is not legal, the data is incorrect and the operation fails;
  • Step C2 determining whether the second data block of the first command meets a preset requirement, and if the first preset requirement is met, setting an associated security domain of the loading file corresponding to the first data block to the card
  • the content management module performs step C4; if the second preset requirement is met, step C3 is performed; if the preset requirement is not met, the data is incorrect, and the operation fails; step C3: checking whether there is a second data block in the card Corresponding application, if not, the processing condition is not satisfied, and the operation fails; if yes, it is checked whether the application corresponding to the second data block has security domain authority, and if there is security domain authority, the setting is The associated security domain of the load file corresponding to the first data block is an application corresponding to the second data block, and step C4 is performed; if the security domain authority is not available, the processing condition is not satisfied, and the operation fails;
  • Step C4 determining whether the third data block of the first command is legal, if yes, storing the corresponding data in the third data block, and performing step C5; otherwise, the data is incorrect, and the operation fails;
  • Step C5 processing the fourth data block of the first command, performing step C6;
  • Step C6 determining whether the fifth data block of the first command is legal, if yes, creating a load file structure, and according to the A data block and the second data block fill the load file structure, initialize the global block number in the card, and succeed; otherwise, the data is incorrect and the operation fails.
  • the loading the application according to the second command specifically includes:
  • Step D1 determining whether the fourth byte of the second command is equal to the global block number in the card, if yes, executing step D2; otherwise, the data is incorrect, and the operation fails;
  • Step D2 Check whether the second command includes the data verification mode block information, and if yes, verify the data verification mode fast information, if the verification is passed, execute step D3, if the verification fails, the data error occurs, and the operation fails.
  • step D3 acquiring component data according to the load file data block in the second command and storing, filling the storage address into the load file structure, and updating the global block number in the card If the current value is incremented by 1, it is determined whether the load file data block is the last load file data block of the load file, and if yes, step D4 is performed, otherwise the operation is successful;
  • Step D4 determining whether the hash value of the load file data block in the card has a value, and if there is a value, performing a hash calculation on the whole of the load file data block stored in the card, and determining whether the calculation result is equal to the loading.
  • File data block hash value if it is equal, then execute step D5, if it is not equal, the data is wrong, and the operation fails; if there is no value, step D5 is performed;
  • Step D5 Store and submit the executable load file structure, and succeed.
  • the installing the application according to the third command specifically includes:
  • Step E1 determining whether the first data block of the third command is legal. If it is legal, checking whether there is a loading file structure corresponding to the first data block in the card, if yes, performing step E2, otherwise If the condition is not satisfied, the operation fails; if it is not legal, the data is wrong and the operation fails;
  • Step E2 determining whether the second data block of the third command is legal, and if it is legal, checking whether a storage space corresponding to the storage address in the loading file structure has a corresponding corresponding to the second data block. Execute the module, if yes, go to step E3. Otherwise, the processing condition is not satisfied, and the operation fails. If it is not legal, the data is wrong and the operation fails.
  • Step E3 determining whether the third data block of the third command is legal. If it is legal, checking whether there is an application corresponding to the third data block in the card, if yes, executing step E4, otherwise the processing condition is not Satisfaction, failure; if not legal, the data is wrong, the failure fails;
  • Step E4 determining whether the fourth data block of the third command is legal, and if it is legal, determining whether the application corresponding to the third data block has a default selection permission, Step E5 is performed, otherwise step E6 is performed; if it is not legal, the data is incorrect, and the operation fails; Step E5: determining whether the third byte of the third command is equal to the preset value, if the preset value is the data error, ⁇ If it is not the default value, it is judged whether the card content management module has the default selection authority, if yes, step E7 is performed; otherwise, the processing condition is not satisfied, and the operation fails;
  • Step E6 determining whether the third data block of the third command meets a preset condition, and processing the fifth data block of the third command if the first preset condition or the second preset condition is met, and performing the step E7, if the preset conditions are not met, the conditions are not satisfied, and the operation fails;
  • Step E7 determining whether the sixth data block of the third command is legal, if yes, registering the application according to the third command, performing step E8, otherwise the data is incorrect, and failing; step E8: determining the third command Whether the third byte of the third byte is equal to the preset value, and the state of the application corresponding to the third data block of the third command is set to be installed, and the operation is successful; otherwise, the third command is set The status of the application corresponding to the third data block is selectable, and step E9 is performed;
  • Step E9 determining whether an application corresponding to the third data block of the third command has a default selection permission, and setting an application corresponding to the third data block of the third command as a default application, Be successful, otherwise it will succeed.
  • the setting the application state according to the fourth command specifically includes:
  • Step F1 determining whether the first data block and the second data block of the fourth command are both legal, if yes, step F2 is performed, otherwise the data is incorrect, and the operation fails;
  • Step F2 determining whether the third data block of the fourth command is legal, if not, the data is incorrect, and the operation fails; if it is legal, checking whether there is an application corresponding to the third data block in the card, if If there is no condition, the condition is not satisfied, and the operation fails; if yes, it is judged whether the state of the application corresponding to the third data block is installed, and if it is not installed, the condition is not satisfied, and the operation fails; Step F3 is performed for installation;
  • Step F3 determining whether the fourth data block of the fourth command is legal, if yes, executing step F4; otherwise, the data is incorrect, and the operation fails;
  • Step F4 determining whether the fifth data block of the fourth command is legal, if yes, executing step F5; otherwise, the data is incorrect, and the operation fails;
  • Step F5 determining whether the sixth data block of the fourth command is legal, if yes, setting the state of the application corresponding to the third data block to be selectable, performing step F6, otherwise the data error fails;
  • Step F6 determining whether the application corresponding to the third data block has a default selection permission, if not, the operation is successful; if yes, determining whether the card content management module has a default selection permission, The application corresponding to the third data block is the default application, and the operation is successful. Otherwise, the processing condition is not satisfied, and the operation fails.
  • the updating the associated security domain of the application according to the fifth command specifically includes: Step G1: determining whether the first data block of the fifth command is legal, if not, the data is incorrect, and the operation fails; if it is legal, the card is checked. Whether there is an application corresponding to the first data block, if not, the processing condition is not satisfied, and the operation fails; if yes, it is determined whether the application corresponding to the first data block is the card.
  • the content management module if yes, the processing condition is not satisfied, and the operation fails; if not, step G2 is performed; step G2: determining whether the second data block of the fifth command is legal, if not, the data is incorrect, and the operation fails. If it is legal, it is determined whether the state of the application corresponding to the first data block is an installation, if not, the processing condition is not satisfied, and the operation fails; if it is installed, step G3 is performed;
  • Step G3 determining whether the third data block of the fifth command is legal. If it is not legal, the data is incorrect, and the operation fails; if it is legal, it is checked whether there is an application corresponding to the third data block in the card, if If there is no condition, the condition is not satisfied, and the operation fails; if yes, step G4 is performed;
  • Step G4 determining whether the application corresponding to the first data block has security domain authority, if not, the processing condition is not satisfied, and the failure occurs; if yes, determining that the first data block corresponds to Whether the state of the application is locked, if it is locked, the processing condition is not satisfied, and the operation fails; if it is not locked, it is determined whether the state of the application corresponding to the first data block is personalized, if it is personalized Then perform step G5, if not personalized If the conditions are not satisfied, the operation fails;
  • Step G5 determining whether the fourth data block and the fifth data block of the fifth command are both legal, if yes, executing step G6; otherwise, the data is incorrect, and the operation fails;
  • Step G6 determining whether the sixth data block of the fifth command is legal, if not, the data is incorrect, and the operation fails; if it is legal, determining whether the application corresponding to the third data block has security domain rights, If the condition is not satisfied, the failure is successful; if not, the associated security domain of the application corresponding to the third data block is set to be the application corresponding to the first data block, success.
  • the personalization application according to the sixth command specifically includes:
  • Step HI determining whether the first data block and the second data block of the sixth command are both legal, if yes, step H2 is performed, otherwise the data is incorrect, and the operation fails;
  • Step H2 determining whether the third data block of the sixth command is legal, if not, the data is incorrect, and the operation fails; if it is legal, checking whether there is an application corresponding to the third data block in the card, if If the condition is not satisfied, the operation fails; if yes, it is determined whether the associated security domain of the application corresponding to the third data block is the card content management module, if yes, step H3 is performed, otherwise, If the conditions are not met, the operation fails;
  • Step H3 determining whether the fourth data block, the fifth data block, and the sixth data block of the sixth command are both legal, and setting an application corresponding to the third data block to be a personalized application Otherwise, the conditions are not met and the operation fails.
  • the deleting the application and the executable loading file according to the seventh command specifically includes: Step II: determining whether the first data block of the seventh command is legal, if yes, executing step 12; otherwise, the data is incorrect, and the operation fails;
  • Step 12 Determine whether the second data block of the seventh command is legal. If it is not legal, the data is incorrect, and the operation fails. If it is legal, check whether there is an application corresponding to the second data block in the card. Then perform step 13, otherwise perform step 14;
  • Step 13 Determine whether the fourth byte of the seventh command is equal to the preset value, if yes, go to step 14, otherwise go to step 15;
  • Step 14 Check whether there is an executable load file corresponding to the second data block in the card. If not, the processing condition is not satisfied, and the operation fails; if yes, the fourth command of the seventh command is determined. Whether the byte is equal to a preset value, if equal to deleting the application and the executable load file corresponding to the second data block, if successful, if not equal to deleting the corresponding corresponding to the second data block The executable load file can be successfully executed;
  • Step 15 Check whether the application corresponding to the second data block is an associated security domain of another application or other executable load file, if the processing condition is not satisfied, the operation fails; otherwise, step 16;
  • Step 16 determining whether the application corresponding to the second data block is the card content management module, if the processing condition is not satisfied, the operation fails, otherwise deleting the corresponding data block corresponding to the second data block Application, success.
  • a method for implementing management of card data is as follows:
  • the first card data management module After the first card data management module receives the application protocol data unit APDU data sent by the operating environment, it uses itself as the current first card data management module, and performs the following steps:
  • Step A Examining the instruction code of the APDU data, if the instruction code is a valid value 0xE8, performing step D, if the instruction code is a valid value 0xE6, performing step B, if the instruction code is a valid value 0xE4 Perform step I;
  • Step B Check the first parameter of the APDU data, if the first parameter is 0x02, perform step C, if the first parameter is 0x04 or OxOC, perform step E, if the first parameter is 0x08 Step F is performed, if the first parameter is 0x10, step G is performed, and if the first parameter is 0x20, step H is performed;
  • Step C Collecting the data field part of the preloading command, obtaining the entire content of the preloading command, checking whether the card satisfies the preloading condition according to the content of the preloading command, and then creating a new executable loading file structure and setting corresponding data, and executing Step J, otherwise directly perform step J;
  • Step D collecting the data field part of the load command, obtaining the entire content of the load command, checking whether the card satisfies the loading condition according to the content of the load command, and storing the Load the corresponding content of the command, perform step J, otherwise directly execute step J;
  • Step E Collecting the data field part of the installation command, obtaining the entire content of the installation command, checking whether the card satisfies the installation condition according to the content of the installation command, creating an application and setting the corresponding state, performing step J, otherwise directly performing step J ;
  • Step F Collecting the data field part of the selectable command, obtaining all the contents of the selectable command, checking whether the card satisfies the selectable condition according to the content of the selectable command, and setting the state of the corresponding application to be selectable, and performing step J Otherwise, step J is directly executed; step G, collecting the data domain part of the extradition command, obtaining the entire content of the extradition command, checking whether the card satisfies the extradition condition according to the content of the extradition command, and resetting the security domain associated with the corresponding application, Perform step J, otherwise directly perform step J;
  • Step H Collecting the data field part of the personalized command, obtaining the entire content of the personalized command, checking whether the card satisfies the personalized condition according to the content of the personalized command, and then sending the corresponding data to the corresponding application, and performing step J, Otherwise, step J is directly executed;
  • Step I The data field portion of the delete command is received, and the entire content of the delete command is obtained. According to the content of the delete command, it is checked whether the card meets the deletion condition, and the card specified in the delete command is deleted. Corresponding data, perform step J, otherwise directly perform step J;
  • Step J Generate and return corresponding return data and/or corresponding status code to the running environment.
  • the beneficial effects of the method of the present invention are: providing a method for managing applications on a card, which can implement loading, installing, updating, personalizing, and deleting applications on the card; and simultaneously providing convenience for data management on the smart card, specifically embodied in Two aspects:
  • the card issuer may not care about applications that are not related to itself;
  • FIG. 1 is a flow chart of a method for managing an application on a card according to Embodiment 1 of the present invention
  • FIG. 2 is a flow chart of a specific method for preparing a loading application according to Embodiment 2 of the present invention
  • FIG. 3 is a flowchart of a specific method for loading an application according to Embodiment 3 of the present invention
  • FIG. 4 is a flowchart of a specific method for installing an application according to Embodiment 4 of the present invention
  • FIG. 6 is a flowchart of a specific method for updating an associated security domain of an application according to Embodiment 6 of the present invention.
  • Embodiment 7 is a flow chart of a specific method for a personalized application according to Embodiment 7 of the present invention.
  • FIG. 8 is a flowchart of a specific method for deleting an application and executing an executable file according to Embodiment 8 of the present invention.
  • FIG. 9 is a flowchart of a method for implementing management card data according to the present invention.
  • FIG. 10 is a specific flowchart of steps 1001 to 1028;
  • FIG. 11 is a specific flowchart of steps 1101 to 1129;
  • Figure 12 is a specific flow chart of steps 1201 to 1235;
  • Figure 13 is a specific flow chart of steps 1301 to 1324;
  • Figure 14 is a specific flow chart of steps 1401 to 1428;
  • Figure 15 is a specific flow chart of steps 1501 to 1517;
  • Figure 16 is a detailed flow chart of steps 1601 through 1625. detailed description
  • a first embodiment of the present invention provides a method for managing an application on a card.
  • the method specifically includes: after the card content management module receives the data sent by the RE (Runtime Environment) device, performing the following steps.
  • the card content management module is a special application in the card:
  • Step 101 Check the card status. If it is the first preset state or the second preset state, generate and return the card state does not support the status code to the RE, and end; otherwise, perform step 102; specifically, in this embodiment, A preset state is TERMINATED and the second preset state is CARD_LOCKED.
  • Step 102 Check whether the received data conforms to the preset format. If the first preset format is met, step 103 is performed; if the second preset format is met, step 104 is performed; if the third preset format is met, step 105 is performed; If the fourth preset format is met, step 106 is performed; if the fifth preset format is met, step 107 is performed; if the sixth preset format is met, step 108 is performed; if the seventh preset format is met, step 109 is performed; Comply with the default format to generate and return a data error status code to the RE, ending;
  • step 102 specifically includes:
  • Step B1 Check whether the length of the received data is five bytes. If yes, execute step B2. Otherwise, the received data does not conform to the preset format, generate and return a data error status code to the operating environment, and end;
  • Step B2 Check whether the first byte of the received data is 0x80 or 0x84, if yes, execute step B3, otherwise the received data does not conform to the preset format, generate and return a data error status code to the operating environment, and end;
  • Step B3 Check the second byte of the received data. If it is 0xE6, go to step B4. If it is 0xE8, go to step B5. If it is 0xE4, go to step B6. Otherwise, the received data does not match the preset format. Generate and return a data error status code to the runtime environment, End;
  • Step B4 Check the third to fifth bytes of the received data. If the third byte and the fourth byte are 0x02 and 0x00, respectively, and the fifth byte is not less than OxOA, the received data conforms to the first pre- Formatting, performing step 103; if the third byte is 0x04 or 0x0C, the fourth byte is 0x00, and the fifth byte is not less than 0x18, the received data conforms to the third preset format, and step 105 is performed; The byte and the fourth byte are 0x08 and 0x00 respectively, and the fifth byte is not less than OxOC, and the received data conforms to the fourth preset format, and step 106 is performed; if the third byte and the fourth byte are 0x10 and respectively 0x00 and the fifth byte is not less than 0x10, the received data conforms to the fifth preset format, and step 107 is performed; if the third byte and the fourth byte are 0x20 and
  • Step B5 Check whether the third byte of the received data is 0x00 or 0x80, if the received data conforms to the second preset format, perform step 104, otherwise the received data does not conform to the preset format, and generates Return the data error status code to the running environment, and end;
  • Step B6 Check whether the third byte of the received data is 0x00, if the received data conforms to the seventh preset format, go to step 109, otherwise receive the received data. The data does not conform to the preset format, generates and returns a data error status code to the running environment, and ends.
  • Step 103 Continue to receive the data sent by the RE to obtain complete APDU data, and prepare to load the application according to the APDU data.
  • the APDU data in step 103 is a for_Load command
  • the loading of the application according to the APDU data includes: parsing the for_Load command, obtaining the loading file identifier and the associated file security domain identifier, creating a loading file structure, and populating the parsed loading file identifier and the loading file association domain identifier into the created In the load file structure, if the above operation succeeds, the success status code and the return result are generated and returned to the running environment, and if the above operation is unsuccessful, the corresponding status code is generated and returned to the running environment according to the failure reason. End. Step 104: Continue to receive data sent by the RE to obtain complete APDU data, and load an application according to the APDU data.
  • the APDU data in the step 104 is a Load command; loading the application according to the APDU data specifically includes: parsing a Load command, obtaining a load file data block, and acquiring component data according to the load file data block. And storing, filling the storage address into the loading file structure, if the above succeeds, generating and returning the success status code and returning the result to the running environment, ending, if the above operation is unsuccessful, generating according to the failure reason And return the corresponding status code to the operating environment, and finish.
  • Step 105 Continue to receive data sent by the RE to obtain complete APDU data, and install an application according to the APDU data.
  • the APDU data in step 105 is a for_Install command
  • the installation of the application according to the APDU data specifically includes: parsing the for_Install command, obtaining an executable load file identifier, an executable module identifier, an application identifier, and an application permission, and searching for the load file structure according to the parsed executable load file identifier, and finding the An executable module corresponding to the executable module identifier obtained by parsing the parsed executable module in the storage space corresponding to the storage address in the file structure, creating an application of the found executable module, and creating the application by using the parsed application identifier identifier, and Giving the created application the right specified by the parsed application permission, and setting the associated security domain of the created application to the associated security domain of the executable load file corresponding to the parsed executable load file identifier, if the above operation If successful, the success status code and the return result are generated and returned to the running environment. If the above operation is unsuccessful, the corresponding status code is generated and returned to the running environment according to the failure reason, and the process ends.
  • Step 106 Continue to receive data sent by the RE to obtain complete APDU data, and set an application state according to the APDU data.
  • the APDU data in step 106 is a for_Makeselectable command
  • Setting the application state according to the APDU data specifically includes:
  • the for_Makeselectable command obtains the application identifier and the application permission, searches for an application corresponding to the parsed application identifier in the card, updates the status of the found application to a selectable state, and updates the searched application's permission to the parsed application.
  • the permission specified by the permission if the above operation succeeds, generates and returns the success status code and returns the result to the running environment, and ends. If the above operation is unsuccessful, the corresponding status code is generated and returned to the running environment according to the failure reason. , End.
  • Step 107 Continue to receive data sent by the RE to obtain complete APDU data, and update an associated security domain of the application according to the APDU data.
  • the associated security domain of the application provides a service such as a key for the application
  • the APDU data in step 107 is a for_Extradition command
  • Updating the associated security domain of the application according to the APDU data specifically includes: parsing the for_Extradition command, obtaining the security domain identifier and the application identifier, and searching for the application corresponding to the parsed application identifier in the card and corresponding to the parsed security domain identifier
  • the application updates the associated security domain of the application corresponding to the parsed application identifier to an application corresponding to the parsed security domain identifier, and if the above succeeds, generates and returns a success status code and Return the result to the running environment, and end. If the above operation is unsuccessful, generate and return the corresponding status code to the running environment according to the failure reason, and the process ends.
  • Step 108 Continue to receive data sent by the RE to obtain complete APDU data, and personalize the application according to the APDU data.
  • the APDU data in step 108 is a for-Personalized command
  • the personalization application according to the APDU data specifically includes: parsing the for_Personalized command, obtaining an application identifier, searching for an application corresponding to the parsed application identifier in the card, and setting the found application as a personalized application, if the above operation succeeds Generate and return the success status code and return the result to the running environment, and end. If the above operation is unsuccessful, generate and return the corresponding status code to the running environment according to the failure reason, and the process ends.
  • Step 109 Continue to receive the data sent by the RE to obtain complete APDU data, and delete the application and the executable loading file according to the APD U data.
  • the APDU data in the step 109 is a Delete command.
  • the deleting the application and the executable loading file according to the APDU data specifically includes: parsing a Delete command, obtaining a data domain identifier, and searching and parsing in the card.
  • the data field identifies the corresponding application and the executable load file, deletes the found application and the executable load file, and if the above operation succeeds, generates and returns the success status code and returns the result to the running environment, ending, if If the operation is unsuccessful, the corresponding status code is generated and returned to the running environment according to the failure reason, and the process ends.
  • the return result is 0x00
  • the failure reason includes: the processing condition is not satisfied and the data error occurs, and when the failure reason is that the processing condition is not satisfied, the generation and return condition does not satisfy the status code.
  • RE a data error status code is generated and returned to the RE when the cause of the failure is a data error.
  • the second embodiment of the present invention provides a specific method for preparing an application for loading an application in a method for managing a card provided in the first embodiment.
  • the APDU data in this embodiment is the complete APDU data obtained in step 103, and the data field portion thereof may be It is considered to be composed of a plurality of data blocks, each of which is an LV structure, that is, a structure of data length + data; see FIG. 2, the method specifically includes:
  • Step 201 Determine whether the first data block of the APDU data is legal, if yes, execute step 202, otherwise the data is incorrect, and the operation fails;
  • the first data block is specifically: loading file identifier length + loading file identifier;
  • Determining whether the first data block of the APDU data is legal or not includes: determining whether the length of the load file identifier in the first data block of the APDU data is within a preset range, and checking the first of the APDU data Each byte of the load file identifier in the data block, if both are 0x00, the first data block is invalid, if not all 0x00, then the first The data block is legal, otherwise the first data block is illegal;
  • the preset range is 0x05-0x10.
  • Step 202 Check whether there is an executable file corresponding to the loaded file identifier in the card, if the processing condition is not satisfied, the operation fails, otherwise step 203 is performed;
  • Step 203 Check whether the second data block of the APDU data meets the preset requirement. If the first preset requirement is met, step 204 is performed. If the second preset requirement is met, step 205 is performed, if the preset requirement is not met. The data is wrong, and the failure is made;
  • the second data block is specifically: a file association security domain identifier length + a load file association security domain identifier;
  • Checking whether the second data block of the APDU data meets the preset requirement specifically includes: determining whether the length of the load file associated security domain identifier in the second data block of the APDU data is 0x00, and the APDU data is The second data block satisfies the first preset requirement, and otherwise checks each byte of the load file associated security domain identifier in the second data block of the APDU data, and if both are 0x00, the APDU data is second. The data block does not meet the preset requirement, and if not all 0x00, the second data block of the APDU data satisfies the second preset requirement;
  • Step 204 Set the associated security domain of the load file to the card content management module, and perform step 208;
  • the load file is a load file corresponding to the load file identifier in the first data block of the APDU data.
  • Step 205 Check whether there is an application corresponding to the security domain identifier associated with the loaded file in the card, and then execute step 206, otherwise the processing condition is not satisfied, and the operation fails;
  • Step 206 Check whether the application corresponding to the security domain identifier associated with the load file has the security domain authority. If yes, execute step 207. Otherwise, the processing condition is not satisfied, and the operation fails. Specifically, it is determined whether the security is determined by the application permission attribute. Domain permission, the application permission attribute is a byte of data, from the high position to the status, b8 b7 b6 b5 b4 b3 b2 bl, check whether the application corresponding to the security domain identifier associated with the load file has security domain permissions, specifically for checking and loading files. The permission attribute of the application corresponding to the associated security domain identifier B8, if it is 1, the application corresponding to the security domain identifier associated with the load file has the security domain authority. If not 1, the application corresponding to the security domain identifier associated with the load file does not have the security domain authority.
  • Domain permission the application permission attribute is a byte of data, from the high position to the status, b8 b7 b6 b5
  • Step 207 Set an associated security domain of the loaded file to be an application corresponding to the security domain identifier associated with the loaded file.
  • Step 208 Determine whether the third data block of the APDU data is legal. If yes, go to step 209. Otherwise, the data is incorrect and fails.
  • the third data block is specifically: loading a file data block hash value length + loading a file data block hash value;
  • Determining whether the third data block of the APDU data is legal or not includes: determining whether the length of the load file data block hash value in the third data block of the APDU data is 0x00, and the third of the APDU data is The data block is invalid, otherwise the third data block of the APDU data is legal.
  • Step 209 Store a load file data block hash value
  • Step 210 Process a fourth data block of the APDU data.
  • the fourth data block is specifically: a loading parameter field length + a loading parameter field
  • the loading parameter field is 1 TLV structure data block (Tn, Ln, Vn)
  • the Vn is composed of 3 TLV structures.
  • the data block (Tn ', Ln ', Vn ') is composed.
  • step 210 specifically includes:
  • Step 210-1 Determine whether the length of the loading parameter field is 0x00, if yes, go to step 211, otherwise go to step 210-2;
  • Step 210-2 It is judged whether Tn is 0xEF, if yes, step 210-3 is performed, otherwise the data is incorrect, and the operation fails;
  • Step 210-3 Obtain a TLV structure data block of the Vn, and determine whether the Tn' of the TLV structure data block is legal. If yes, execute step 210-4. Otherwise, the data is incorrect, and the operation fails.
  • Step 210-5 Check Tn ' of the TLV structure data block, if it is 0xC6, according to the The Vn of the TLV structure data block acquires and stores the non-volatile code space quota, and performs step 210-6. If it is 0xC7, the volatile data space quota is acquired and stored according to the Vn' of the TLV structure data block, and step 210 is performed. -6, if 0xC8, according to the Vn ' of the TLV structure data block to obtain and store the non-volatile data space limit, step 210-6;
  • Step 210-6 determining whether there is still an unprocessed TLV structure data block, if yes, returning to step 210-3, otherwise performing step 210-7;
  • Step 210-7 Determine whether the non-volatile storage space and the volatile storage space in the card can meet the above quota. If yes, execute step 211. Otherwise, the processing condition is not satisfied, and the operation fails.
  • Step 211 Determine whether the fifth data block of the APDU data is legal. If yes, execute step 212. Otherwise, the data is incorrect and fails.
  • the fifth data block is specifically: loading the token length + loading the token; determining whether the fifth data block of the APDU data is legal or not specifically includes: determining the fifth data block of the APDU data Whether the length of the loaded token is 0x00, the fifth data block of the APDU data is legal, otherwise the data block of the APDU data is invalid.
  • Step 212 Create a load file structure, fill the load file identifier and the load file association security domain identifier into the created load file structure, and initialize the global block number in the card, and succeed.
  • the third embodiment of the present invention provides a specific method for loading an application in a method for managing an application on a card provided in the first embodiment.
  • the method specifically includes:
  • Step 301 Determine whether the fourth byte of the APDU data is equal to the global block number in the card, if yes, go to step 302. Otherwise, the data is incorrect and fails.
  • Step 302 Check whether the APDU data includes DAP (Data Authentication Pattern) block information, if yes, go to step 303, otherwise go to step 304;
  • Step 303 Verify the DAP block information, if the verification is passed, execute step 304, otherwise the data is incorrect, and the operation fails;
  • DAP Data Authentication Pattern
  • Step 304 Acquire component data according to the load file data block in the APDU data, store the storage address, and fill the storage address into the load file structure.
  • the loading file is divided into a plurality of loading file data blocks outside the card, and each time a loading file data block is encapsulated into an APDU data and sent to the card, and the RE sends the APDU data received by the card to the card content management module.
  • the card content management module processes the load file data block in each APDU data in units of components, and the components include: a Header component, a Directory component, an Applet component, an Import component, and the like.
  • Step 305 Update the global block number in the card
  • the global block number in the update card is specifically the global block number in the update card plus its current value plus one.
  • Step 306 Determine whether the load file data block is the last load file data block of the load file, if yes, execute step 307, otherwise the operation is successful;
  • determining whether the load file data block is the last load file data block of the load file specifically includes: determining whether the value of the third byte of the APDU data is 0x80, and the loading file data is The block is the last loaded file data block of the loaded file, otherwise the loaded file data block is not the last loaded file data block of the loaded file, and the loaded file has other data blocks.
  • Step 307 Determine whether the load file data block hash value in the card has a value, if yes, go to step 308, otherwise go to step 310;
  • Step 308 Hash all the loaded file data blocks stored in the card as a whole;
  • Step 309 Determine whether the calculation result is equal to the hash value of the load file data block stored in the card, if yes, execute step 310, otherwise the data is incorrect, and the operation fails;
  • Step 310 Store and submit the executable load file structure, and succeed.
  • the submitting is specifically writing data from the cache to the permanent storage area.
  • the fourth embodiment of the present invention provides a specific method for installing an application in a method for managing an application on a card provided in the first embodiment.
  • the data field portion of the APDU data in this embodiment may be regarded as being composed of multiple data blocks.
  • Each data block is an LV structure, that is, a structure of data length + data; see FIG. 4, the method specifically includes:
  • Step 401 Determine whether the first data block of the APDU data is legal, if yes, execute step 402, otherwise the data is incorrect, and the operation fails;
  • the first data block is specifically: an executable load file identifier length + an executable load file identifier;
  • Determining whether the first data block of the APDU data is legal or not includes: determining whether the length of the executable load file identifier in the first data block of the APDU data is within a preset range, and determining the length of the APDU data One data block is legal, otherwise the first data block of the APDU data is invalid;
  • the preset range is: 0x05-0x10.
  • Step 402 Check whether there is a loading file structure corresponding to the executable loading file identifier in the card. If yes, execute step 403. Otherwise, the processing condition is not satisfied, and the operation fails.
  • Step 403 Determine the second data of the APDU data. If the block is legal, if yes, go to step 404. Otherwise, the data is incorrect and the operation fails.
  • the second data block is specifically: an executable module identifier length + an executable module identifier
  • Determining whether the second data block of the APDU data is legal or not includes: determining whether the length of the executable module identifier in the second data block of the APD U data is within a preset range, and determining the length of the APDU data Two data blocks are legal, otherwise the second data block of the APDU data is invalid;
  • the preset range is 0x05-0x10.
  • Step 404 Check whether there is an executable module corresponding to the executable module identifier in the storage space corresponding to the storage address in the load file structure. If yes, execute step 405. Otherwise, the processing condition is not satisfied, and the operation fails; Step 405: Determine whether the third data block of the APDU data is legal. If yes, execute step 406. Otherwise, the data is incorrect and fails.
  • the third data block is specifically: an application identifier length + an application identifier; determining whether the third data block of the APDU data is legal or not specifically includes: determining an application in the third data block of the APDU data Whether the length of the identifier is within a preset range, and then checking each byte of the application identifier in the third data block of the APDU data, if all are 0x00, the third data block of the APDU data is invalid. If not all 0x00, the third data block of the APDU data is legal, otherwise the third data block of the APDU data is invalid;
  • the preset range is 0x05-0x10.
  • Step 406 Check whether there is an application corresponding to the application identifier in the card, if yes, execute step 407; otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 407 Determine whether the fourth data block of the APDU data is legal. If yes, go to step 408. Otherwise, the data is incorrect and fails.
  • Step 408 Determine whether the currently installed application has the default selection authority, if yes, go to step 409, otherwise go to step 411;
  • the application that is installed in this time is specifically an application corresponding to the application identifier in the third data block; determining whether the currently installed application has the default selection authority specifically includes: determining the fourth of the APDU data. Whether the application permission in the data block is 0x04, the application installed this time has the default selection permission, otherwise the application installed this time does not have the default selection permission.
  • Step 409 Determine whether the third byte of the APDU data is a preset value, if the data is wrong, the operation fails; otherwise, step 410 is performed; In this embodiment, the preset value is 0x04.
  • Step 410 Determine whether the card content management module has a default selection permission, if yes, execute step 413; otherwise, the processing condition is not satisfied, and the operation fails;
  • the card content management module determines whether the card content management module has a default selection authority by using the permission attribute of the card content management module, and the permission attribute of the card content management module is one byte of data, and the order from the high position to the status is b8 b7 b6 b5 b4 b3 b2 bl ;
  • Determining whether the card content management module has the default selection authority specifically includes: determining whether the b3 of the license attribute of the card content management module is 1, and the card content management module has the default selection authority; otherwise, the card content management module does not have the default selection authority.
  • Step 411 Determine whether the application permission meets the preset condition. If the first preset condition or the second preset condition is met, step 412 is performed. If the preset condition is not met, the processing condition is not satisfied, and the operation fails;
  • determining whether the application permission meets the preset condition specifically includes: checking the application permission, if the application permission is from the lower end, the first bit, the sixth bit, and the seventh bit are both 0, the eighth bit If the application permission is equal to the first preset condition; if the first bit, the sixth bit, and the seventh bit of the application permission are not all 0 from the lower end, the application permission satisfies the second preset condition, otherwise the application is applied. The permission does not meet the preset conditions;
  • Step 412 Process the installation parameter field in the fifth data block of the APDU data, and perform step 413;
  • the fifth data block is specifically: an installation parameter field length + an installation parameter field, where the installation parameter field is composed of data of one or more TLV structure data blocks (Tn, Ln, Vn).
  • the Vn is composed of 0 or a plurality of TLV structure data blocks (Tn ', Ln ', Vn ').
  • the step 412 specifically includes:
  • Step 412-1 Determine whether the length of the installation parameter field is 0x00, if yes, go to step 413, otherwise go to step 412-2;
  • Step 412-2 Obtain a TLV structure data block of the installation parameter field, and check Tn of the TLV structure data block. If it is 0xC9, go to step 412-3. If it is OxEF, go to step 412-4. Otherwise, the data is incorrect. Failure to do so; Step 412-3: storing the Vn of the TLV structure data block, performing step 412-9;
  • Step 412-4 Obtain a TLV structure data block of Vn of the TLV structure data block, and determine whether Tn ' is legal. If yes, execute step 412-5. Otherwise, the data is incorrect, and the operation fails. Step 412-5: Determine Ln ' If it is 0x02, if yes, go to step 412-6. Otherwise, the data is wrong and the operation fails.
  • Step 412-6 Check Tn ', if 0xC7, obtain and store the volatile data space quota according to Vn ', perform step 412-7, if 0xC8, obtain and store the non-volatile data space quota according to Vn ', Perform step 412-7;
  • Step 412-7 determining whether there is an unprocessed TLV structure data block in the TLV structure data block, if yes, returning to step 412-4, otherwise performing step 412-8;
  • Step 412-8 Determine whether the non-volatile storage space and the volatile storage space in the card can meet the above quota, if yes, execute step 412-9; otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 412-9 Determine whether there is an unprocessed TLV structure data block in the installation parameter field, if yes, go back to step 412-2, otherwise go to step 413.
  • Step 413 Determine whether the sixth data block of the APDU data is legal, if yes, execute step 414; otherwise, the data is incorrect, and the operation fails;
  • the sixth data block is specifically the installation token length + the installation token; determining whether the sixth data block of the APDU data is legal or not specifically includes: determining the sixth data block of the APDU data If the length of the installation token is 0x00, the sixth data block of the APDU data is legal, otherwise the sixth data block of the APDU data is invalid.
  • Step 414 Register an application according to the application identifier in the data field of the APDU data.
  • step 414 is specifically: creating and storing an instance of an executable module corresponding to the executable module identifier in the APDU data.
  • the instance is uniquely associated with the application identifier in the APDU data, and the state of the instance is set to an initial value, the permission of the instance is set according to the application permission in the APDU data, and the associated security domain of the instance is set to The executable load file identifier in the APDU data corresponds to the Execute the associated security domain of the loaded file.
  • Step 415 Determine whether the third byte of the APD U data is equal to the preset value, if yes, go to step 419; otherwise, go to step 416;
  • the preset value is 0x04.
  • Step 416 Set the state of the installed application to SELECTABLE (optional);
  • the step 416 is specifically: setting the state attribute of the installed application to 0x07.
  • Step 417 Determine whether the installed application has the default selection authority, and then execute step 418, otherwise the operation succeeds;
  • Step 418 Set the application to be installed as the default application, and succeed;
  • Step 419 Set the state of the installed application to INSTALLED (installation), and succeed.
  • the step 419 is specifically: setting the state attribute of the installed application to 0x03.
  • the fifth embodiment of the present invention provides a specific method for setting an application state in a method for managing an application on a card provided in the first embodiment.
  • the data domain portion of the APDU data in this embodiment may be regarded as being composed of multiple data blocks.
  • Each data block is an LV structure, that is, a structure of data length + data; see FIG. 5, the method specifically includes:
  • Step 501 Determine whether the first data block and the second data block of the APDU data are both legal. If yes, go to step 502. Otherwise, the data is incorrect and fails.
  • determining whether the first data block of the APDU data is legal or not includes: determining whether the first data block of the APDU data is 0x00, and the first data block of the APDU data is legal. Otherwise, the first data block of the APDU data is invalid;
  • Determining whether the second data block of the APDU data is legal or not includes: Whether the second data block of the APDU data is 0x00, if the second data block of the APDU data is legal, otherwise the second data block of the APDU data is invalid.
  • Step 502 Determine whether the third data block of the APDU data is legal. If yes, go to step 503. Otherwise, the data is incorrect and fails.
  • the third data block is specifically: an application identifier length + an application identifier; determining whether the third data block of the APDU data is legal or not specifically includes: determining an application in the third data block of the APDU data Whether the length of the identifier is within a preset range, and the third data block of the APDU data is legal, otherwise the third data block of the APDU data is invalid;
  • the preset range is 0x05-0x10.
  • Step 503 Check whether there is an application corresponding to the application identifier in the card, if yes, execute step 504; otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 504 Determine whether the status of the application corresponding to the application identifier is INSTALLED, if yes, execute step 505, otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 505 Determine whether the fourth data block of the APDU data is legal. If yes, go to step 506. Otherwise, the data is incorrect and the operation fails.
  • the fourth data block is specifically the application permission length + the application authority; determining whether the fourth data block of the APDU data is legal or not includes: determining the application permission in the fourth data block of the APDU data If the length is 0x01, then the fourth data block of the APDU data is legal, otherwise the fourth data block of the APDU data is invalid.
  • Step 506 Determine whether the fifth data block of the APDU data is legal. If yes, go to step 507. Otherwise, the data is incorrect and fails.
  • the fifth data block is specifically a parameter domain length + a parameter field.
  • the determining whether the fifth data block of the APDU data is legal or not includes: determining a parameter domain in the fifth data block of the APDU data. Whether the length is 0x00, yes, then
  • Step 507 Determine whether the sixth data block of the APDU data is legal, if yes, execute step 508; otherwise, the data is incorrect, and the operation fails;
  • the sixth data block is specifically: a selectable token length + a selectable token
  • Determining whether the sixth data block of the APDU data is legal or not includes: determining whether the selectable token length in the sixth data block of the APDU data is 0x00, and the sixth data block of the APDU data is Legal, otherwise the sixth data block of the APDU data is invalid.
  • Step 508 Set the status of the application corresponding to the application identifier to SELECTABLE
  • step 508 specifically sets the state attribute of the application corresponding to the application identifier to 0x07.
  • Step 509 Determine whether the application corresponding to the application identifier has a default selection permission, if yes, execute step 510, otherwise the operation succeeds;
  • Step 510 Determine whether the card content management module has a default selection permission, if yes, execute step 511, otherwise the processing condition is not satisfied, and the operation fails;
  • the card content management module determines whether the card content management module has a default selection authority by using the permission attribute of the card content management module, and the permission attribute of the card content management module is one byte of data, and the order from the high position to the status is b8 b7 b6 b5 b4 b3 b2 bl ;
  • Determining whether the card content management module has the default selection authority specifically includes: determining whether the b3 of the license attribute of the card content management module is 1, and the card content management module has the default selection authority; otherwise, the card content management module does not have the default selection authority.
  • Step 511 The application corresponding to the application identifier is set as the default application, and the operation is successful.
  • the sixth embodiment of the present invention provides a specific method for updating an associated security domain of an application in a method for managing applications on a card provided in the first embodiment.
  • the data domain portion of the APDU data in this embodiment may be regarded as multiple data. Composed of blocks, each block is one LV structure, that is, data length + data structure; Referring to FIG. 6, the method specifically includes: Step 601: Determine whether the first data block of the APDU data is legal, if yes, execute step 602, otherwise the data error occurs. failure;
  • the first data block is specifically: a security domain identifier length + a security domain identifier
  • Determining whether the first data block of the APDU data is legal or not includes: determining whether the length of the security domain identifier in the first data block of the APDU data is within a preset range, and the first of the APDU data is The data block is legal, otherwise the first data block of the APDU data is invalid;
  • the preset range is 0x05-0x10.
  • Step 602 Check whether there is an application corresponding to the security domain identifier in the card, and then execute step 603. Otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 603 Determine whether the application corresponding to the security domain identifier is a card content management module, if the processing condition is not satisfied, the operation fails, otherwise step 604 is performed;
  • Step 604 Determine whether the second data block of the APDU data is legal. If yes, go to step 605. Otherwise, the data is incorrect and the operation fails.
  • determining whether the second data block of the APDU data is legal or not includes: determining whether the second data block of the APDU data is 0x00, and the second data block of the APDU data is legal. Otherwise, the second data block of the APDU data is invalid.
  • Step 605 Determine whether the status of the application corresponding to the security domain identifier is INSTALLED, if yes, execute step 606, otherwise the processing condition is not satisfied, and the operation fails;
  • Step 606 Determine whether the third data block of the APDU data is legal. If yes, go to step 607. Otherwise, the data is incorrect and the operation fails.
  • the third data block is specifically: an application identifier length + an application identifier; determining whether the third data block of the APDU data is legal or not specifically includes: determining an application in the third data block of the APDU data Whether the identifier length is within a preset range, and the third data block of the APDU data is legal, otherwise the APDU data is Three data blocks are illegal;
  • the preset range is 0x05-0x10.
  • Step 607 Check whether there is an application corresponding to the application identifier in the card, if yes, execute step 608; otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 608 Determine whether the application corresponding to the security domain identifier has security domain authority, if yes, execute step 609; otherwise, the processing condition is not satisfied, and the operation fails;
  • the step 608 specifically includes: determining whether the highest bit of the privilege attribute of the application corresponding to the security domain identifier is 1, and the application corresponding to the security domain identifier has the security domain privilege; otherwise, the application corresponding to the security domain identifier Does not have security domain permissions.
  • Step 609 Determine whether the status of the application corresponding to the security domain identifier is LOCKED. If the condition is not satisfied, the operation fails. Otherwise, step 610 is performed. Step 610: Determine the status of the application corresponding to the security domain identifier. If it is PERSONALIZED (personalized), if yes, go to step 611. Otherwise, the processing condition is not satisfied, and the operation fails.
  • PERSONALIZED personalized
  • Step 611 Determine whether the fourth data block and the fifth data block of the APDU data are both legal. If yes, go to step 612. Otherwise, the data is incorrect and fails.
  • determining whether the fourth data block of the APDU data is legal or not includes: determining whether the fourth data block of the APDU data is 0x00, and the fourth data block of the APDU data is legal. Otherwise, the fourth data block of the APDU data is invalid;
  • Determining whether the fifth data block of the APDU data is legal or not includes: determining whether the fifth data block of the APDU data is 0x00, and then the fifth data block of the APDU data is legal, otherwise the APDU data The fifth data block is illegal.
  • Step 612 Determine whether the sixth data block of the APDU data is legal. If yes, go to step 613. Otherwise, the data is incorrect and fails.
  • the sixth data block is specifically: an extradition token length + an extrapolation token; determining whether the sixth data block of the APDU data is legal or not specifically includes: determining a sixth data block of the APDU data Whether the length of the extradition token is 0x00, is the The sixth data block of the APDU data is legal, otherwise the sixth data block of the APDU data is invalid.
  • Step 613 Determine whether the application corresponding to the application identifier has the security domain authority, if the processing condition is not satisfied, the operation fails; otherwise, step 614 is performed;
  • the step 613 specifically includes: determining whether the highest bit of the permission attribute of the application corresponding to the application identifier is 1 or not, and the application corresponding to the application identifier has the security domain authority; otherwise, the application corresponding to the application identifier is not secure. Domain permissions.
  • Step 614 Set the associated security domain of the application corresponding to the application identifier to be the application corresponding to the security domain identifier, and succeed.
  • Example 7
  • the seventh embodiment of the present invention provides a specific method for managing a personalized application in a method for managing a card provided in the first embodiment.
  • the data field portion of the APDU data in this embodiment may be regarded as being composed of multiple data blocks.
  • Each data block is an LV structure, that is, a data length + a structure of data; see FIG. 7, the method specifically includes:
  • Step 701 Determine whether the first data block and the second data block of the APDU data are both legal. If yes, go to step 702. Otherwise, the data is incorrect and fails.
  • determining whether the first data block of the APDU data is legal or not includes: determining whether the first data block of the APDU data is 0x00, and the first data block of the APDU data is legal. Otherwise, the first data block of the APDU data is invalid;
  • Determining whether the second data block of the APDU data is legal or not includes: determining whether the second data block of the APDU data is 0x00, and then the second data block of the APDU data is legal, otherwise the APDU data The second data block is illegal.
  • Step 702 Determine whether the third data block of the APDU data is legal. If yes, go to step 703. Otherwise, the data is incorrect and fails.
  • the third data block is specifically an application identifier length + an application identifier; determining whether the third data block of the APDU data is legal or not includes: Whether the application identifier length in the third data block of the APDU data is within a preset range, and the third data block of the APDU data is legal, otherwise the third data block of the APDU data is invalid;
  • the preset range is 0x05-0x10.
  • Step 703 Check whether there is an application corresponding to the application identifier in the card, and if yes, execute step 704. Otherwise, the processing condition is not satisfied, and the operation fails;
  • Step 704 Determine whether the associated security domain of the application corresponding to the application identifier is a card content management module. If yes, execute step 705. Otherwise, the processing condition is not satisfied, and the operation fails.
  • Step 705 Determine the fourth of the APDU data. Whether the data block, the fifth data block, and the sixth data block are both legal, if yes, step 706 is performed; otherwise, the data is incorrect, and the operation fails;
  • determining whether the fourth data block of the APDU data is legal or not includes: determining whether the fourth data block of the APDU data is 0x00, and the fourth data block of the APDU data is legal. Otherwise, the fourth data block of the APDU data is invalid;
  • Determining whether the fifth data block of the APDU data is legal or not includes: determining whether the fifth data block of the APDU data is 0x00, and then the fifth data block of the APDU data is legal, otherwise the APDU data The fifth data block is illegal;
  • Determining whether the sixth data block of the APDU data is legal or not includes: determining whether the sixth data block of the APDU data is 0x00, and the sixth data block of the APDU data is legal, otherwise the APDU data is The sixth data block is illegal.
  • Step 706 Set the state of the application corresponding to the application identifier to PERSONLIZED, and succeed.
  • the eighth embodiment of the present invention provides a specific method for deleting an application and an executable load file in the method for managing an application on a card provided in the first embodiment.
  • the data field portion of the APDU data in this embodiment may be regarded as multiple Composed of data blocks, each data block is one The LV structure, that is, the data length + the structure of the data;
  • the method specifically includes: Step 801: Determine whether the first data block of the APDU data is legal, if yes, execute step 802, otherwise the data is incorrect, Failed;
  • determining whether the first data block of the APDU data is legal or not includes: determining whether the first data block of the APDU data is 0x4f,
  • the first data block of the APDU data is legal, otherwise the first data block of the APDU data is invalid.
  • Step 802 Determine whether the second data block of the APDU data is legal. If yes, go to step 803. Otherwise, the data is incorrect.
  • the preset range is: 0x05-0x10.
  • Step 803 Check whether there is an application corresponding to the data domain identifier in the card, if yes, go to step 804, otherwise go to step 805;
  • Step 804 Determine whether the fourth byte of the APD U data is equal to the preset value, if yes, go to step 805, otherwise go to step 809;
  • the preset value is 0x80.
  • Step 805 Check whether there is an executable loading file corresponding to the data domain identifier in the card. If yes, go to step 806. Otherwise, the processing condition is not satisfied, and the operation fails.
  • Step 806 Determine whether the fourth byte of the APDU data is equal to a preset value, if yes, go to step 807, otherwise go to step 808;
  • the preset value is 0x80.
  • Step 807 Deleting an application corresponding to the data domain identifier and an executable loading file corresponding to the data domain identifier, and succeeding;
  • Step 808 deleting the executable loading file corresponding to the data domain identifier, and succeeding;
  • Step 809 Check whether the application corresponding to the data domain identifier is an associated security domain of another application or other executable load file, if the processing condition is not satisfied, the operation fails; otherwise, step 810 is performed;
  • Step 810 Determine whether the application corresponding to the data domain identifier is a card content management module, if the processing condition is not satisfied, the operation fails; otherwise, step 811 is performed;
  • Step 811 The application corresponding to the data domain identifier is deleted, and the operation succeeds.
  • the smart card is simply referred to as a card.
  • a method for implementing management card data is provided by the embodiment of the present invention.
  • the method specifically includes: when the first card data management module receives the APDU (Application Protocol Data Unit) data sent by the operating environment, As the current first card data management module, perform the following steps:
  • APDU Application Protocol Data Unit
  • Step 901 Check the INS (instruction code) of the APDU data, if it is 0xE8, execute step 1101 to step 1129; if it is 0xE6, execute step 902; if it is 0xE4, execute step 1601 to step 1625; if it is other valid values
  • the APDU data is another valid command that is not content management, and performs corresponding operations according to the APDU data; otherwise, the APDU data is an invalid command, and generates and returns a corresponding status code;
  • the other valid values include: 0xA4, 0x78, 0x7 A, 0x82, 0x50, 0xE2, 0xF0, 0xD8, 0xF2, OxCA;
  • Step 902 Check the PI (first parameter) of the APDU data, if it is 0x02, perform step 1001 to step 1028; if it is 0x04 or OxOC, perform step 1201 to step 1235; if it is 0x08, perform step 1301 to step 1324. If it is 0x10, step 1401 to step 1428 is performed; if it is 0x20, step 1501 to step 1517 is performed; otherwise, the APDU data is an invalid command, and a corresponding status code is generated and returned;
  • the first card data management module is a special application in the card, and is a representative of the application provider on the card;
  • steps 1001 to 1028 are specifically as follows: Step 1001: Determine whether the APDU data is a command header of a legal preload command, if yes, go to step 1002, otherwise go to step 1027;
  • the APDU data is a legal preload command.
  • Command header 0x80 or 0x84
  • P2 second parameter
  • Lc data field length
  • Step 1002 Determine whether the current state of the card is TERMINATED or CARD_LOCKED. If yes, go to step 1027. Otherwise, go to step 1003. Specifically, determine the status of the card by its status attribute.
  • the status attribute of the card is one word.
  • the data of the section, from high to low, is 138137136135134133132131, and the status of the card includes preparation OP_READY, initialization INITIALIZED, safety SECURED, lock CARD_LOCKED and termination TERMINATED, see the following table:
  • step 1001 and step 1002 may be reversed: first, it is determined whether the current state of the card is termination or card locking, and if yes, step 1027 is performed; otherwise, it is determined whether the APDU data is a legal preload command command header, Then step 1003 is performed, otherwise step 1027 is performed;
  • Step 1003 Receive the data field part of the preload command to obtain a complete preload command;
  • Step 1004 Determine whether the current state of the first card data management module is PERSONALIZED, if yes, go to step 1005, otherwise go to step 1027;
  • the first card data management module determines the status of the current first card data management module by using the status attribute of the current first card data management module, and the status attribute of the first card data management module is one byte of data, from high to low.
  • the status of the first card data management module includes INSTALLED installed, SELECTABLE selectable, personalized PERSONALIZED and lock LOCKED, see the following table:
  • Step 1005 Determine whether the current first card data management module has proxy authority, if yes, go to step 1006, otherwise go to step 1027;
  • the first card data management module determines whether the current first card data management module has proxy authority by using the permission attribute of the current first card data management module, and the permission attribute of the first card data management module is one byte data, from a high position
  • the lower order is b8b7b6b5b4b3b2bl, and when both b8 and b6 are 1, the first card data management module has proxy authority;
  • Step 1006 Determine whether the card meets the security condition, if yes, go to step 1007, otherwise go to step 1027;
  • the first card data management module determines whether the card satisfies the security condition by checking the security flag of the card. If the security flag is set, the card satisfies the security condition, and if the security flag is not set, the card does not satisfy the security condition.
  • the security flag is set when the card correctly executes the legal command with the INS byte value of 0x50 and the legal command with the INS byte value of 0x82.
  • Step 1007 Check the security level of the card, if it is the first level, go to step 1010, if it is the second level, go to step 1008, if it is the third level, go to step 1009;
  • the preloading command is the plaintext of the message data
  • the preloading command is the message data plaintext and the message authentication code (Message) Combination of Authentication Code (MAC)
  • MAC message authentication code
  • Step 1008 Determine, according to the message data plaintext and MAC (message authentication code) in the preloading command, whether the preloading command is complete, if yes, go to step 1010, otherwise go to step 1027;
  • MAC message authentication code
  • the determining, according to the message data plaintext and the message authentication code in the preloading command, whether the preloading command is complete or not includes: decrypting the message authentication code by using the agreed session key to obtain a decryption result, and according to the agreement
  • the hash function calculates the plaintext of the message data to obtain a calculation result, and determines whether the decryption result is the same as the calculation result, and the preloading command is complete, otherwise the preloading command is incomplete;
  • Step 1009 Determine whether the preloading command is complete according to the message data ciphertext and the MAC in the preloading command, if yes, execute step 1010, otherwise perform step 1027; wherein the message according to the preloading command is performed.
  • the data ciphertext and the message authentication code determine whether the preloading command is complete or not, including: decrypting the message data ciphertext to obtain the message data plaintext, decrypting the message authentication code by using the agreed session key, and obtaining the decrypted result, and simultaneously dispersing according to the agreement
  • the column function calculates the plaintext of the message data to obtain a calculation result, and determines whether the decryption result is the same as the calculation result, and the preloading command is complete, otherwise the preloading command is incomplete;
  • Step 1010 Determine whether the length of the load file identifier in the preload command is within the preset range, if yes, go to step 1011, otherwise go to step 1027;
  • Step 1011 Determine whether the load file identifier in the preload command is legal, if yes, go to step 1012, otherwise go to step 1027;
  • the loading file identifier is invalid when each byte thereof is 0x00, otherwise legal;
  • Step 1012 Check whether the loading file corresponding to the loading file identifier already exists in the card. If yes, go to step 1027. Otherwise, go to step 1013.
  • Step 1013 Determine whether the length of the security domain identifier in the preload command is within a preset range. If yes, go to step 1014. Otherwise, go to step 1027.
  • the preset range is 0x05-0x10;
  • Step 1014 Determine whether the security domain identifier in the preload command is legal. If yes, go to step 1015. Otherwise, go to step 1027.
  • the security domain identifier is invalid when each byte is 0x00, otherwise it is legal;
  • Step 1015 Check whether there is an application corresponding to the security domain identifier in the preloading command in the card, if yes, go to step 1016; otherwise, go to step 1027;
  • Step 1016 Determine whether the application corresponding to the security domain identifier in the preloading command has the security domain authority. If yes, go to step 1017. Otherwise, go to step 1027.
  • the privilege attribute of the application determines whether it has the security domain privilege, and the privilege attribute of the application is one byte of data, and the order from the high to the low is b8 b7 b6 b5 b4 b3 b2 bl, and when b8 is 1, the application is safe.
  • Step 1017 Determine whether the application corresponding to the security domain identifier in the preloading command is the current first card data management module, if yes, go to step 1019, otherwise go to step 1018;
  • Step 1018 Determine whether the status of the application corresponding to the security domain identifier in the preload command is PERSONALIZED. If yes, go to step 1019. Otherwise, go to step 1027.
  • Step 1019 Set an associated security domain of the load file corresponding to the load file identifier in the preload command to be an application corresponding to the security domain identifier in the preload command.
  • Step 1020 Determine whether the length of the load file data block hash value in the preload command is a preset value, if yes, go to step 1021; otherwise, go to step 1027;
  • the preset value is 0x14;
  • Step 1021 Store a load file data block hash value in the preload command and set a hash value verification flag.
  • Step 1022 Process a loading parameter field in the preloading command.
  • the loading parameter field is a TLV structure, that is, a data consisting of multiple labels + length + value format, and different operations are performed according to different labels, and detailed descriptions are not performed herein;
  • Step 1023 Determine whether the length of the load token in the preload command is 0x80, if yes, go to step 1024, otherwise go to step 1027;
  • Step 1024 Send data required for calculating the loading token to the second card data management module, and receive a calculation result returned by the second card data management module, and determine whether the calculation result is the same as the loading token in the preloading command. , if yes, go to step 1025, otherwise go to step 1027;
  • the second card data management module is also a special application in the card; specifically, sending P1, P2, length of valid data, loading file identifier length, loading file identifier, and security domain identifier in the preloading command Length, security domain ID, load file data block hash length, load file data block hash value, load parameter field length, and load parameter field to the second card data management module, regarding the card issuer verifying the process of loading the token, No detailed description is given here;
  • Step 1025 Newly load the file structure, and initialize the global block number.
  • the initialization global block number is 0, and the newly created loading file structure includes: creating an object of an executable loading file structure in the cache, setting each attribute value of the object to a default value, and the attribute value of the object
  • the storage address of each load file data block in the cache and the attributes of the executable load file, and the attributes of the executable load file, such as the executable load file association security domain identifier, are not specifically described herein;
  • Step 1026 Set the return data to 0x00, and perform step 1027.
  • Step 1027 Generate a corresponding status code.
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1028 Return the set return data and/or the generated status code.
  • steps 1101 to 1129 are as follows:
  • Step 1101 Determine whether the APDU data is a command header of a legal load command, if yes, go to step 1102, otherwise go to step 1128;
  • the APDU data is legal;
  • Step 1102 Determine whether the current state of the card is TERMANATED or CARD_LOCKED, if yes, go to step 1128, otherwise go to step 1103;
  • Step 1103 The data field part of the load command is received, and a complete load command is obtained.
  • Step 1105 Determine whether the current first card data management module has proxy authority, if yes, go to step 1106, otherwise go to step 1128;
  • Step 1106 Determine whether the card meets the security condition, if yes, go to step 1107, otherwise, go to step 1128;
  • Step 1107 Check the security level of the card. If it is the first level, go to step 1110. If it is the second level, go to step 1108. If it is the third level, go to step 1109.
  • the loading command is a plaintext of the message data
  • the security level of the card is the second level
  • the loading command is a combination of the message data plaintext and the message authentication code.
  • the security level of the card is the third level, and the loading command is a combination of the message data ciphertext and the message authentication code;
  • Step 1108 Determine whether the loading command is complete according to the plaintext and MAC of the message data in the loading command, if yes, execute step 1110; otherwise, perform step 1128;
  • the determining, according to the message data in the loading command, the plaintext and the MAC Whether the loading command is complete or not includes: decrypting the MAC by using the agreed session key to obtain a decryption result, and calculating the plaintext of the message data according to the agreed hash function to obtain a calculation result, and determining whether the decryption result and the calculation result are The same, the load command is complete, otherwise the load command is incomplete;
  • Step 1109 Determine whether the loading command is complete according to the message data ciphertext and the MAC in the loading command, if yes, execute step 1110; otherwise, perform step 1128;
  • the determining whether the loading command is complete according to the message data ciphertext and the MAC in the loading command includes: decrypting the message data ciphertext to obtain the message data plaintext, and decrypting the MAC by using the agreed session key to obtain the decryption
  • the calculation result is obtained by calculating the plaintext of the message data according to the agreed hash function, and determining whether the decryption result and the calculation result are the same, if the loading command is complete, otherwise the loading command is incomplete;
  • Step 1110 Determine whether P2 in the load command is equal to the global block number, if yes, go to step 1111, otherwise go to step 1128;
  • Step 1111 Determine whether the global block number is 0, if yes, go to step 1112, otherwise go to step 1113;
  • Step 1112 The DAP (Data Authentication Pattern) block information in the load command is verified, if the verification is passed, step 1113 is performed, and if the verification fails, step 1128 is performed;
  • the load file is divided into a plurality of load file data blocks outside the card, and each load command includes a load file data block.
  • each load command includes a load file data block.
  • the loading command further includes DAP block information, where the DAP block information includes a load file data block signature value, and the first card data management module calculates the key pair DAP block information according to the application provider DAP stored by the current first card data management module. The loaded file data block signature value is verified;
  • Step 1113 Determine whether there is a hash value verification flag in the card, if yes, save the load file data block in the load command, perform step 1114, otherwise directly execute step 1114;
  • Step 1114 Determine whether there is any uncommitted storage component in the executable load file structure, if yes, go to step 1118, otherwise go to step 1115;
  • the application processes the loaded load file data block in units of components to obtain an executable load file structure, where the components include: a Header component, a Directory component, an Applet component, an Import component, and the like;
  • Step 1115 Check whether the component number and component size are included in the load command, if yes, go to step 1116, otherwise go to step 1128;
  • Step 1116 Read the component number, determine whether the component number is legal, if yes, go to step 1117, otherwise go to step 1128;
  • Step 1117 According to the component size Distribute the corresponding size of space;
  • Step 1118 Start processing the load file data block in the load command;
  • Step 1119 Determine whether the current component is processed, if yes, go to step 320, otherwise, go to step 1121;
  • the determining whether the current component is processed is to determine whether a size of data that has been processed in the current component is equal to a size of the current component;
  • Step 1120 Submit the processing result of the current component, and perform step 1121;
  • Step 1121 Determine whether there is still unprocessed load file data block data, if yes, go back to step 1115, otherwise go to step 1122;
  • Step 1122 The global block number is incremented, and it is determined whether P1 of the load command is 0x80, if yes, step 1123 is performed, otherwise step 1127 is performed;
  • the global block number is incremented by one
  • Step 1123 Determine whether there is a hash value verification flag in the card, if yes, go to step 1124; otherwise, go to step 1125;
  • Step 1124 Perform a hash calculation on the stored file data block, and determine whether the calculation result is equal to the load file data block hash value. If yes, go to step 1125. Otherwise, go to step 1128.
  • Step 1125 Submit the storage executable file structure;
  • Step 1126 Send the data required for calculating the receipt to the second card data management module, receive the receipt returned by the second card data management module, and set the return data to the Receipt, perform step 1128;
  • the length of the load file identifier corresponding to the load file data block in the load command, the load file identifier, the length of the security domain identifier, and the security domain identifier are sent to the card provider module.
  • Step 1127 Set the return data to 0x00, and perform step 1128;
  • Step 1128 Generate a corresponding status code.
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1129 Return the set return data and/or the generated status code; preferably, referring to FIG. 12, steps 1201 to 1235 are as follows:
  • Step 1201 Determine whether the APD U data is a command header of a legal installation command, if yes, go to step 1202, otherwise go to step 1234;
  • the APDU data is a command header of a legal installation command
  • Step 1202 Determine whether the current state of the card is TERMANATED or CARD_LOCKED, if yes, go to step 1234, otherwise go to step 1203;
  • Step 1203 Receive the data field part of the installation command to obtain a complete installation command;
  • Step 1204 Determine whether the current state of the first card data management module is PERSONALIED, if yes, go to step 1205, otherwise go to step 1234;
  • Step 1205 Determine whether the current first card data management module has proxy authority, if yes, go to step 1206, otherwise go to step 1234;
  • Step 1206 Determine whether the card meets the security condition, if yes, go to step 1207, otherwise go to step 1234;
  • Step 1207 Check the security level of the card. If it is the first level, perform step 1210. If the level is the second level, the step 1208 is performed. If the level is the third level, the step 1209 is performed. Specifically, if the security level of the card is the first level, the installation command is the clear text of the message data, and if the security level of the card is the first level The second level, the installation command is a combination of the message data plaintext and the message authentication code. If the security level of the card is the third level, the installation command is a combination of the message data ciphertext and the message authentication code;
  • Step 1208 Determine whether the installation command is complete according to the plaintext and the MAC address of the message in the installation command. If yes, go to step 1210. Otherwise, execute step 1234.
  • the message is based on the message data in the installation command. Determining whether the installation command is complete or not includes: decrypting the MAC by using the agreed session key to obtain a decryption result, and calculating the plaintext of the message data according to the agreed hash function to obtain a calculation result, determining the decryption result and the calculating Whether the result is the same, if the installation command is complete, otherwise the installation command is incomplete;
  • Step 1209 Determine whether the installation command is complete according to the message data ciphertext and the MAC in the installation command, if yes, execute step 1210, otherwise perform step 1234; wherein, according to the message data ciphertext in the installation command And the MAC determining whether the installation command is complete includes: decrypting the message data ciphertext to obtain the message data plaintext, decrypting the MAC by using the agreed session key to obtain a decryption result, and calculating the plaintext of the message data according to the agreed hash function. Obtaining a calculation result, determining whether the decryption result and the calculation result are the same, if the installation command is complete, otherwise the installation command is incomplete;
  • Step 1210 Determine whether the length of the executable load file identifier in the installation command is within a preset range, if yes, go to step 1211, otherwise go to step 1234;
  • the preset range is 0x05-0x10; the corresponding identifier of the executable load file is identified, if yes, step 1212 is performed; otherwise, step 1234 is performed;
  • Step 1212 Determine whether the security domain associated with the executable load file corresponding to the executable load file identifier in the installation command is the current first card data management module, and Go to step 1213, otherwise go to step 1234;
  • Step 1213 Determine whether the executable module identifier length in the installation command is within the preset range, if yes, go to step 1214, otherwise go to step 1234;
  • the preset range is 0x05-0x10; the corresponding executable module is identified, if yes, step 1215 is performed, otherwise step 1234 is performed;
  • Step 1215 Determine whether the application identifier length in the installation command is within a preset range, if yes, go to step 1216, otherwise go to step 1234;
  • the preset range is 0x05-0x10;
  • Step 1216 Determine whether the application identifier in the installation command is legal, if yes, go to step 1217, otherwise go to step 1234;
  • the application identifier is invalid when each byte thereof is 0x00, otherwise the method is legal;
  • Step 1217 Determine whether there is an application corresponding to the application identifier in the installation command in the card, if yes, go to step 1234, otherwise go to step 1218;
  • Step 1218 Determine whether the application permission length in the installation command is 0x01, if yes, go to step 1219, otherwise go to step 1234;
  • Step 1219 Determine whether the application permission in the installation command is 0x04, if yes, execute step 1220, otherwise perform step 1222;
  • Step 1220 Determine whether P1 of the installation command is 0x04, if yes, go to step 1234, otherwise go to step 1221.
  • Step 1221 Determine whether the second card data management module has a default selection authority, if yes, go to step 1222, otherwise go to step 1234;
  • the permission attribute of the second card data management module determines whether it has a default selection authority, and the permission attribute of the second card data management module is one byte of data, which is 138 137 136 135 134 134 133 132 131 from high to low.
  • the permission attribute of the second card data management module is one byte of data, which is 138 137 136 135 134 134 133 132 131 from high to low.
  • the second card data management module has a default selection authority
  • Step 1222 determining that the lower end of the application permission of the installation command starts from the first bit, Whether the 6th bit and the 7th bit are both 0, if yes, go to step 1223, otherwise go to step 1224;
  • Step 1223 Determine whether the highest bit of the application permission of the installation command is 1, and then execute step 1224, otherwise step 1234;
  • Step 1224 Process the installation parameter field in the installation command.
  • Step 1225 Determine whether the length of the installation token in the installation command is 0x80, if yes, go to step 1226, otherwise go to step 1234;
  • Step 1226 Send the data required for calculating the installation token to the second card data management module, and receive the calculation result returned by the second card data management module, and determine whether the calculation result and the installation token in the installation command are the same. If yes, go to step 1227, otherwise go to step 1234;
  • the P1, P2, the length of the valid data, the length of the executable load file identifier, the executable load file identifier, the executable module identifier length, the executable module identifier, the application identifier length, the application identifier, and the application are sent.
  • Step 1227 Register the application according to the data in the data field of the installation command;
  • Step 1228 Determine whether P1 in the installation command is 0x04, if yes, go to step 1232, otherwise go to step 1229;
  • Step 1229 Set the state of the application corresponding to the application identifier in the installation command to SELECTABLE (optional);
  • step 1229 is to set a value of a status attribute of an application corresponding to the application identifier in the installation command to 0x07;
  • Step 1230 Determine whether the application permission in the installation command is 0x04, if yes, execute step 1231, otherwise perform step 1233;
  • Step 1231 Set the application corresponding to the application identifier in the installation command as the default application, and perform step 1233.
  • Step 1232 Set the state of the application corresponding to the application identifier in the installation command to INSTALLED (installation), and perform step 1233; Specifically, the step 1232 includes: setting a value of a state attribute of an application corresponding to the application identifier in the obtained command to 0x03;
  • Step 1233 Send the data required for calculating the receipt to the second card data management module, receive the receipt returned by the second card data management module, set the return data to the receipt, and perform step 1234;
  • Step 1234 Generate a corresponding status code.
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1235 Return the set return data and/or the generated status code; preferably, see Figure 13, step 1301 to step 1324 are as follows:
  • Step 1301 Determine whether the APDU data is a command header of a legal selectable command, if yes, execute step 1302, otherwise perform step 1323;
  • the APDU data is a command header of a legal selectable command
  • Step 1302 Determine whether the current state of the card is TERMANATED or CARD_LOCKED, if yes, go to step 1323, otherwise go to step 1303;
  • Step 1303 Receive a data field portion of the selectable command to obtain a complete selectable command.
  • Step 1304 Determine whether the current state of the first card data management module is PERSONALIZED (personalized), if yes, execute step 1305, otherwise perform step 1323;
  • Step 1305 Determine whether the current first card data management module has proxy authority, if yes, go to step 1306, otherwise go to step 1323;
  • Step 1306 Determine whether the card meets the security condition, if yes, go to step 1307, otherwise, go to step 1323;
  • Step 1307 Check the security level of the card. If it is the first level, perform step 1310. If the level is the second level, the step 1308 is performed. If the level is the third level, the step 1309 is performed. Specifically, if the security level of the card is the first level, the selectable command is the plaintext of the message data, if the security level of the card is The second level, the selectable command is a combination of the message data plaintext and the message authentication code. If the security level of the card is the third level, the selectable command is a combination of the message data ciphertext and the message authentication code;
  • Step 1308 Determine whether the selectable command is complete according to the message data plaintext and MAC in the selectable command, if yes, execute step 1310, otherwise perform step 1323; wherein, according to the message data in the selectable command Whether the plaintext and the MAC determine whether the selectable command is complete or not includes: decrypting the MAC by using the agreed session key to obtain a decrypted result, and calculating the plaintext of the message data according to the agreed hash function to obtain a calculation result, and determining the decrypted result. Whether the result of the calculation is the same, if the selectable command is complete, otherwise the selectable command is incomplete
  • Step 1309 Determine whether the selectable command is complete according to the message data ciphertext and MAC in the selectable command, if yes, execute step 1310, otherwise perform step 1323; wherein, according to the message in the selectable command The data ciphertext and the MAC determine whether the selectable command is complete or not, including: decrypting the message data ciphertext to obtain the message data plaintext, decrypting the MAC by using the agreed session key to obtain a decryption result, and simultaneously using the hash function according to the agreed hash function The data is calculated in plain text to obtain a calculation result, and it is judged whether the decryption result and the calculation result are the same, and the selectable command is complete, otherwise the selectable command is incomplete;
  • Step 1310 Determine whether the first two bytes of data in the data field of the selectable command are all 0x00, if yes, execute step 1311; otherwise, perform step 1323;
  • Step 1311 Determine whether the application identifier length in the selectable command is within a preset range, if yes, execute step 1312; otherwise, perform step 1323;
  • the preset range is 0x05-0x10;
  • Step 1312 Determine whether there is an application corresponding to the application identifier in the selectable command in the card, if yes, go to step 1313, otherwise go to step 1323;
  • Step 1313 Determine the status of the application corresponding to the application identifier in the selectable command. If it is INSTALLED (installation), if yes, go to step 1314, otherwise go to step 1323; Step 1314: Determine whether the application permission length in the selectable command is 0x00, if yes, go to step 1315, otherwise go to step 1323;
  • Step 1315 Determine whether a byte data after the application permission in the selectable command is 0x00, if yes, go to step 1316; otherwise, go to step 1323; if yes, go to step 1317; otherwise, go to step 1323;
  • Step 1317 Send data required for calculating the installation token to the second card data management module, and receive a calculation result returned by the second card data management module, and determine whether the calculation result is the same as the installation token in the selectable command. If yes, go to step 1318, otherwise go to step 1323;
  • the P1, P2, the valid data length, the executable load file identifier length, the 0x00, the 0x00, the application identifier length, the application identifier, the application permission length, the application permission, and the 0x00 for the second card data management of the selectable command are sent.
  • Step 1318 Set the state of the application corresponding to the application identifier in the selectable command to SELECTABLE (optional);
  • step 1318 is specifically: setting a value of a status attribute of an application corresponding to the application identifier in the selectable command to 0x07;
  • Step 1319 Determine whether P1 in the selectable command is 0x04, if yes, execute step 1320, otherwise perform step 1322;
  • Step 1320 Determine whether the second card data management module has a default selection authority, if yes, go to step 1321. Otherwise, go to step 1323;
  • Step 1321 Set the application corresponding to the application identifier in the selectable command to be the default application, and perform step 1322;
  • Step 1322 Set the return data to 0x00, and perform step 1323;
  • Step 1323 Generate a corresponding status code.
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1324 Return the set return data and/or the generated status code; preferably, referring to FIG. 14, steps 1401 to 1428 are as follows:
  • Step 1401 Determine whether the APDU data is a command header of a legal extradition command, if yes, execute step 1402; otherwise, execute step 1427;
  • the APDU data is a command header of a legal extradition command
  • Step 1402 Determine whether the current state of the card is TERMANATED or CARD_LOCKED, if yes, go to step 1427; otherwise, go to step 1403;
  • Step 1403 Receive the data domain part of the extradition command to obtain a complete extradition command;
  • Step 1404 Determine whether the current state of the first card data management module is PERSONALIZED, if yes, go to step 1405; otherwise, go to step 1427;
  • Step 1405 Determine whether the current first card data management module has proxy authority, if yes, go to step 1406, otherwise go to step 1427;
  • Step 1406 Determine whether the card meets the security condition, if yes, go to step 1407, otherwise, go to step 1427;
  • Step 1407 Check the security level of the card. If it is the first level, go to step 1410. If it is the second level, go to step 1408. If it is the third level, go to step 1409.
  • the extradition command is a plaintext of the message data
  • the extradition command is a combination of the message data plaintext and the message authentication code.
  • the security level of the card is the third level, and the extradition command is a combination of the message data ciphertext and the message authentication code;
  • Step 1408 Determine, according to the plaintext and MAC of the message data in the extradition command, whether the extradition command is complete, if yes, execute step 1410; otherwise, perform step 1427;
  • the determining, according to the plaintext and the MAC of the message data in the extradition command, whether the extradition command is complete includes: decrypting the MAC by using the agreed session key to obtain a decryption result, and simultaneously using the hash function according to the agreed hash function
  • the plain text is calculated to obtain a calculation result, and it is judged whether the decrypted result and the calculation result are the same.
  • the extradition order is complete, otherwise the extradition order is incomplete;
  • Step 1409 Determine, according to the message data ciphertext and the MAC in the extradition command, whether the extradition command is complete, if yes, go to step 1410; otherwise, go to step 1427;
  • the determining, according to the message data ciphertext and the MAC in the extradition command, whether the extradition command is complete includes: decrypting the message data ciphertext to obtain the message data plaintext, and decrypting the MAC by using the agreed session key to obtain the decryption
  • the calculation result is obtained by calculating the plaintext of the message data according to the agreed hash function, and determining whether the decryption result and the calculation result are the same, and the extradition command is complete, otherwise the extradition command is incomplete; , yes, go to step 1411, otherwise go to step 1427;
  • the preset range is 0x05-0x10; for the application, step 1412 is performed, otherwise step 1427 is performed;
  • Step 1412 Determine whether the application corresponding to the security domain identifier in the extradition command is the current card provider module, if yes, go to step 1427; otherwise, go to step 1413;
  • Step 1413 Determine whether a byte data after the security domain identifier in the extrapolation command is 0x00, if yes, execute step 1414; otherwise, execute step 1427;
  • Step 1414 Determine whether the status of the application corresponding to the security domain identifier in the extradition command is INSTALLED. If yes, go to step 1415. Otherwise, go to step 1427. Step 1415: Determine whether the application identifier length in the extradition command is Within the preset range, yes, step 1416 is performed, otherwise step 1427 is performed;
  • the preset range is 0x05-0x10;
  • Step 1416 Determine whether there is an application corresponding to the application identifier in the extradition command in the card, if yes, go to step 1417; otherwise, go to step 1427;
  • Step 1417 It is determined whether the security domain associated with the application corresponding to the application identifier in the extradition command is the current first card data management module, if yes, step 1418 is performed; otherwise, step 1427 is performed; Step 1418: Determine whether the application corresponding to the security domain identifier in the extradition command has security domain authority, if yes, go to step 1419, otherwise go to step 1427;
  • Step 1419 Determine whether the status of the application corresponding to the security domain identifier in the extradition command is LOCKED. If yes, go to step 1427. Otherwise, go to step 1420.
  • Step 1420 Determine the security domain identifier in the extradition command. Whether the status of the application is PERSONALIZED (personalized), if yes, execute step 1421; otherwise, execute step 1427;
  • Step 1421 Determine whether the two bytes of data after the application identifier in the extradition command are all 0x00, if yes, go to step 1422, otherwise go to step 1427;
  • Step 1422 Determine whether the length of the extradition token in the extradition command is 0x80, if yes, go to step 1423, otherwise go to step 1427;
  • Step 1423 Send the data required for calculating the extradition token to the second card data management module, and receive the calculation result returned by the second card data management module, and determine whether the calculation result is the same as the extradition token in the extradition command. If yes, go to step 1424, otherwise go to step 1427;
  • the P1, P2, the valid data length, the security domain identifier length, the security domain identifier, the 0x00, the application identifier length, the application identifier, 0x00, and 0x00 of the extrapolation command are sent to the second card data management module;
  • Step 1424 It is determined whether the application corresponding to the application identifier in the extradition command has the security domain authority, if yes, step 1427 is performed; otherwise, step 1425 is performed;
  • Step 1425 Will be stated! The security domain associated with the application identifier corresponding to the application identifier in the transition command is modified to be the application corresponding to the security domain identifier in the extradition command;
  • Step 1426 Send the data required for calculating the receipt to the second card data management module, receive the receipt returned by the second card data management module, set the return data to the receipt, and perform step 1427;
  • the length of the application identifier, the application identifier, the length of the original security domain identifier, the original security domain identifier, the length of the new security domain identifier, and the new security domain identifier are sent to the second card data management module, where , the original security domain identifier is this reference
  • the security domain identifier of the security domain associated with the application before the extradition; the new security domain identifier identifies the security domain identity of the security domain to be associated after the extradition application for the extradition application;
  • Step 1427 Generate a corresponding status code
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1428 Return the set return data and/or the generated status code; preferably, see Figure 15, step 1501 to step 1517 are as follows:
  • Step 1501 Determine whether the APDU data is a command header of a legal personalized command, if yes, go to step 1502, otherwise go to step 1516;
  • the APDU data is a command header of a legal personalized command
  • Step 1502 Determine whether the current state of the card is TERMANATED or CARD_LOCKED, if yes, go to step 1516; otherwise, go to step 1503;
  • Step 1503 Receive the data field part of the personalized command to obtain a complete personalization command;
  • Step 1504 Determine whether the current state of the first card data management module is PERSONALIZED (personalized), if yes, go to step 1505, otherwise go to step 1516;
  • Step 1505 Determine whether the card meets the security condition, if yes, go to step 1506, otherwise go to step 1516;
  • Step 1506 Check the security level of the card. If it is the first level, go to step 1509. If it is the second level, go to step 1507. If it is the third level, go to step 1508.
  • the personalized command is a plaintext of the message data
  • the personalized command is a combination of the message data plaintext and the message authentication code.
  • the security level of the card is the third level, the personalized command is a combination of the message data ciphertext and the message authentication code;
  • Step 1507 Determine whether the personalized command is complete according to the plaintext and MAC of the message data in the personalized command. If yes, go to step 1509. Otherwise, go to step 1516.
  • the message data according to the personalized command is executed.
  • Clear text and MAC judgment Whether the personalization command is complete or not includes: decrypting the MAC by using the agreed session key to obtain a decryption result, and calculating the plaintext of the message data according to the agreed hash function to obtain a calculation result, and determining the decryption result and the calculation Whether the result is the same, if the personalized command is complete, otherwise the personalized command is incomplete;
  • Step 1508 Determine whether the personalized command is complete according to the message data ciphertext and the MAC in the personalized command, if yes, go to step 1509, otherwise go to step 1516; wherein, according to the message in the personalized command
  • the data ciphertext and the MAC determine whether the personalized command is complete or not, including: decrypting the message data ciphertext to obtain the message data plaintext, decrypting the MAC by using the agreed session key to obtain a decryption result, and simultaneously using the hash function according to the agreed hash function.
  • the data is calculated in plain text to obtain a calculation result, and it is judged whether the decryption result and the calculation result are the same, and the personalized command is complete, otherwise the personalized command is incomplete;
  • Step 1509 Determine whether the first two bytes of the data field of the personalized command are 0x00, if yes, go to step 1510, otherwise go to step 1516;
  • Step 1510 Determine whether the application identifier length in the personalized command is within a preset range, if yes, go to step 1511, otherwise go to step 1516;
  • the preset range is 0x05-0x10;
  • Step 1511 Determine whether there is an application corresponding to the application identifier in the personalized command in the card, if yes, go to step 1512, otherwise go to step 1516;
  • Step 1512 Determine whether the security domain associated with the application corresponding to the application identifier in the personalized command is the current first card data management module, if yes, go to step 1513, otherwise go to step 1516;
  • Step 1513 Determine whether the last three bytes of data of the personalized command are 0x00, if yes, go to step 1514, otherwise go to step 1516;
  • Step 1514 Set the state of the application corresponding to the application identifier in the personalized command to personalization (PERSONLIZED);
  • Step 1515 Set the return data to 0x00;
  • Step 1516 Generate a corresponding status code.
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1517 Return the set return data and/or the generated status code; preferably, see Figure 16, step 1601 to step 1625 are as follows:
  • Step 1601 Determine whether the APDU data is a command header of a legal delete command, if yes, go to step 1602, otherwise go to step 1624;
  • the APD U data is a command header of a legal delete command
  • Step 1602 Determine whether the current state of the card is TERMANATED or CARD_LOCKED, if yes, go to step 1624, otherwise go to step 1603;
  • Step 1603 The data field part of the delete command is received, and a complete delete command is obtained.
  • Step 1605 Determine whether the current first card data management module has proxy authority, if yes, go to step 1606, otherwise go to step 1624;
  • Step 1606 Determine whether the card meets the security condition, if yes, go to step 1607, otherwise go to step 1624;
  • Step 1607 Check the security level of the card, if it is the first level, step 1610 is performed, if it is the second level, step 1608 is performed, and if it is the third level, step 1609 is performed;
  • the deletion command is a plaintext of the message data
  • the deletion command is a combination of the message data plaintext and the message authentication code.
  • the security level of the card is the third level, and the deletion command is a combination of the message data ciphertext and the message authentication code;
  • Step 1608 Determine, according to the plaintext and MAC of the message data in the delete command, whether the delete command is complete, if yes, go to step 1610, otherwise go to step 1624;
  • the determining, according to the plaintext and the MAC of the message data in the deletion command, whether the deletion command is complete or not includes: solving the MAC by using the agreed session key The decryption result is obtained, and the calculation result is obtained by calculating the plaintext of the message data according to the agreed hash function, and determining whether the decryption result and the calculation result are the same, if the deletion command is complete, otherwise the deletion command is incomplete. ;
  • Step 1609 Determine whether the deletion command is complete according to the message data ciphertext and the MAC in the deletion command. If yes, go to step 1610. Otherwise, execute step 1624.
  • the MAC determining whether the deletion command is complete includes: decrypting the message data ciphertext to obtain the message data plaintext, decrypting the MAC by using the agreed session key to obtain a decryption result, and calculating the plaintext of the message data according to the agreed hash function. Obtaining a calculation result, determining whether the decryption result and the calculation result are the same, if the deletion command is complete, otherwise the deletion command is incomplete;
  • Step 1610 It is determined whether the first byte data in the data field of the delete command is 0x4f, if yes, step 1611 is performed, otherwise step 1624 is performed;
  • Step 1611 Determine whether the length of the data field identifier in the delete command is within a preset range, if yes, go to step 1612, otherwise go to step 1624;
  • the preset range is 0x05-0x10;
  • Step 1612 Determine whether there is an application corresponding to the data field identifier in the delete command in the card, if yes, go to step 1613, otherwise go to step 1614;
  • Step 1613 Determine whether P2 in the delete command is 0x80, if yes, go to step 1614, otherwise go to step 1619;
  • Step 1614 Determine whether there is an executable file corresponding to the data field identifier in the delete command in the card, if yes, go to step 1615, otherwise go to step 1624;
  • Step 1615 Determine whether the security domain associated with the executable file corresponding to the data domain identifier in the delete command is the current first card data management module, if yes, go to step 1616; otherwise, go to step 1624;
  • Step 1616 It is determined whether P2 in the delete command is 0x80, if yes, step 1617 is performed; otherwise, step 1618 is performed;
  • Step 1617 Delete the executable file corresponding to the data domain identifier in the delete command. And all the applications corresponding to the executable file, go to step 1623; Step 1618: Delete the executable file corresponding to the data domain identifier in the delete command, and perform step 1623;
  • Step 1619 Determine whether the application corresponding to the data domain identifier in the delete command is a security domain associated with another application or other executable file, if yes, go to step 1624, otherwise go to step 1620;
  • Step 1620 Determine whether the application corresponding to the data domain identifier in the delete command is the current first card data management module, if yes, go to step 1624, otherwise go to step 1621;
  • Step 1621 Determine the data domain identifier in the delete command. Whether the security domain associated with the corresponding application is the current first card data management module, if yes, go to step 1622, otherwise go to step 1624;
  • Step 1622 Delete an application corresponding to the data domain identifier in the delete command.
  • Step 1623 Send data required for calculating the receipt to the second card data management module, and receive the receipt returned by the second card data management module, and set Returning the data to the receipt, performing step 1624;
  • Step 1624 Generate a corresponding status code.
  • the corresponding status code includes a status code that identifies a success and a status code that identifies an error, where different error types correspond to different status codes;
  • Step 1625 Return the set return data and/or the generated status code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Storage Device Security (AREA)

Abstract

本发明公开了一种管理卡片上应用的方法,属于智能卡领域。所述方法包括卡片内容管理模块接收到运行环境发送的数据后检查卡片状态,当卡片状态不为第一预设状态或第二预设状态时检查接收到的数据,当接收到的数据符合预设格式时继续接收运行环境发送的数据,得到完整命令,执行相应命令实现对卡片上应用的关联。本发明的有益效果在于提供了一种管理卡片上应用的方法,可以实现卡片上应用的加载、安装、更新、个人化以及删除。

Description

一种管理卡片上应用的方法 本申请要求于 2013 年 4 月 25 日提交中国专利局、 申请号为 201310146939.4, 发明名称为"一种管理卡片数据的实现方法"的中国 专利申请, 以及 2013 年 9 月 5 日提交中国专利局、 申请号为 201310399702.7, 发明名称为"一种管理卡片上应用的方法 "的中国专 利申请的优先权, 其全部内容通过引用结合在本申请中。 技术领域
本发明属于智能卡领域, 特别涉及一种管理卡片上应用的方法。 背景技术
随着社会的发展, 智能卡由于其便于随身携带、 存储容量大、 信 息记录可靠安全等优点受到了越来越广泛的关注, 而为了适应智能卡 应用领域的不断扩展, 需要对智能卡扩展更多的应用。
而且, 为了给用户提供更多的便利, 现今的智能卡上除了发卡方 提供的内容外, 还可以安装多个应用, 通常情况下, 发卡方并不会管 理所有的卡片内容, 尤其是不属于发卡方的卡片内容, 因此, 需要一 种授予第三方通过预认证后来代理管理卡片内容的机制,所述管理如 加载、 安装、 引渡和删除等。
申请人在实现本发明的过程中发现,在现有技术中尚无代理管理 卡片内容机制的具体实现方法。
发明内容
本发明的目的是为了克服现有技术的缺陷,提出一种管理卡片上 应用的方法。
本发明方法是通过下述技术方案实现的:
一种管理卡片上应用的方法, 其基本实施过程如下:
当卡片内容管理模块接收到运行环境发送的数据后执行以下步 骤:
步骤 A: 检查卡片状态, 若为第一预设状态或第二预设状态则生 步骤 B : 检查接收到的数据是否符合预设格式, 若符合第一预设 格式则执行步骤 C, 若符合第二预设格式则执行步骤 D, 若符合第三 预设格式则执行步骤 E, 若符合第四预设格式则执行步骤 F, 若符合第 五预设格式则执行步骤 G, 若符合第六预设格式则执行步骤 H, 若符 合第七预设格式则执行步骤 I, 若不符合预设格式则生成并返回数据 错误状态码给运行环境, 结束;
步骤 C: 继续接收运行环境发送的数据得到完整的第一命令, 解 析所述第一命令, 得到加载文件标识和加载文件关联安全域标识, 创 建加载文件结构,并将解析得到的加载文件标识和加载文件关联域标 识填充到创建的加载文件结构中,如果搡作成功则生成并返回搡作成 功状态码和返回结果给运行环境, 结束, 如果搡作未成功则根据搡作 失败原因生成并返回相应状态码给运行环境, 结束;
步骤 D: 继续接收运行环境发送的数据得到完整的第二命令, 解 析所述第二命令, 得到加载文件数据块, 根据所述加载文件数据块获 取组件数据并进行存储, 将存储地址填充到加载文件结构中, 如果搡 作成功则生成并返回搡作成功状态码和返回结果给运行环境, 结束, 如果搡作未成功则根据搡作失败原因生成并返回相应状态码给运行 环境, 结束;
步骤 E: 继续接收运行环境发送的数据得到完整的第三命令, 解 析所述第三命令, 得到可执行加载文件标识、 可执行模块标识、 应用 标识和应用权限,根据解析得到的可执行加载文件标识查找加载文件 结构,在查找到的加载文件结构中的存储地址对应的存储空间中查找 与解析得到的可执行模块标识相对应的可执行模块,创建查找到的可 执行模块的应用, 用解析得到的应用标识标识创建的应用, 并赋予创 建的应用以解析得到的应用权限所指定的权限,并设置创建的应用的 关联安全域为与解析得到的可执行加载文件标识相对应的可执行加 载文件的关联安全域,如果搡作成功则生成并返回搡作成功状态码和 返回结果给运行环境, 结束, 如果搡作未成功则根据搡作失败原因生 成并返回相应状态码给运行环境, 结束;
步骤 F: 继续接收运行环境发送的数据得到完整的第四命令, 解 析所述第四命令, 得到应用标识和应用权限, 在卡片中查找与解析得 到的应用标识相对应的应用, 更新查找到的应用的状态为可选择状 态,以及更新查找到的应用的权限为解析得到的应用权限所指定的权 限,如果搡作成功则生成并返回搡作成功状态码和返回结果给运行环 境, 结束, 如果搡作未成功则根据搡作失败原因生成并返回相应状态 码给运行环境, 结束;
步骤 G: 继续接收运行环境发送的数据得到完整的第五命令, 解 析所述第五命令, 得到安全域标识和应用标识, 在卡片内查找与解析 得到的应用标识相对应的应用和与解析得到的安全域标识相对应的 应用,将查找到的应用的关联安全域更新为与解析得到的安全域标识 相对应的应用,如果搡作成功则生成并返回搡作成功状态码和返回结 果给运行环境, 结束, 如果搡作未成功则根据搡作失败原因生成并返 回相应状态码给运行环境, 结束;
步骤 H: 继续接收运行环境发送的数据得到完整的第六命令, 解 析所述第六命令, 得到应用标识, 在卡片内查找与解析得到的应用标 识相对应的应用, 设置查找到的应用为个人化应用, 如果搡作成功则 生成并返回搡作成功状态码和返回结果给运行环境, 结束, 如果搡作 未成功则根据搡作失败原因生成并返回相应状态码给运行环境, 结 束;
步骤 I: 继续接收运行环境发送的数据得到完整的第七命令, 解 析所述第七命令, 得到数据域标识, 在卡片内查找与解析得到的数据 域标识相对应的应用和可执行加载文件,删除查找到的应用和可执行 加载文件,如果搡作成功则生成并返回搡作成功状态码和返回结果给 运行环境, 结束, 如果搡作未成功则根据搡作失败原因生成并返回相 应状态码给运行环境, 结束。
其中, 所述根据所述第一命令准备加载应用具体包括:
步骤 C1 :判断所述第一命令的第一个数据块是否合法, 若合法则 检查卡片内是否有与所述第一个数据块相对应的可执行文件,是则搡 作条件不满足, 搡作失败, 否则执行步骤 C2; 若不合法则数据错误, 搡作失败;
步骤 C2: 判断所述第一命令的第二个数据块是否满足预设要求, 若满足第一预设要求则设置与所述第一个数据块对应的加载文件的 关联安全域为所述卡片内容管理模块, 执行步骤 C4; 若满足第二预设 要求则执行步骤 C3 ; 若不满足预设要求则数据错误, 搡作失败; 步骤 C3 : 检查卡片内是否有与所述第二个数据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则检查与所述第二个数据 块相对应的应用是否具有安全域权限,若具有安全域权限则设置与所 述第一个数据块对应的加载文件的关联安全域为与所述第二个数据 块相对应的应用, 执行步骤 C4; 若不具有安全域权限则搡作条件不满 足, 搡作失败;
步骤 C4:判断所述第一命令的第三个数据块是否合法, 是则存储 所述第三个数据块中的相应数据, 执行步骤 C5 ; 否则数据错误, 搡作 失败;
步骤 C5 : 处理所述第一命令的第四个数据块, 执行步骤 C6 ; 步骤 C6 :判断所述第一命令的第五个数据块是否合法, 是则创建 加载文件结构,并根据所述第一个数据块和所述第二个数据块对加载 文件结构进行填充, 初始化卡片内的全局块编号, 搡作成功; 否则数 据错误, 搡作失败。
所述根据所述第二命令加载应用具体包括:
步骤 D1 : 判断所述第二命令的第四个字节是否等于卡片内的全 局块编号, 是则执行步骤 D2, 否则数据错误, 搡作失败; 步骤 D2: 检查所所述第二命令中是否包含数据验证模式块信息, 若包含则验证所述数据验证模式快信息, 若验证通过则执行步骤 D3, 若验证未通过则数据错误, 搡作失败; 若不包含则执行步骤 D3 ; 步骤 D3 : 根据所述第二命令中的加载文件数据块获取组件数据 并进行存储, 将存储地址填充到加载文件结构中, 更新卡片内的全局 块编号为其当前值加 1, 判断所述加载文件数据块是否为加载文件的 最后一个加载文件数据块, 是则执行步骤 D4, 否则搡作成功;
步骤 D4: 判断卡片内的加载文件数据块哈希值是否有值, 若有 值则对由卡片内存储的全部加载文件数据块构成的整体进行哈希计 算, 并判断计算结果是否等于所述加载文件数据块哈希值, 若等于则 执行步骤 D5, 若不等于则数据错误, 搡作失败; 若没有值则执行步 骤 D5;
步骤 D5 : 存储并提交可执行加载文件结构, 搡作成功。
所述根据所述第三命令安装应用具体包括:
步骤 E1 : 判断所述第三命令的第一个数据块是否合法, 若合法则 检查卡片内是否有与所述第一个数据块相对应的加载文件结构,是则 执行步骤 E2,否则搡作条件不满足,搡作失败;若不合法则数据错误, 搡作失败;
步骤 E2: 判断所述第三命令的第二个数据块是否合法, 若合法则 检查所述加载文件结构中的存储地址对应的存储空间中是否有与所 述第二个数据块相对应的可执行模块, 是则执行步骤 E3, 否则搡作条 件不满足, 搡作失败; 若不合法则数据错误, 搡作失败;
步骤 E3 : 判断所述第三命令的第三个数据块是否合法, 若合法则 检查卡片内是否有与所述第三个数据块相对应的应用,是则执行步骤 E4, 否则搡作条件不满足, 搡作失败; 若不合法则数据错误, 搡作失 败;
步骤 E4: 判断所述第三命令的第四个数据块是否合法, 若合法则 判断与所述第三个数据块相对应的应用是否具有默认选择权限,是则 执行步骤 E5, 否则执行步骤 E6; 若不合法则数据错误, 搡作失败; 步骤 E5 : 判断所述第三命令的第三个字节是否等于预设值, 若为 预设值则数据错误, 搡作失败; 若不为预设值则判断所述卡片内容管 理模块是否具有默认选择权限, 是则执行步骤 E7, 否则搡作条件不满 足, 搡作失败;
步骤 E6: 判断所述第三命令的第三个数据块是否满足预设条件, 若满足第一预设条件或第二预设条件则处理所述第三命令的第五个 数据块, 执行步骤 E7, 若不满足预设条件则搡作条件不满足, 搡作失 败;
步骤 E7 : 判断所述第三命令的第六个数据块是否合法, 是则根据 所述第三命令注册应用, 执行步骤 E8, 否则数据错误, 搡作失败; 步骤 E8 : 判断所述第三命令的第三个字节是否等于所述预设值, 是则设置与所述第三命令的第三个数据块相对应的应用的状态为安 装, 搡作成功; 否则设置与所述第三命令的第三个数据块相对应的应 用的状态为可选择, 执行步骤 E9;
步骤 E9:判断与所述第三命令的第三个数据块相对应的应用是否 具有默认选择权限,是则设置与所述第三命令的第三个数据块相对应 的应用为默认应用, 搡作成功, 否则搡作成功。
所述根据第四命令设置应用状态具体包括:
步骤 F1 :判断所述第四命令的第一个数据块和第二个数据块是否 均合法, 是则执行步骤 F2, 否则数据错误, 搡作失败;
步骤 F2: 判断所述第四命令的第三个数据块是否合法, 若不合法 则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第三个数 据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则判 断与所述第三个数据块相对应的应用的状态是否为安装,若不为安装 则搡作条件不满足, 搡作失败; 若为安装则执行步骤 F3 ;
步骤 F3 : 判断所述第四命令的第四个数据块是否合法, 是则执行 步骤 F4, 否则数据错误, 搡作失败; 步骤 F4: 判断所述第四命令的第五个数据块是否合法, 是则执行 步骤 F5, 否则数据错误, 搡作失败;
步骤 F5 : 判断所述第四命令的第六个数据块是否合法, 是则设置 与所述第三个数据块相对应的应用的状态为可选择, 执行步骤 F6, 否 则数据错误搡作失败;
步骤 F6:判断与所述第三个数据块相对应的应用是否具有默认选 择权限, 若没有则搡作成功; 若有则判断所述卡片内容管理模块是否 具有默认选择权限,是则设置与所述第三个数据块相对应的应用为默 认应用, 搡作成功, 否则搡作条件不满足, 搡作失败。
所述根据所述第五命令更新应用的关联安全域具体包括: 步骤 G1 : 判断所述第五命令的第一个数据块是否合法, 若不合 法则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第一个 数据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则 判断与所述第一个数据块相对应的应用是否为所述卡片内容管理模 块, 若是则搡作条件不满足, 搡作失败; 若不是则执行步骤 G2; 步骤 G2: 判断所述第五命令的第二个数据块是否合法, 若不合 法则数据错误, 搡作失败; 若合法则判断与所述第一个数据块相对应 的应用的状态是否为安装,若不为安装则搡作条件不满足,搡作失败; 若为安装则执行步骤 G3 ;
步骤 G3 : 判断所述第五命令的第三个数据块是否合法, 若不合 法则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第三个 数据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则 执行步骤 G4;
步骤 G4: 判断与所述第一个数据块相对应的应用是否具有安全 域权限, 若没有则搡作条件不满足, 搡作失败; 若有则判断与所述第 一个数据块相对应的应用的状态是否为锁定,若为锁定则搡作条件不 满足, 搡作失败; 若不为锁定则判断与所述第一个数据块相对应的应 用的状态是否为个人化, 若为个人化则执行步骤 G5, 若不为个人化 则搡作条件不满足, 搡作失败;
步骤 G5: 判断所述第五命令的第四个数据块和第五个数据块是 否均合法, 是则执行步骤 G6, 否则数据错误, 搡作失败;
步骤 G6 : 判断所述第五命令的第六个数据块是否合法, 若不合 法则数据错误, 搡作失败; 若合法则判断与所述第三个数据块相对应 的应用是否具有安全域权限, 若具有则搡作条件不满足, 搡作失败; 若不具有则设置与所述第三个数据块相对应的应用的关联安全域为 与所述第一个数据块相对应的应用, 搡作成功。
所述根据所述第六命令个人化应用具体包括:
步骤 HI : 判断所述第六命令的第一个数据块和第二个数据块是 否均合法, 是则执行步骤 H2, 否则数据错误, 搡作失败;
步骤 H2: 判断所述第六命令的第三个数据块是否合法, 若不合 法则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第三个 数据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则 判断与所述第三个数据块相对应的应用的关联安全域是否为所述卡 片内容管理模块, 是则执行步骤 H3, 否则搡作条件不满足, 搡作失 败;
步骤 H3 : 判断所述第六命令的第四个数据块、 第五个数据块和 第六个数据块是否均合法,是则设置与所述第三个数据块相对应的应 用为个人化应用, 否则搡作条件不满足, 搡作失败。
所述根据所述第七命令删除应用及可执行加载文件具体包括: 步骤 II: 判断所述第七命令的第一个数据块是否合法, 是则执行 步骤 12, 否则数据错误, 搡作失败;
步骤 12: 判断所述第七命令的第二个数据块是否合法, 若不合法 则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第二个数 据块相对应的应用, 是则执行步骤 13, 否则执行步骤 14;
步骤 13 : 判断所述第七命令的第四个字节是否等于预设值, 是则 执行步骤 14, 否则执行步骤 15 ; 步骤 14: 检查卡片内是否有与所述第二个数据块相对应的可执行 加载文件, 若没有则搡作条件不满足, 搡作失败; 若有则判断所述第 七命令的第四个字节是否等于预设值,若等于则删除与所述第二个数 据块相对应的应用和可执行加载文件, 搡作成功, 若不等于则删除与 所述第二个数据块相对应的可执行加载文件, 搡作成功;
步骤 15 : 检查与所述第二个数据块相对应的应用是否为其他应用 或其他可执行加载文件的关联安全域, 是则搡作条件不满足, 搡作失 败; 否则执行步骤 16;
步骤 16: 判断与所述第二个数据块相对应的应用是否为所述卡片 内容管理模块, 是则搡作条件不满足, 搡作失败, 否则删除与所述第 二个数据块相对应的应用, 搡作成功。
一种管理卡片数据的实现方法, 其基本实施过程如下:
当第一卡片数据管理模块接收到运行环境发送的应用协议数据 单元 APDU数据后, 将自身作为当前第一卡片数据管理模块, 执行以 下步骤:
步骤 A、 检查所述 APDU数据的指令码, 若所述指令码为有效数 值 0xE8则执行步骤 D, 若所述指令码为有效数值 0xE6则执行步骤 B, 若所述指令码为有效数值 0xE4则执行步骤 I;
步骤 B、检查所述 APDU数据的第一参数,若所述第一参数为 0x02 则执行步骤 C, 若所述第一参数为 0x04或 OxOC则执行步骤 E, 若所述 第一参数为 0x08则执行步骤 F, 若所述第一参数为 0x10则执行步骤 G, 若所述第一参数为 0x20则执行步骤 H;
步骤 C、 收取预加载命令的数据域部分, 得到预加载命令的全部 内容, 根据所述预加载命令的内容检查卡片是否满足预加载条件, 是 则新建可执行加载文件结构并设置相应数据, 执行步骤 J, 否则直接 执行步骤 J;
步骤 D、收取加载命令的数据域部分,得到加载命令的全部内容, 根据所述加载命令的内容检查卡片是否满足加载条件,是则存储所述 加载命令的相应内容, 执行步骤 J, 否则直接执行步骤 J;
步骤 E、 收取安装命令的数据域部分, 得到安装命令的全部内容, 根据所述安装命令的内容检查卡片是否满足安装条件,是则创建应用 并设置相应状态, 执行步骤 J, 否则直接执行步骤 J;
步骤 F、 收取可选择命令的数据域部分, 得到可选择命令的全部 内容, 根据所述可选择命令的内容检查卡片是否满足可选择条件, 是 则设置相应应用的状态为可选择, 执行步骤 J, 否则直接执行步骤 J; 步骤 G、收取引渡命令的数据域部分,得到引渡命令的全部内容, 根据所述引渡命令的内容检查卡片是否满足引渡条件,是则重置相应 应用关联的安全域, 执行步骤 J, 否则直接执行步骤 J;
步骤 H、 收取个人化命令的数据域部分, 得到个人化命令的全部 内容, 根据所述个人化命令的内容检查卡片是否满足个人化条件, 是 则将相应数据发送给相应应用, 执行步骤 J, 否则直接执行步骤 J; 步骤 I、 收取删除命令的数据域部分, 得到删除命令的全部内容, 根据所述删除命令的内容检查卡片是否满足删除条件,是则删除所述 删除命令中指定的卡片内的相应数据, 执行步骤 J, 否则直接执行步 骤 J;
步骤 J、 生成并返回相应返回数据和 /或相应状态码给所述运行环 境。
本发明方法的有益效果在于: 提供了一种管理卡片上应用的方 法, 可以实现卡片上应用的加载、 安装、 更新、 个人化以及删除; 同 时, 为智能卡上数据的管理提供方便, 具体体现在两个方面:
1、 发卡方可以不用关心与自己无关的应用;
2、 第三方也可以自己管理自身应用, 而不用通过发卡方来管理。 附图说明
为了更清楚的说明本发明实施例或现有技术中的技术方案,下面 将对实施例或现有技术描述中所需要使用的附图作简单的介绍,显而 易见地, 下面描述中的附图仅仅是本发明的一些实施例, 对于本领域 普通技术人员来讲, 在不付出创造性劳动的前提下, 还可以根据这些 附图获得其他的附图。
图 1为本发明实施例一提供的一种管理卡片上应用的方法流程 图;
图 2为本发明实施例二提供的一种准备加载应用的具体方法流程 图;
图 3为本发明实施例三提供的一种加载应用的具体方法流程图; 图 4为本发明实施例四提供的一种安装应用的具体方法流程图; 图 5为本发明实施例五提供的一种设置应用状态的具体方法流程 图;
图 6为本发明实施例六提供的一种更新应用的关联安全域的具体 方法流程图;
图 7为本发明实施例七提供的一种个人化应用的具体方法流程 图;
图 8为本发明实施例八中提供的一种删除应用及可执行加载文件 的具体方法流程图。
图 9为本发明提供的一种管理卡片数据的实现方法流程图; 图 10为步骤 1001至步骤 1028的具体流程图;
图 11为步骤 1101至步骤 1129的具体流程图;
图 12为步骤 1201至步骤 1235的具体流程图;
图 13为步骤 1301至步骤 1324的具体流程图;
图 14为步骤 1401至步骤 1428的具体流程图;
图 15为步骤 1501至步骤 1517的具体流程图;
图 16为步骤 1601至步骤 1625的具体流程图。 具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方 案进行清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部 分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域技 术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属 于本发明保护的范围。 实施例一
本发明实施例一提供一种管理卡片上应用的方法, 参见图 1, 所 述方法具体包括当 卡片 内容管理模块接收到 RE ( Runtime Environment, 运行环境) 设备发送的数据后执行下述步骤, 在本发 明中, 所述卡片内容管理模块为卡片中一种特殊的应用:
步骤 101 : 检查卡片状态, 若为第一预设状态或第二预设状态则 生成并返回卡片状态不支持状态码给 RE, 结束; 否则执行步骤 102; 具体地, 在本实施例中, 第一预设状态为 TERMINATED (终止), 第二预设状态为 CARD_LOCKED (锁定)。
步骤 102: 检查接收到的数据是否符合预设格式, 若符合第一预 设格式则执行步骤 103 ; 若符合第二预设格式则执行步骤 104; 若符合 第三预设格式则执行步骤 105 ; 若符合第四预设格式则执行步骤 106; 若符合第五预设格式则执行步骤 107 ; 若符合第六预设格式则执行步 骤 108 ; 若符合第七预设格式则执行步骤 109; 若不符合预设格式则生 成并返回数据错误状态码给 RE, 结束;
具体地, 在本实施例中, 步骤 102具体包括:
步骤 B1 :检查接收到的数据的长度是否为五个字节, 是则执行步 骤 B2, 否则接收到的数据不符合预设格式, 生成并返回数据错误状态 码给运行环境, 结束;
步骤 B2:检查接收到的数据的第一个字节是否为 0x80或 0x84, 是 则执行步骤 B3, 否则接收到的数据不符合预设格式, 生成并返回数据 错误状态码给运行环境, 结束;
步骤 B3 : 检查接收到的数据的第二个字节, 若为 0xE6则执行步 骤 B4, 若为 0xE8则执行步骤 B5, 若为 0xE4则执行步骤 B6, 否则接收 到的数据不符合预设格式, 生成并返回数据错误状态码给运行环境, 结束;
步骤 B4:检查接收到的数据的第三至第五个字节, 若第三字节和 第四字节分别为 0x02和 0x00且第五字节不小于 OxOA则接收到的数据 符合第一预设格式, 执行步骤 103 ; 若第三字节为 0x04或 0x0C、 第四 字节为 0x00且第五字节不小于 0x18则接收到的数据符合第三预设格 式, 执行步骤 105 ; 若第三字节和第四字节分别为 0x08和 0x00且第五 字节不小于 OxOC则接收到的数据符合第四预设格式, 执行步骤 106; 若第三字节和第四字节分别为 0x10和 0x00且第五字节不小于 0x10则 接收到的数据符合第五预设格式, 执行步骤 107 ; 若第三字节和第四 字节分别为 0x20和 0x00且第五字节不小于 OxOB则接收到的数据符合 第六预设格式, 执行步骤 108 ; 否则接收到的数据不符合预设格式, 生成并返回数据错误状态码给运行环境, 结束;
步骤 B5 :检查接收到的数据的第三个字节是否为 0x00或 0x80, 是 则接收到的数据符合第二预设格式, 执行步骤 104, 否则接收到的数 据不符合预设格式, 生成并返回数据错误状态码给运行环境, 结束; 步骤 B6:检查接收到的数据的第三个字节是否为 0x00, 是则接收 到的数据符合第七预设格式, 执行步骤 109, 否则接收到的数据不符 合预设格式, 生成并返回数据错误状态码给运行环境, 结束。
步骤 103 : 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APDU数据准备加载应用;
具体地, 在本实施例中, 步骤 103中所述 APDU数据为 for_Load 命令;
根据所述 APDU数据准备加载应用具体包括:解析 for_Load命令, 得到加载文件标识和加载文件关联安全域标识, 创建加载文件结构, 并将解析得到的加载文件标识和加载文件关联域标识填充到创建的 加载文件结构中,如果上述搡作成功则生成并返回搡作成功状态码和 返回结果给运行环境, 结束, 如果上述搡作未成功则根据搡作失败原 因生成并返回相应状态码给运行环境, 结束。 步骤 104: 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APDU数据加载应用;
具体地, 在本实施例中, 步骤 104中所述 APDU数据为 Load命令; 根据所述 APDU数据加载应用具体包括: 解析 Load命令, 得到加 载文件数据块, 根据所述加载文件数据块获取组件数据并进行存储, 将存储地址填充到加载文件结构中,如果上述搡作成功则生成并返回 搡作成功状态码和返回结果给运行环境, 结束, 如果上述搡作未成功 则根据搡作失败原因生成并返回相应状态码给运行环境, 结束。
步骤 105 : 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APDU数据安装应用;
具体地, 在本实施例中, 步骤 105中所述 APDU数据为 for_Install 命令;
根据所述 APDU数据安装应用具体包括: 解析 for_Install命令, 得 到可执行加载文件标识、 可执行模块标识、 应用标识和应用权限, 根 据解析得到的可执行加载文件标识查找加载文件结构,在查找到的加 载文件结构中的存储地址对应的存储空间中查找与解析得到的可执 行模块标识相对应的可执行模块, 创建查找到的可执行模块的应用, 用解析得到的应用标识标识创建的应用,并赋予创建的应用以解析得 到的应用权限所指定的权限,并设置创建的应用的关联安全域为与解 析得到的可执行加载文件标识相对应的可执行加载文件的关联安全 域,如果上述搡作成功则生成并返回搡作成功状态码和返回结果给运 行环境, 结束, 如果上述搡作未成功则根据搡作失败原因生成并返回 相应状态码给运行环境, 结束。
步骤 106: 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APDU数据设置应用状态;
具体地, 本实施例 中 , 步骤 106中 所述 APDU数据为 for_Makeselectable命令;
根据所述 APDU数据设置应 用 状态具体包括: 解析 for_Makeselectable命令, 得到应用标识和应用权限, 在卡片中查找与 解析得到的应用标识相对应的应用,更新查找到的应用的状态为可选 择状态,以及更新查找到的应用的权限为解析得到的应用权限所指定 的权限,如果上述搡作成功则生成并返回搡作成功状态码和返回结果 给运行环境, 结束, 如果上述搡作未成功则根据搡作失败原因生成并 返回相应状态码给运行环境, 结束。
步骤 107 : 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APDU数据更新应用的关联安全域;
其中, 应用的关联安全域为应用提供密钥等服务;
具体地,本实施例中,步骤 107中所述 APDU数据为 for_Extradition 命令;
根据所述 APDU数据更新应用的关联安全域具体包括: 解析 for_Extradition命令, 得到安全域标识和应用标识, 在卡片内查找与解 析得到的应用标识相对应的应用和与解析得到的安全域标识相对应 的应用,将查找到的与解析得到的应用标识相对应的应用的关联安全 域更新为与解析得到的安全域标识相对应的应用,如果上述搡作成功 则生成并返回搡作成功状态码和返回结果给运行环境, 结束, 如果上 述搡作未成功则根据搡作失败原因生成并返回相应状态码给运行环 境, 结束。
步骤 108 : 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APDU数据个人化应用;
具体地, 本实施例 中 , 步骤 108中 所述 APDU数据为 for—Personalized命令;
根据所述 APDU数据个人化应用具体包括: 解析 for_Personalized 命令, 得到应用标识, 在卡片内查找与解析得到的应用标识相对应的 应用, 设置查找到的应用为个人化应用, 如果上述搡作成功则生成并 返回搡作成功状态码和返回结果给运行环境, 结束, 如果上述搡作未 成功则根据搡作失败原因生成并返回相应状态码给运行环境, 结束。 步骤 109: 继续接收 RE发送的数据得到完整的 APDU数据, 根据 所述 APD U数据删除应用及可执行加载文件。
具体地, 本实施例中, 步骤 109中所述 APDU数据为 Delete命令; 根据所述 APDU数据删除应用及可执行加载文件具体包括: 解析 Delete命令, 得到数据域标识, 在卡片内查找与解析得到的数据域标 识相对应的应用和可执行加载文件,删除查找到的应用和可执行加载 文件,如果上述搡作成功则生成并返回搡作成功状态码和返回结果给 运行环境, 结束, 如果上述搡作未成功则根据搡作失败原因生成并返 回相应状态码给运行环境, 结束。
具体地, 在本实施例中, 返回结果为 0x00, 搡作失败原因包括, 搡作条件不满足和数据错误, 当搡作失败原因为搡作条件不满足时, 生成并返回条件不满足状态码给 RE, 当搡作失败原因为数据错误时 生成并返回数据错误状态码给 RE。 实施例二
本发明实施例二提供一种实施例一中提供的管理卡片上应用的 方法中准备加载应用的具体方法, 本实施例中的 APDU数据为步骤 103中得到的完整 APDU数据, 其数据域部分可看作是由多个数据块 组成的, 每个数据块都是一个 LV结构, 即数据长度 +数据的结构; 参 见图 2, 所述方法具体包括:
步骤 201 : 判断所述 APDU数据的第一个数据块是否合法, 是则 执行步骤 202, 否则数据错误, 搡作失败;
本实施例中, 第一个数据块具体为: 加载文件标识长度 +加载文 件标识;
判断所述 APDU数据的第一个数据块是否合法具体包括: 判断所 述 APDU数据的第一个数据块中的加载文件标识长度是否在预设范 围内, 是则检查所述 APDU数据的第一个数据块中的加载文件标识的 每个字节, 若均为 0x00则第一个数据块不合法, 若不都是 0x00则第一 个数据块合法, 否则第一个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 202:检查卡片内是否有与加载文件标识对应的可执行文件, 是则搡作条件不满足, 搡作失败, 否则执行步骤 203 ;
步骤 203 : 检查所述 APDU数据的第二个数据块是否满足预设要 求, 若满足第一预设要求则执行步骤 204, 若满足第二预设要求则执 行步骤 205, 若不满足预设要求则数据错误, 搡作失败;
本实施例中, 第二个数据块具体为: 加载文件关联安全域标识长 度 +加载文件关联安全域标识;
检查所述 APDU数据的第二个数据块是否满足预设要求具体包 括: 判断所述 APDU数据的第二个数据块中的加载文件关联安全域标 识长度是否为 0x00, 是则所述 APDU数据的第二个数据块满足第一预 设要求, 否则检查所述 APDU数据的第二个数据块中的加载文件关联 安全域标识的每个字节, 若均为 0x00则所述 APDU数据的第二个数据 块不满足预设要求, 若不都是 0x00则所述 APDU数据的第二个数据块 满足第二预设要求;
步骤 204: 设置加载文件的关联安全域为卡片内容管理模块, 执 行步骤 208 ;
其中, 所述加载文件为与所述 APDU数据的第一个数据块中的加 载文件标识对应的加载文件。
步骤 205 : 检查卡片内是否有与加载文件关联安全域标识对应的 应用, 是则执行步骤 206, 否则搡作条件不满足, 搡作失败;
步骤 206: 检查与加载文件关联安全域标识对应的应用是否具有 安全域权限, 是则执行步骤 207, 否则搡作条件不满足, 搡作失败; 具体地, 通过应用的权限属性判断其是否具有安全域权限, 应用 的权限属性为一个字节数据, 从高位到地位依次为 b8 b7 b6 b5 b4 b3 b2 bl, 检查与加载文件关联安全域标识对应的应用是否具有安全域 权限具体为检查与加载文件关联安全域标识对应的应用的权限属性 的 b8, 若为 1则与加载文件关联安全域标识对应的应用具有安全域权 限, 若不为 1则与加载文件关联安全域标识对应的应用不具有安全域 权限。
步骤 207 : 设置加载文件的关联安全域为与加载文件关联安全域 标识对应的应用;
步骤 208 : 判断所述 APDU数据的第三个数据块是否合法, 是则 执行步骤 209, 否则数据错误, 搡作失败;
本实施例中, 第三个数据块具体为: 加载文件数据块哈希值长度 +加载文件数据块哈希值;
判断所述 APDU数据的第三个数据块是否合法具体包括: 判断所 述 APDU数据的第三个数据块中的加载文件数据块哈希值长度是否 为 0x00,是则所述 APDU数据的第三个数据块不合法,否则所述 APDU 数据的第三个数据块合法。
步骤 209: 存储加载文件数据块哈希值;
步骤 210: 处理所述 APDU数据的第四个数据块;
本实施例中, 第四个数据块具体为: 加载参数域长度 +加载参数 域, 所述加载参数域为 1个 TLV结构数据块 (Tn,Ln, Vn) , 所述 Vn由 3个 TLV结构数据块 (Tn ' ,Ln ', Vn ') 组成, 本实施例中, 步骤 210 具体包括:
步骤 210-1 :判断加载参数域长度是否为 0x00,是则执行步骤 211, 否则执行步骤 210-2;
步骤 210-2: 判断 Tn是否为 0xEF, 是则执行步骤 210-3, 否则数据 错误, 搡作失败;
步骤 210-3 : 获取 Vn的 1个 TLV结构数据块, 判断该 TLV结构数据 块的 Tn '是否合法, 是则执行步骤 210-4, 否则数据错误, 搡作失败; 步骤 210-4: 判断该 TLV结构数据块的 Ln ' 是否为 0x02, 是则执 行步骤 210-5, 否则数据错误, 搡作失败;
步骤 210-5 : 检查该 TLV结构数据块的 Tn ', 若为 0xC6则根据该 TLV结构数据块的 Vn '获取并存储非易失性代码空间限额, 执行步骤 210-6, 若为 0xC7则根据该 TLV结构数据块的 Vn '获取并存储易失性 数据空间限额, 执行步骤 210-6, 若为 0xC8则根据该 TLV结构数据块 的 Vn '获取并存储非易失性数据空间限额, 执行步骤 210-6;
步骤 210-6:判断是否还有未处理的 TLV结构数据块, 是则返回执 行步骤 210-3, 否则执行步骤 210-7 ;
步骤 210-7: 判断卡内非易失性存储空间和易失性存储空间是否 能够满足上述限额, 是则执行步骤 211, 否则搡作条件不满足, 搡作 失败。
步骤 211 :判断所述 APDU数据的第五个数据块是否合法, 是则执 行步骤 212, 否则数据错误, 搡作失败;
本实施例中, 第五个数据块具体为: 加载令牌长度 +加载令牌; 判断所述 APDU数据的第五个数据块是否合法具体包括: 判断所 述 APDU数据的第五个数据块中的加载令牌长度是否为 0x00, 是则所 述 APDU数据的第五个数据块合法, 否则所述 APDU数据的数据块不 合法。
步骤 212: 创建加载文件结构, 将加载文件标识和加载文件关联 安全域标识填充到创建的加载文件结构中,初始化卡片内的全局块编 号, 搡作成功。 实施例三
本发明实施例三提供一种实施例一中提供的管理卡片上应用的 方法中加载应用的具体方法, 参见图 3, 所述方法具体包括:
步骤 301 : 判断所述 APDU数据的第四个字节是否等于卡片内的 全局块编号, 是则执行步骤 302, 否则数据错误, 搡作失败;
步骤 302: 检查所述 APDU数据中是否 包含 DAP ( Data Authentication Pattern, 数据验证模式) 块信息, 是则执行步骤 303, 否则执行步骤 304; 步骤 303 : 验证所述 DAP块信息, 若验证通过则执行步骤 304, 否 则数据错误, 搡作失败;
步骤 304: 根据所述 APDU数据中的加载文件数据块获取组件数 据并进行存储, 将存储地址填充到加载文件结构中;
具体地, 加载文件在卡片外被分割成若干个加载文件数据块, 每 次将一个加载文件数据块封装成一条 APDU数据发送给卡片, RE将卡 片接收到的 APDU数据发送给卡片内容管理模块, 卡片内容管理模块 以组件为单位对每条 APDU数据中的加载文件数据块进行处理, 所述 组件包括: Header组件、 Directory组件、 Applet组件、 Import组件等。
步骤 305 : 更新卡片内的全局块编号;
本实施例中,更新卡片内的全局块编号具体为更新卡片内的全局 块编号为其当前值加 1。
步骤 306: 判断所述加载文件数据块是否为加载文件的最后一个 加载文件数据块, 是则执行步骤 307, 否则搡作成功;
本实施例中,判断所述加载文件数据块是否为加载文件的最后一 个加载文件数据块具体包括: 判断所述 APDU数据的第三个字节的值 是否为 0x80,是则所述加载文件数据块是加载文件的最后一个加载文 件数据块,否则所述加载文件数据块不是加载文件的最后一个加载文 件数据块, 加载文件还有其他数据块。
步骤 307 : 判断卡片内的加载文件数据块哈希值是否有值, 是则 执行步骤 308, 否则执行步骤 310;
步骤 308 : 将卡片内存储的全部加载文件数据块作为一个整体对 其进行哈希计算;
步骤 309: 判断计算结果是否等于卡片内存储的加载文件数据块 哈希值, 是则执行步骤 310, 否则数据错误, 搡作失败;
步骤 310: 存储并提交可执行加载文件结构, 搡作成功。
本实施例中, 所述提交具体为将数据从緩存中写入永久存储区。 实施例四
本发明实施例四提供一种实施例一中提供的管理卡片上应用的 方法中安装应用的具体方法, 本实施例中的 APDU数据的数据域部分 可看作是由多个数据块组成的, 每个数据块都是一个 LV结构, 即数 据长度 +数据的结构; 参见图 4, 所述方法具体包括:
步骤 401 : 判断所述 APDU数据的第一个数据块是否合法, 是则 执行步骤 402, 否则数据错误, 搡作失败;
本实施例中, 第一个数据块具体为: 可执行加载文件标识长度 + 可执行加载文件标识;
判断所述 APDU数据的第一个数据块是否合法具体包括: 判断所 述 APDU数据的第一个数据块中的可执行加载文件标识长度是否在 预设范围内, 是则所述 APDU数据的第一个数据块合法, 否则所述 APDU数据的第一个数据块不合法;
所述预设范围为: 0x05-0x10。
步骤 402: 检查卡片内是否有与可执行加载文件标识对应的加载 文件结构, 是则执行步骤 403, 否则搡作条件不满足, 搡作失败; 步骤 403 : 判断所述 APDU数据的第二个数据块是否合法, 是则 执行步骤 404, 否则数据错误, 搡作失败;
本实施例中, 第二个数据块具体为: 可执行模块标识长度 +可执 行模块标识;
判断所述 APDU数据的第二个数据块是否合法具体包括: 判断所 述 APD U数据的第二个数据块中的可执行模块标识长度是否在预设 范围内, 是则所述 APDU数据的第二个数据块合法, 否则所述 APDU 数据的第二个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 404: 检查加载文件结构中的存储地址对应的存储空间中是 否有与可执行模块标识对应的可执行模块, 是则执行步骤 405, 否则 搡作条件不满足, 搡作失败; 步骤 405 : 判断所述 APDU数据的第三个数据块是否合法, 是则 执行步骤 406, 否则数据错误, 搡作失败;
本实施例中, 第三个数据块具体为: 应用标识长度 +应用标识; 判断所述 APDU数据的第三个数据块是否合法具体包括: 判断所 述 APDU数据的第三个数据块中的应用标识长度是否在预设范围内, 是则检查所述 APDU数据的第三个数据块中的应用标识的每个字节, 若均为 0x00则所述 APDU数据的第三个数据块不合法, 若不都是 0x00 则所述 APDU数据的第三个数据块合法, 否则所述 APDU数据的第三 个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 406: 检查卡片内是否有与应用标识对应的应用, 是则执行 步骤 407, 否则搡作条件不满足, 搡作失败;
步骤 407 : 判断所述 APDU数据的第四个数据块是否合法, 是则 执行步骤 408, 否则数据错误, 搡作失败;
本实施例中, 第四个数据块具体为: 应用权限长度 +应用权限; 判断所述 APDU数据的第四个数据块是否合法包括: 判断所述 APDU数据的第四个数据块中的应用权限长度是否为 0x01, 是则所述 APDU数据的第四个数据块合法, 否则所述 APDU数据的第四个数据 块不合法。
步骤 408 : 判断本次安装的应用是否具有默认选择权限, 是则执 行步骤 409, 否则执行步骤 411;
本实施例中, 本次安装的应用具体为与第三个数据块中的应用标 识相对应的应用;判断本次安装的应用是否具有默认选择权限具体包 括: 判断所述 APDU数据的第四个数据块中的应用权限是否为 0x04, 是则本次安装的应用具有默认选择权限,否则本次安装的应用不具有 默认选择权限。
步骤 409 : 判断所述 APDU数据的第三字节是否为预设值, 是则 数据错误, 搡作失败; 否则执行步骤 410; 本实施例中, 预设值为 0x04。
步骤 410: 判断卡片内容管理模块是否具有默认选择权限, 是则 执行步骤 413 ; 否则搡作条件不满足, 搡作失败;
本实施例中,通过卡片内容管理模块的权限属性判断其是否具有 默认选择权限, 卡片内容管理模块的权限属性为一个字节数据, 从高 位到地位依次为 b8 b7 b6 b5 b4 b3 b2 bl ;
判断卡片内容管理模块是否具有默认选择权限具体包括:判断卡 片内容管理模块的权限属性的 b3是否为 1, 是则卡片内容管理模块具 有默认选择权限, 否则卡片内容管理模块不具有默认选择权限。
步骤 411 : 判断应用权限是否满足预设条件, 若满足第一预设条 件或第二预设条件则执行步骤 412, 若不满足预设条件则搡作条件不 满足, 搡作失败;
本实施例中, 判断应用权限是否满足预设条件具体包括: 检查应 用权限, 若应用权限从低位端起的第 1比特位、 第 6比特位和第 7比特 位均为 0, 第 8比特位为 1则应用权限满足第一预设条件; 若应用权限 从低位端起的第 1比特位、第 6比特位和第 7比特位不都是 0则应用权限 满足第二预设条件, 否则应用权限不满足预设条件;
步骤 412: 处理所述 APDU数据的第五个数据块中的安装参数域, 执行步骤 413 ;
本实施例中, 第五个数据块具体为: 安装参数域长度 +安装参数 域, 所述安装参数域由 1个或多个 TLV结构数据块 (Tn,Ln, Vn) 的格 式的数据组成, 所述 Vn由 0个或若干个 TLV结构数据块 (Tn ' ,Ln ', Vn ') 组成, 本实施例中, 步骤 412具体包括:
步骤 412-1 :判断安装参数域长度是否为 0x00,是则执行步骤 413, 否则执行步骤 412-2;
步骤 412-2: 获取安装参数域的 1个 TLV结构数据块, 检查该 TLV 结构数据块的 Tn, 若为 0xC9则执行步骤 412-3, 若为 OxEF则执行步骤 412-4, 否则数据错误, 搡作失败; 步骤 412-3 : 存储该 TLV结构数据块的 Vn, 执行步骤 412-9;
步骤 412-4: 获取该 TLV结构数据块的 Vn的一个 TLV结构数据块, 判断 Tn '是否合法, 是则执行步骤 412-5, 否则数据错误, 搡作失败; 步骤 412-5 : 判断 Ln '是否为 0x02, 是则执行步骤 412-6, 否则数 据错误, 搡作失败;
步骤 412-6 : 检查 Tn ', 若为 0xC7则根据 Vn '获取并存储易失性 数据空间限额, 执行步骤 412-7, 若为 0xC8则根据 Vn '获取并存储非 易失性数据空间限额, 执行步骤 412-7 ;
步骤 412-7 :判断该 TLV结构数据块中是否还有未处理的 TLV结构 数据块, 是则返回执行步骤 412-4, 否则执行步骤 412-8 ;
步骤 412-8: 判断卡内非易失性存储空间和易失性存储空间是否 能够满足上述限额, 是则执行步骤 412-9, 否则搡作条件不满足, 搡 作失败;
步骤 412-9 : 判断安装参数域中是否还有未处理的 TLV结构数据 块, 是则返回执行步骤 412-2, 否则执行步骤 413。
步骤 413 : 判断所述 APDU数据的第六个数据块是否合法, 是则 执行步骤 414; 否则数据错误, 搡作失败;
本实施例中, 第六个数据块具体为安装令牌长度 +安装令牌; 判断所述 APDU数据的第六个数据块是否合法具体包括: 判断所 述 APDU数据的第六个数据块中的安装令牌长度是否为 0x00, 是则所 述 APDU数据的第六个数据块合法, 否则所述 APDU数据的第六个数 据块不合法。
步骤 414: 根据所述 APDU数据的数据域中的应用标识注册应用; 本实施例中, 步骤 414具体为: 创建并存储与所述 APDU数据中 的可执行模块标识对应的可执行模块的一个实例, 将该实例与所述 APDU数据中的应用标识唯一关联, 设置该实例的状态为初始值, 根 据所述 APDU数据中的应用权限设置该实例的权限, 并设置该实例的 关联安全域为与所述 APDU数据中的可执行加载文件标识对应的可 执行加载文件的关联安全域。
步骤 415: 判断所述 APD U数据的第三个字节是否等于预设值, 是则执行步骤 419; 否则执行步骤 416;
本实施例中, 预设值为 0x04。
步骤 416: 将本次安装的应用的状态设置为 SELECTABLE (可选 择);
本实施例中, 步骤 416具体为: 将本次安装的应用的状态属性设 为 0x07。
步骤 417 : 判断本次安装的应用是否具有默认选择权限, 是则执 行步骤 418, 否则搡作成功;
步骤 418 : 设置本次安装的应用为默认应用, 搡作成功; 步骤 419: 设置本次安装的应用的状态为 INSTALLED (安装), 搡作成功。
本实施例中, 步骤 419具体为: 设置本次安装的应用的状态属性 为 0x03。 实施例五
本发明实施例五提供一种实施例一中提供的管理卡片上应用的 方法中设置应用状态的具体方法, 本实施例中的 APDU数据的数据域 部分可看作是由多个数据块组成的, 每个数据块都是一个 LV结构, 即数据长度 +数据的结构; 参见图 5, 所述方法具体包括:
步骤 501: 判断所述 APDU数据的第一个数据块和第二个数据块 是否均合法, 是则执行步骤 502, 否则数据错误, 搡作失败;
本实施例中, 判断所述 APDU数据的第一个数据块是否合法具体 包括: 判断所述 APDU数据的第一个数据块是否为 0x00, 是则所述 APDU数据的第一个数据块合法, 否则所述 APDU数据的第一个数据 块不合法;
判断所述 APDU数据的第二个数据块是否合法具体包括: 判断所 述 APDU数据的第二个数据块是否为 0x00, 是则所述 APDU数据的第 二个数据块合法, 否则所述 APDU数据的第二个数据块不合法。
步骤 502: 判断所述 APDU数据的第三个数据块是否合法, 是则 执行步骤 503, 否则数据错误, 搡作失败;
本实施例中, 第三个数据块具体为: 应用标识长度 +应用标识; 判断所述 APDU数据的第三个数据块是否合法具体包括: 判断所 述 APDU数据的第三个数据块中的应用标识长度是否在预设范围内, 是则所述 APDU数据的第三个数据块合法, 否则所述 APDU数据的第 三个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 503 : 检查卡片内是否有与应用标识对应的应用, 是则执行 步骤 504, 否则搡作条件不满足, 搡作失败;
步骤 504: 判断与应用标识对应的应用 的状态是否为 INSTALLED, 是则执行步骤 505, 否则搡作条件不满足, 搡作失败; 步骤 505 : 判断所述 APDU数据的第四个数据块是否合法, 是则 执行步骤 506, 否则数据错误, 搡作失败;
本实施例中, 第四个数据块具体为应用权限长度 +应用权限; 判断所述 APDU数据的第四个数据块是否合法具体包括: 判断所 述 APDU数据的第四个数据块中的应用权限长度是否为 0x01, 是则所 述 APDU数据的第四个数据块合法, 否则所述 APDU数据的第四个数 据块不合法。
步骤 506 : 判断所述 APDU数据的第五个数据块是否合法, 是则 执行步骤 507, 否则数据错误, 搡作失败;
本实施例中, 第五个数据块具体为参数域长度 +参数域; 判断所述 APDU数据的第五个数据块是否合法具体包括: 判断所 述 APDU数据的第五个数据块中的参数域长度是否为 0x00, 是则所述
APDU数据的第五个数据块合法, 否则所述 APDU数据的第五个数据 块不合法。 步骤 507 : 判断所述 APDU数据的第六个数据块是否合法, 是则 执行步骤 508, 否则数据错误, 搡作失败;
本实施例中, 第六个数据块具体为: 可选择令牌长度 +可选择令 牌;
判断所述 APDU数据的第六个数据块是否合法具体包括: 判断所 述 APDU数据的第六个数据块中的可选择令牌长度是否为 0x00, 是则 所述 APDU数据的第六个数据块合法, 否则所述 APDU数据的第六个 数据块不合法。
步骤 508 : 将与 应 用 标识对应的应 用 的状态设置 为 SELECTABLE;
本实施例中, 步骤 508具体为设置与应用标识对应的应用的状态 属性为 0x07。
步骤 509: 判断与应用标识对应的应用是否具有默认选择权限, 是则执行步骤 510, 否则搡作成功;
步骤 510: 判断卡片内容管理模块是否具有默认选择权限, 是则 执行步骤 511, 否则搡作条件不满足, 搡作失败;
本实施例中,通过卡片内容管理模块的权限属性判断其是否具有 默认选择权限, 卡片内容管理模块的权限属性为一个字节数据, 从高 位到地位依次为 b8 b7 b6 b5 b4 b3 b2 bl ;
判断卡片内容管理模块是否具有默认选择权限具体包括:判断卡 片内容管理模块的权限属性的 b3是否为 1, 是则卡片内容管理模块具 有默认选择权限, 否则卡片内容管理模块不具有默认选择权限。
步骤 511 : 设置与应用标识对应的应用为默认应用, 搡作成功。 实施例六
本发明实施例六提供一种实施例一中提供的管理卡片上应用的 方法中更新应用的关联安全域的具体方法, 本实施例中的 APDU数据 的数据域部分可看作是由多个数据块组成的, 每个数据块都是一个 LV结构, 即数据长度 +数据的结构; 参见图 6, 所述方法具体包括: 步骤 601 : 判断所述 APDU数据的第一个数据块是否合法, 是则 执行步骤 602, 否则数据错误, 搡作失败;
本实施例中, 第一个数据块具体为: 安全域标识长度 +安全域标 识;
判断所述 APDU数据的第一个数据块是否合法具体包括: 判断所 述 APDU数据的第一个数据块中的安全域标识长度是否在预设范围 内, 是则所述 APDU数据的第一个数据块合法, 否则所述 APDU数据 的第一个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 602: 检查卡片内是否有与安全域标识对应的应用, 是则执 行步骤 603, 否则搡作条件不满足, 搡作失败;
步骤 603 : 判断与安全域标识对应的应用是否为卡片内容管理模 块, 是则搡作条件不满足, 搡作失败, 否则执行步骤 604;
步骤 604: 判断所述 APDU数据的第二个数据块是否合法, 是则 执行步骤 605, 否则数据错误, 搡作失败;
本实施例中, 判断所述 APDU数据的第二个数据块是否合法具体 包括: 判断所述 APDU数据的第二个数据块是否为 0x00, 是则所述 APDU数据的第二个数据块合法, 否则所述 APDU数据的第二个数据 块不合法。
步骤 605: 判断与安全域标识对应的应用的状态是否为 INSTALLED, 是则执行步骤 606, 否则搡作条件不满足, 搡作失败; 步骤 606 : 判断所述 APDU数据的第三个数据块是否合法, 是则 执行步骤 607, 否则数据错误, 搡作失败;
本实施例中, 第三个数据块具体为: 应用标识长度 +应用标识; 判断所述 APDU数据的第三个数据块是否合法具体包括: 判断所 述 APDU数据的第三个数据块中的应用标识长度是否在预设范围内, 是则所述 APDU数据的第三个数据块合法, 否则所述 APDU数据的第 三个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 607 : 检查卡片内是否有与应用标识对应的应用, 是则执行 步骤 608, 否则搡作条件不满足, 搡作失败;
步骤 608: 判断与安全域标识对应的应用是否具有安全域权限, 是则执行步骤 609; 否则搡作条件不满足, 搡作失败;
本实施例中, 步骤 608具体包括: 判断与安全域标识对应的应用 的权限属性最高比特位是否为 1, 是则与安全域标识对应的应用具有 安全域权限, 否则与安全域标识对应的应用不具有安全域权限。
步骤 609: 判断与安全域标识对应的应用的状态是否为 LOCKED (锁定), 是则搡作条件不满足, 搡作失败; 否则执行步骤 610; 步骤 610: 判断与安全域标识对应的应用的状态是否为 PERSONALIZED (个人化), 是则执行步骤 611, 否则搡作条件不满 足, 搡作失败;
步骤 611 :判断所述 APDU数据的第四个数据块和第五个数据块是 否均合法, 是则执行步骤 612, 否则数据错误, 搡作失败;
本实施例中, 判断所述 APDU数据的第四个数据块是否合法具体 包括: 判断所述 APDU数据的第四个数据块是否为 0x00, 是则所述 APDU数据的第四个数据块合法, 否则所述 APDU数据的第四个数据 块不合法;
判断所述 APDU数据的第五个数据块是否合法具体包括: 判断所 述 APDU数据的第五个数据块是否为 0x00, 是则所述 APDU数据的第 五个数据块合法, 否则所述 APDU数据的第五个数据块不合法。
步骤 612: 判断所述 APDU数据的第六个数据块是否合法, 是则 执行步骤 613, 否则数据错误, 搡作失败;
本实施例中, 第六个数据块具体为: 引渡令牌长度 +引渡令牌; 判断所述 APDU数据的第六个数据块是否合法具体包括: 判断所 述 APDU数据的第六个数据块中的引渡令牌长度是否为 0x00, 是则所 述 APDU数据的第六个数据块合法, 否则所述 APDU数据的第六个数 据块不合法。
步骤 613 : 判断与应用标识对应的应用是否具有安全域权限, 是 则搡作条件不满足, 搡作失败; 否则执行步骤 614;
本实施例中, 步骤 613具体包括: 判断与应用标识对应的应用的 权限属性最高比特位是否为 1, 是则与应用标识对应的应用具有安全 域权限, 否则与应用标识对应的应用不具有安全域权限。
步骤 614: 设置与应用标识对应的应用的关联安全域为与安全域 标识对应的应用, 搡作成功。 实施例七
本发明实施例七提供一种实施例一中提供的管理卡片上应用的 方法中个人化应用的具体方法, 本实施例中的 APDU数据的数据域部 分可看作是由多个数据块组成的, 每个数据块都是一个 LV结构, 即 数据长度 +数据的结构; 参见图 7, 所述方法具体包括:
步骤 701 : 判断所述 APDU数据的第一个数据块和第二个数据块 是否均合法, 是则执行步骤 702, 否则数据错误, 搡作失败;
本实施例中, 判断所述 APDU数据的第一个数据块是否合法具体 包括: 判断所述 APDU数据的第一个数据块是否为 0x00, 是则所述 APDU数据的第一个数据块合法, 否则所述 APDU数据的第一个数据 块不合法;
判断所述 APDU数据的第二个数据块是否合法具体包括: 判断所 述 APDU数据的第二个数据块是否为 0x00, 是则所述 APDU数据的第 二个数据块合法, 否则所述 APDU数据的第二个数据块不合法。
步骤 702: 判断所述 APDU数据的第三个数据块是否合法, 是则 执行步骤 703, 否则数据错误, 搡作失败;
本实施例中, 第三个数据块具体为应用标识长度 +应用标识; 判断所述 APDU数据的第三个数据块是否合法具体包括: 判断所 述 APDU数据的第三个数据块中的应用标识长度是否在预设范围内, 是则所述 APDU数据的第三个数据块合法, 否则所述 APDU数据的第 三个数据块不合法;
所述预设范围为 0x05-0x10。
步骤 703 : 检查卡片内是否有与应用标识对应的应用, 是则执行 步骤 704, 否则搡作条件不满足, 搡作失败;
步骤 704: 判断与应用标识对应的应用的关联安全域是否为卡片 内容管理模块, 是则执行步骤 705, 否则搡作条件不满足, 搡作失败; 步骤 705 : 判断所述 APDU数据的第四个数据块、 第五个数据块 和第六个数据块是否均合法, 是则执行步骤 706, 否则数据错误, 搡 作失败;
本实施例中, 判断所述 APDU数据的第四个数据块是否合法具体 包括: 判断所述 APDU数据的第四个数据块是否为 0x00, 是则所述 APDU数据的第四个数据块合法, 否则所述 APDU数据的第四个数据 块不合法;
判断所述 APDU数据的第五个数据块是否合法具体包括: 判断所 述 APDU数据的第五个数据块是否为 0x00, 是则所述 APDU数据的第 五个数据块合法, 否则所述 APDU数据的第五个数据块不合法;
判断所述 APDU数据的第六个数据块是否合法具体包括: 判断所 述 APDU数据的第六个数据块是否为 0x00, 是则所述 APDU数据的第 六个数据块合法, 否则所述 APDU数据的第六个数据块不合法。
步骤 706: 将与应用标识对应的应用的状态设为 PERSONLIZED, 搡作成功。 实施例八
本发明实施例八提供一种实施例一中提供的管理卡片上应用的 方法中删除应用及可执行加载文件的具体方法, 本实施例中的 APDU 数据的数据域部分可看作是由多个数据块组成的,每个数据块都是一 个 LV结构, 即数据长度 +数据的结构; 参见图 8, 所述方法具体包括: 步骤 801 : 判断所述 APDU数据的第一个数据块是否合法, 是则 执行步骤 802, 否则数据错误, 搡作失败;
本实施例中, 判断所述 APDU数据的第一个数据块是否合法具体 包括: 判断所述 APDU数据的第一个数据块是否为 0x4f, 是则所述
APDU数据的第一个数据块合法, 否则所述 APDU数据的第一个数据 块不合法。
步骤 802: 判断所述 APDU数据的第二个数据块是否合法, 是则 执行步骤 803, 否则数据错误, 搡作失败;
本实施例中,第二个数据块具体为数据域标识长度 +数据域标识; 判断所述 APDU数据的第二个数据块是否合法具体包括: 判断所 述 APDU数据的第二个数据块中的数据域标识长度是否在预设范围 内, 是则所述 APDU数据的第二个数据块合法, 否则所述 APDU数据 的第二个数据块不合法;
所述预设范围为: 0x05-0x10。
步骤 803 : 检查卡片内是否有与数据域标识对应的应用, 是则执 行步骤 804, 否则执行步骤 805 ;
步骤 804: 判断所述 APD U数据的第四个字节是否等于预设值, 是则执行步骤 805, 否则执行步骤 809;
本实施例中, 预设值为 0x80。
步骤 805 : 检查卡片内是否有与数据域标识对应的可执行加载文 件, 是则执行步骤 806, 否则搡作条件不满足, 搡作失败;
步骤 806: 判断所述 APDU数据的第四个字节是否等于预设值, 是则执行步骤 807, 否则执行步骤 808 ;
本实施例中, 预设值为 0x80。
步骤 807: 删除与数据域标识对应的应用和与数据域标识对应的 可执行加载文件, 搡作成功;
步骤 808 : 删除与数据域标识对应的可执行加载文件, 搡作成功; 步骤 809: 检查与数据域标识对应的应用是否为其他应用或其他 可执行加载文件的关联安全域, 是则搡作条件不满足, 搡作失败; 否 则执行步骤 810;
步骤 810: 判断与数据域标识对应的应用是否为卡片内容管理模 块, 是则搡作条件不满足, 搡作失败; 否则执行步骤 811 ;
步骤 811 : 删除与数据域标识对应的应用, 搡作成功。 实施例九
需说明的是, 在本发明实施例中, 将智能卡简称为卡片。
本发明实施例提供的一种管理卡片数据的实现方法, 参见图 9, 所述方法具体包括当第一卡片数据管理模块接收到运行环境发送的 APDU ( ApplicationProtocolDataUnit , 应用协议数据单元) 数据后将 自身作为当前第一卡片数据管理模块, 执行以下步骤:
步骤 901 : 检查所述 APDU数据的 INS (指令码) ,若为 0xE8则执 行步骤 1101至步骤 1129; 若为 0xE6则执行步骤 902; 若为 0xE4则执行 步骤 1601至步骤 1625 ; 若为其他有效数值则所述 APDU数据为其他非 内容管理的有效命令, 根据所述 APDU数据执行相应搡作; 否则所述 APDU数据为无效命令, 生成并返回相应状态码;
具体地, 所述其他有效数值包括: 0xA4、 0x78、 0x7 A, 0x82、 0x50、 0xE2、 0xF0、 0xD8、 0xF2、 OxCA;
步骤 902: 检查所述 APDU数据的 PI (第一参数), 若为 0x02则执 行步骤 1001至步骤 1028;若为 0x04或 OxOC则执行步骤 1201至步骤 1235; 若为 0x08则执行步骤 1301至步骤 1324;若为 0x10则执行步骤 1401至步 骤 1428 ; 若为 0x20则执行步骤 1501至步骤 1517 ; 否则所述 APDU数据 为无效命令, 生成并返回相应状态码;
在本发明中,所述第一卡片数据管理模块为卡片中一种特殊的应 用, 为应用提供商在卡上的代表;
优选地, 参见图 10, 步骤 1001至步骤 1028具体如下: 步骤 1001: 判断所述 APDU数据是否为合法的预加载命令的命令 头, 是则执行步骤 1002, 否则执行步骤 1027;
具体地, 当所述 APDU数据的 CLA (指令类别) 为 0x80或 0x84、 P2 (第二参数)为 0x00且 Lc (数据域长度)不小于 OxOA时,所述 APDU 数据为合法的预加载命令的命令头;
步骤 1002: 判断卡片的当前状态是否为 TERMINATED (终止) 或 CARD_LOCKED (锁定), 是则执行步骤 1027, 否则执行步骤 1003; 具体地, 通过卡片的状态属性判断其状态, 卡片的状态属性为一 个字节数据, 从高位到低位依次为138137136135134133132131, 卡片的状 态包括准备 OP_READY、 初始化 INITIALIZED、 安全 SECURED、 锁 定 CARD_LOCKED和终止 TERMINATED, 参见下表:
Figure imgf000036_0001
进一步地, 步骤 1001和步骤 1002的位置可以调换: 首先判断卡片 的当前状态是否为终止或卡片锁定, 是则执行步骤 1027, 否则判断所 述 APDU数据是否为合法的预加载命令的命令头, 是则执行步骤 1003, 否则执行步骤 1027;
步骤 1003:收取预加载命令的数据域部分,得到完整预加载命令; 步骤 1004 : 判断当前第一卡片数据管理模块状态是否为 PERSONALIZED, 是则执行步骤 1005, 否则执行步骤 1027; 具体地, 第一卡片数据管理模块通过当前第一卡片数据管理模块 的状态属性判断当前第一卡片数据管理模块的状态, 第一卡片数据管 理模块的状态属性为一个字节数据, 从高位到低位依次为 b8b7b6b5 b4b3 b2bl, 第一卡片数据管理模块的状态包括已安装 INSTALLED、 可选择 SELECTABLE、 个人化 PERSONALIZED和锁定 LOCKED, 参 见下表:
Figure imgf000037_0001
步骤 1005: 判断当前第一卡片数据管理模块是否具有代理权限, 是则执行步骤 1006, 否则执行步骤 1027;
具体地, 第一卡片数据管理模块通过当前第一卡片数据管理模块 的权限属性判断当前第一卡片数据管理模块是否具有代理权限, 第一 卡片数据管理模块的权限属性为一个字节数据,从高位到低位依次为 b8b7b6b5b4b3b2bl, 当 b8和 b6均为 1时, 第一卡片数据管理模块 具有代理权限;
步骤 1006: 判断卡片是否满足安全条件, 是则执行步骤 1007, 否 则执行步骤 1027;
具体地, 第一卡片数据管理模块通过检查卡片的安全标志判断卡 片是否满足安全条件, 若所述安全标志置位则卡片满足安全条件, 若 所述安全标志未置位则卡片不满足安全条件, 当卡片依次正确执行完 INS字节的值为 0x50的合法命令以及 INS字节的值为 0x82的合法命令 时所述安全标志被置位; 步骤 1007 :检查卡片的安全级别,若为第一级别则执行步骤 1010, 若为第二级别则执行步骤 1008, 若为第三级别则执行步骤 1009;
INS字节的值为 0x82的两条合法命令确定的;
具体地, 若卡片的安全级别为第一级别, 则所述预加载命令为消 息数据明文, 若卡片的安全级别为第二级别, 则所述预加载命令为消 息数据明文和消息认证码 (Message Authentication Code, 简称 MAC) 的组合, 若卡片的安全级别为第三级别, 则所述预加载命令为消息数 据密文和消息认证码的组合;
步骤 1008 : 根据所述预加载命令中的消息数据明文和 MAC (消 息认证码) 判断所述预加载命令是否完整, 是则执行步骤 1010, 否则 执行步骤 1027 ;
其中,所述根据所述预加载命令中的消息数据明文和消息认证码 判断所述预加载命令是否完整具体包括:利用约定的会话密钥对消息 认证码进行解密得到解密结果, 同时根据约定的散列函数对消息数据 明文进行计算得到计算结果,判断所述解密结果和所述计算结果是否 相同, 是则所述预加载命令完整, 否则所述预加载命令不完整;
步骤 1009: 根据所述预加载命令中的消息数据密文和 MAC判断 所述预加载命令是否完整, 是则执行步骤 1010, 否则执行步骤 1027 ; 其中,所述根据所述预加载命令中的消息数据密文和消息认证码 判断所述预加载命令是否完整具体包括:对消息数据密文解密得到消 息数据明文,利用约定的会话密钥对消息认证码进行解密得到解密结 果, 同时根据约定的散列函数对消息数据明文进行计算得到计算结 果, 判断所述解密结果和所述计算结果是否相同, 是则所述预加载命 令完整, 否则所述预加载命令不完整;
步骤 1010:判断所述预加载命令中的加载文件标识长度是否在预 设范围内, 是则执行步骤 1011, 否则执行步骤 1027 ;
具体地, 所述预设范围为 0x05-0x10; 步骤 1011 : 判断所述预加载命令中的加载文件标识是否合法, 是 则执行步骤 1012, 否则执行步骤 1027;
具体地, 所述加载文件标识, 当其每个字节均为 0x00时不合法, 否则合法;
步骤 1012:检查卡片内是否已存在所述加载文件标识对应的加载 文件, 是则执行步骤 1027, 否则执行步骤 1013 ;
步骤 1013 :判断所述预加载命令中的安全域标识长度是否在预设 范围内, 是则执行步骤 1014, 否则执行步骤 1027 ;
具体地, 所述预设范围为 0x05-0x10;
步骤 1014: 判断所述预加载命令中的安全域标识是否合法, 是则 执行步骤 1015, 否则执行步骤 1027 ;
具体地, 所述安全域标识, 当其每个字节均为 0x00时不合法, 否 则合法;
步骤 1015 :检查卡片内是否存在所述预加载命令中的安全域标识 对应的应用, 是则执行步骤 1016, 否则执行步骤 1027 ;
步骤 1016:判断所述预加载命令中的安全域标识对应的应用是否 具有安全域权限, 是则执行步骤 1017, 否则执行步骤 1027 ;
具体地, 通过应用的权限属性判断其是否具有安全域权限, 应用 的权限属性为一个字节数据, 从高位到低位依次为 b8 b7 b6 b5 b4 b3 b2 bl, 当 b8为 1时, 应用具有安全域权限;
步骤 1017:判断所述预加载命令中的安全域标识对应的应用是否 为当前第一卡片数据管理模块, 是则执行步骤 1019, 否则执行步骤 1018 ;
步骤 1018:判断所述预加载命令中的安全域标识对应的应用的状 态是否为 PERSONALIZED (个人化), 是则执行步骤 1019, 否则执行 步骤 1027 ;
步骤 1019:设置所述预加载命令中的加载文件标识对应的加载文 件的关联安全域为所述预加载命令中的安全域标识对应的应用; 步骤 1020:判断所述预加载命令中的加载文件数据块哈希值长度 是否为预设值, 是则执行步骤 1021, 否则执行步骤 1027 ;
优选地, 在本实施例中, 所述预设值为 0x14;
步骤 1021 :存储所述预加载命令中的加载文件数据块哈希值并设 置哈希值验证标志;
步骤 1022: 处理所述预加载命令中的加载参数域;
具体地, 所述加载参数域为 TLV结构, 即由多个标签 +长度 +值的 格式的数据组成, 根据不同的标签执行不同的搡作, 在此不进行详细 表述;
步骤 1023 : 判断所述预加载命令中的加载令牌长度是否为 0x80, 是则执行步骤 1024, 否则执行步骤 1027;
步骤 1024:发送计算加载令牌所需的数据给第二卡片数据管理模 块, 接收第二卡片数据管理模块返回的计算结果, 判断所述计算结果 与所述预加载命令中的加载令牌是否相同, 是则执行步骤 1025, 否则 执行步骤 1027 ;
其中, 所述第二卡片数据管理模块也是卡片中的一个特殊应用; 具体地, 发送所述预加载命令中的 Pl、 P2、 有效数据的长度、 加 载文件标识长度、 加载文件标识、 安全域标识长度、 安全域标识、 加 载文件数据块哈希值长度、 加载文件数据块哈希值、 加载参数域长度 以及加载参数域给第二卡片数据管理模块, 关于卡片发行商验证加载 令牌的过程, 在此不进行详细表述;
步骤 1025 : 新建加载文件结构, 初始化全局块编号;
具体地, 初始化全局块编号为 0, 所述新建加载文件结构包括: 在緩存中创建一个可执行加载文件结构的对象,将所述对象的各个属 性值设置为默认值,所述对象的属性值包括各加载文件数据块在緩存 中的存储地址以及可执行加载文件的各个属性,所述可执行加载文件 的属性如可执行加载文件关联安全域标识等, 在此不做具体描述; 步骤 1026: 设置返回数据为 0x00, 执行步骤 1027 ; 步骤 1027 : 生成相应状态码;
具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码;
步骤 1028: 返回设置的返回数据和 /或生成的状态码; 优选地, 参见图 11, 步骤 1101至步骤 1129具体如下:
步骤 1101 :判断所述 APDU数据是否为合法的加载命令的命令头, 是则执行步骤 1102, 否则执行步骤 1128;
具体地, 当所述 APDU数据的 CLA为 0x80或 0x84、 P1为 0x00或 0x80且 P2在 OxOO-OxFF之间时, 所述 APDU数据合法;
步骤 1102: 判断卡片 当前的状态是否为 TERMANATED或 CARD_LOCKED, 是则执行步骤 1128, 否则执行步骤 1103 ;
步骤 1103 : 收取加载命令的数据域部分, 得到完整加载命令; 步骤 1104 : 判断当前第一卡片数据管理模块的状态是否为 PERSONALIZED, 是则执行步骤 1105, 否则执行步骤 1128 ;
步骤 1105 : 判断当前第一卡片数据管理模块是否具有代理权限, 是则执行步骤 1106, 否则执行步骤 1128;
步骤 1106: 判断卡片是否满足安全条件, 是则执行步骤 1107, 否 则执行步骤 1128 ;
步骤 1107 :检查卡片的安全级别,若为第一级别则执行步骤 1110, 若为第二级别则执行步骤 1108, 若为第三级别则执行步骤 1109;
具体地, 若卡片的安全级别为第一级别, 则所述加载命令为消息 数据明文, 若卡片的安全级别为第二级别, 则所述加载命令为消息数 据明文和消息认证码的组合, 若卡片的安全级别为第三级别, 则所述 加载命令为消息数据密文和消息认证码的组合;
步骤 1108: 根据所述加载命令中的消息数据明文和 MAC判断所 述加载命令是否完整, 是则执行步骤 1110, 否则执行步骤 1128 ;
其中, 所述根据所述加载命令中的消息数据明文和 MAC判断所 述加载命令是否完整具体包括: 利用约定的会话密钥对 MAC进行解 密得到解密结果, 同时根据约定的散列函数对消息数据明文进行计算 得到计算结果, 判断所述解密结果和所述计算结果是否相同, 是则所 述加载命令完整, 否则所述加载命令不完整;
步骤 1109: 根据所述加载命令中的消息数据密文和 MAC判断所 述加载命令是否完整, 是则执行步骤 1110, 否则执行步骤 1128 ;
其中, 所述根据所述加载命令中的消息数据密文和 MAC判断所 述加载命令是否完整具体包括:对消息数据密文解密得到消息数据明 文, 利用约定的会话密钥对 MAC进行解密得到解密结果, 同时根据 约定的散列函数对消息数据明文进行计算得到计算结果,判断所述解 密结果和所述计算结果是否相同, 是则所述加载命令完整, 否则所述 加载命令不完整;
步骤 1110: 判断所述加载命令中的 P2是否等于所述全局块编号, 是则执行步骤 1111, 否则执行步骤 1128;
步骤 1111 : 判断所述全局块编号是否为 0, 是则执行步骤 1112, 否则执行步骤 1113 ;
步骤 1112 : 验证所述加载命令中的 DAP ( Data Authentication Pattern, 数据验证模式) 块信息, 若验证通过则执行步骤 1113, 若验 证不通过则执行步骤 1128;
具体地, 加载文件在卡外被分割为若干个加载文件数据块, 每条 加载命令中包含一个加载文件数据块, 当所述加载命令的 P2等于全局 块编号, 且全局块编号为 0时, 所述加载命令中还包含 DAP块信息, DAP块信息中包含加载文件数据块签名值, 第一卡片数据管理模块根 据当前第一卡片数据管理模块存储的应用提供商 DAP计算密钥对 DAP块信息中的加载文件数据块签名值进行验证;
步骤 1113 : 判断卡片内是否存在哈希值验证标志, 是则保存所述 加载命令中的加载文件数据块, 执行步骤 1114, 否则直接执行步骤 1114; 步骤 1114:判断所述可执行加载文件结构中是否有未提交存储的 组件, 是则执行步骤 1118, 否则执行步骤 1115 ;
具体地, 应用以组件为单位对加载的加载文件数据块进行处理, 得到可执行加载文件结构, 所述组件包括: Header组件、 Directory组 件、 Applet组件、 Import组件等;
步骤 1115 : 检查所述加载命令中是否包含组件编号和组件大小, 是则执行步骤 1116, 否则执行步骤 1128;
步骤 1116 : 读取所述组件编号, 判断所述组件编号是否合法, 是 则执行步骤 1117, 否则执行步骤 1128;
具体地, 除首次读取到组件编号外, 若所述组件编号与上一次读 取到的组件编号是连续的则所述编号合理, 否则所述编号不合理; 步骤 1117: 根据所述组件大小分派相应大小的空间;
步骤 1118 : 开始处理所述加载命令中的加载文件数据块; 步骤 1119 : 判断当前组件是否处理完成, 是则执行步骤 320, 否 则执行步骤 1121 ;
具体地,所述判断当前组件是否处理完成为判断当前组件中已经 处理的数据的大小是否等于所述当前组件的大小;
步骤 1120: 提交当前组件的处理结果, 执行步骤 1121 ;
步骤 1121 : 判断是否还有未处理的加载文件数据块数据, 是则返 回执行步骤 1115, 否则执行步骤 1122;
步骤 1122: 所述全局块编号自增, 判断所述加载命令的 P1是否为 0x80, 是则执行步骤 1123, 否则执行步骤 1127 ;
具体的, 所述全局块编号自增 1 ;
步骤 1123 : 判断卡片内是否存在哈希值验证标志, 是则执行步骤 1124, 否则执行步骤 1125 ;
步骤 1124: 对已存储的加载文件数据块进行哈希计算, 判断计算 结果是否等于加载文件数据块哈希值, 是则执行步骤 1125, 否则执行 步骤 1128 ; 步骤 1125 : 提交存储所述可执行加载文件结构; 步骤 1126: 发送计算收条所需的数据给第二卡片数据管理模块, 接收第二卡片数据管理模块返回的收条, 设置返回数据为所述收条, 执行步骤 1128 ;
具体地, 发送所述加载命令中的加载文件数据块对应的加载文件 标识的长度、 加载文件标识、 安全域标识的长度、 安全域标识给卡片 提供商模块;
步骤 1127 : 设置返回数据为 0x00, 执行步骤 1128 ;
步骤 1128 : 生成相应状态码;
具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码;
步骤 1129: 返回设置的返回数据和 /或生成的状态码; 优选地, 参见图 12, 步骤 1201至步骤 1235具体如下:
步骤 1201: 判断所述 APD U数据是否为合法的安装命令的命令 头, 是则执行步骤 1202, 否则执行步骤 1234;
具体地, 当所述 APDU数据的 CLA为 0x80或 0x84、 P2为 0x00且 Lc 不小于 0x18时, 所述 APDU数据为合法的安装命令的命令头;
步骤 1202: 判断卡片 的当前状态是否为 TERMANATED或 CARD_LOCKED, 是则执行步骤 1234, 否则执行步骤 1203 ;
步骤 1203 : 收取安装命令的数据域部分, 得到完整安装命令; 步骤 1204 : 判断当前第一卡片数据管理模块的状态是否为 PERSONALIED, 是则执行步骤 1205, 否则执行步骤 1234;
步骤 1205: 判断当前第一卡片数据管理模块是否具有代理权限, 是则执行步骤 1206, 否则执行步骤 1234;
步骤 1206: 判断卡片是否满足安全条件, 是则执行步骤 1207, 否 则执行步骤 1234;
步骤 1207 :检查卡片的安全级别,若为第一级别则执行步骤 1210, 若为第二级别则执行步骤 1208, 若为第三级别则执行步骤 1209; 具体地, 若卡片的安全级别为第一级别, 则所述安装命令为消息 数据明文, 若卡片的安全级别为第二级别, 则所述安装命令为消息数 据明文和消息认证码的组合, 若卡片的安全级别为第三级别, 则所述 安装命令为消息数据密文和消息认证码的组合;
步骤 1208: 根据所述安装命令中的消息数据明文和 MAC判断所 述安装命令是否完整, 是则执行步骤 1210, 否则执行步骤 1234; 其中, 所述根据所述安装命令中的消息数据明文和 MAC判断所 述安装命令是否完整具体包括: 利用约定的会话密钥对 MAC进行解 密得到解密结果, 同时根据约定的散列函数对消息数据明文进行计算 得到计算结果, 判断所述解密结果和所述计算结果是否相同, 是则所 述安装命令完整, 否则所述安装命令不完整;
步骤 1209: 根据所述安装命令中的消息数据密文和 MAC判断所 述安装命令是否完整, 是则执行步骤 1210, 否则执行步骤 1234; 其中, 所述根据所述安装命令中的消息数据密文和 MAC判断所 述安装命令是否完整具体包括:对消息数据密文解密得到消息数据明 文, 利用约定的会话密钥对 MAC进行解密得到解密结果, 同时根据 约定的散列函数对消息数据明文进行计算得到计算结果,判断所述解 密结果和所述计算结果是否相同, 是则所述安装命令完整, 否则所述 安装命令不完整;
步骤 1210:判断所述安装命令中的可执行加载文件标识长度是否 在预设范围内, 是则执行步骤 1211, 否则执行步骤 1234;
具体地, 所述预设范围为 0x05-0x10; 件标识对应的可执行加载文件, 是则执行步骤 1212, 否则执行步骤 1234;
步骤 1212:判断所述安装命令中的可执行加载文件标识对应的可 执行加载文件关联的安全域是否为当前第一卡片数据管理模块,是则 执行步骤 1213, 否则执行步骤 1234;
步骤 1213:判断所述安装命令中的可执行模块标识长度是否在预 设范围内, 是则执行步骤 1214, 否则执行步骤 1234;
具体地, 所述预设范围为 0x05-0x10; 识对应的可执行模块, 是则执行步骤 1215, 否则执行步骤 1234;
步骤 1215 :判断所述安装命令中的应用标识长度是否在预设范围 内, 是则执行步骤 1216, 否则执行步骤 1234;
具体地, 所述预设范围为 0x05-0x10;
步骤 1216 : 判断所述安装命令中的应用标识是否合法, 是则执行 步骤 1217, 否则执行步骤 1234;
具体地, 所述应用标识当其每个字节均为 0x00时不合法, 否则合 法;
步骤 1217 :判断卡片内是否存在所述安装命令中的应用标识对应 的应用, 是则执行步骤 1234, 否则执行步骤 1218 ;
步骤 1218 : 判断所述安装命令中的应用权限长度是否为 0x01, 是 则执行步骤 1219, 否则执行步骤 1234;
步骤 1219 : 判断所述安装命令中的应用权限是否为 0x04, 是则执 行步骤 1220, 否则执行步骤 1222;
步骤 1220 : 判断所述安装命令的 P1是否为 0x04, 是则执行步骤 1234, 否则执行步骤 1221 ;
步骤 1221: 判断第二卡片数据管理模块是否具有默认选择权限, 是则执行步骤 1222, 否则执行步骤 1234;
具体地,通过第二卡片数据管理模块的权限属性判断其是否具有 默认选择权限, 第二卡片数据管理模块的权限属性为一个字节数据, 从高位到低位依次为138 137 136 135 134 133 132 131, 当 b3为 1时, 第二卡片 数据管理模块具有默认选择权限;
步骤 1222:判断所述安装命令的应用权限的低位端起第 1比特位、 第 6比特位和第 7比特位是否均为 0, 是则执行步骤 1223, 否则执行步 骤 1224;
步骤 1223:判断所述安装命令的应用权限的最高比特位是否为 1, 是则执行步骤 1224, 否则执行步骤 1234;
步骤 1224: 处理所述安装命令中的安装参数域;
步骤 1225 : 判断所述安装命令中的安装令牌长度是否为 0x80, 是 则执行步骤 1226, 否则执行步骤 1234;
步骤 1226:发送计算安装令牌所需的数据给第二卡片数据管理模 块, 接收第二卡片数据管理模块返回的计算结果, 判断所述计算结果 和所述安装命令中的安装令牌是否相同, 是则执行步骤 1227, 否则执 行步骤 1234;
具体地, 发送所述安装命令的 Pl、 P2、 有效数据的长度、 可执行 加载文件标识长度、 可执行加载文件标识、 可执行模块标识长度、 可 执行模块标识、应用标识长度、应用标识、应用权限长度、应用权限、 安装参数域长度以及安装参数域给第二卡片数据管理模块;
步骤 1227 : 根据所述安装命令的数据域中的数据注册应用; 步骤 1228 : 判断所述安装命令中的 P1是否为 0x04, 是则执行步骤 1232, 否则执行步骤 1229;
步骤 1229:将所述安装命令中的应用标识对应的应用的状态设置 为 SELECTABLE (可选择);
具体地, 步骤 1229为将所述安装命令中的应用标识对应的应用的 状态属性的值设置为 0x07 ;
步骤 1230: 判断所述安装命令中的应用权限是否为 0x04, 是则执 行步骤 1231, 否则执行步骤 1233 ;
步骤 1231:将所述安装命令中的应用标识对应的应用设置为默认 应用, 执行步骤 1233 ;
步骤 1232:将所述安装命令中的应用标识对应的应用的状态设置 为 INSTALLED (安装), 执行步骤 1233 ; 具体地, 步骤 1232包括: 将所述得到的命令中的应用标识对应的 应用的状态属性的值设置为 0x03;
步骤 1233 : 发送计算收条所需的数据给第二卡片数据管理模块, 接收第二卡片数据管理模块返回的收条, 设置返回数据为所述收条, 执行步骤 1234;
具体地, 发送所述安装命令中的可执行加载文件标识长度、 可执 行加载文件标识、应用标识长度以及应用标识给第二卡片数据管理模 块;
步骤 1234: 生成相应状态码;
具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码;
步骤 1235: 返回设置的返回数据和 /或生成的状态码; 优选地, 参见图 13, 步骤 1301至步骤 1324具体如下:
步骤 1301 : 判断所述 APDU数据是否为合法的可选择命令的命令 头, 是则执行步骤 1302, 否则执行步骤 1323 ;
具体地, 当所述 APDU数据的 CLA为 0x80或 0x84、 P2为 0x00且 Lc 不小于 0x0( †, 所述 APDU数据为合法的可选择命令的命令头;
步骤 1302: 判断卡片 的当前状态是否为 TERMANATED或 CARD_LOCKED, 是则执行步骤 1323, 否则执行步骤 1303 ;
步骤 1303 :收取可选择命令的数据域部分,得到完整可选择命令; 步骤 1304 : 判断当前第一卡片数据管理模块的状态是否为 PERSONALIZED (个人化), 是则执行步骤 1305, 否则执行步骤 1323 ; 步骤 1305 : 判断当前第一卡片数据管理模块是否具有代理权限, 是则执行步骤 1306, 否则执行步骤 1323 ;
步骤 1306: 判断卡片是否满足安全条件, 是则执行步骤 1307, 否 则执行步骤 1323 ;
步骤 1307 :检查卡片的安全级别,若为第一级别则执行步骤 1310, 若为第二级别则执行步骤 1308, 若为第三级别则执行步骤 1309; 具体地, 若卡片的安全级别为第一级别, 则所述可选择命令为消 息数据明文, 若卡片的安全级别为第二级别, 则所述可选择命令为消 息数据明文和消息认证码的组合, 若卡片的安全级别为第三级别, 则 所述可选择命令为消息数据密文和消息认证码的组合;
步骤 1308: 根据所述可选择命令中的消息数据明文和 MAC判断 所述可选择命令是否完整, 是则执行步骤 1310, 否则执行步骤 1323 ; 其中, 所述根据所述可选择命令中的消息数据明文和 MAC判断 所述可选择命令是否完整具体包括: 利用约定的会话密钥对 MAC进 行解密得到解密结果, 同时根据约定的散列函数对消息数据明文进行 计算得到计算结果, 判断所述解密结果和所述计算结果是否相同, 是 则所述可选择命令完整, 否则所述可选择命令不完整
步骤 1309: 根据所述可选择命令中的消息数据密文和 MAC判断 所述可选择命令是否完整, 是则执行步骤 1310, 否则执行步骤 1323 ; 其中, 所述根据所述可选择命令中的消息数据密文和 MAC判断 所述可选择命令是否完整具体包括:对消息数据密文解密得到消息数 据明文, 利用约定的会话密钥对 MAC进行解密得到解密结果, 同时 根据约定的散列函数对消息数据明文进行计算得到计算结果,判断所 述解密结果和所述计算结果是否相同, 是则所述可选择命令完整, 否 则所述可选择命令不完整;
步骤 1310:判断所述可选择命令的数据域中的前两个字节数据是 否均为 0x00, 是则执行步骤 1311, 否则执行步骤 1323 ;
步骤 1311 :判断所述可选择命令中的应用标识长度是否在预设范 围内, 是则执行步骤 1312, 否则执行步骤 1323 ;
具体地, 所述预设范围为 0x05-0x10;
步骤 1312:判断卡片内是否有所述可选择命令中的应用标识对应 的应用, 是则执行步骤 1313, 否则执行步骤 1323 ;
步骤 1313:判断所述可选择命令中的应用标识对应的应用的状态 是否为 INSTALLED (安装), 是则执行步骤 1314, 否则执行步骤 1323 ; 步骤 1314: 判断所述可选择命令中的应用权限长度是否为 0x00, 是则执行步骤 1315, 否则执行步骤 1323 ;
步骤 1315 :判断所述可选择命令中应用权限之后的一个字节数据 是否为 0x00, 是则执行步骤 1316, 否则执行步骤 1323 ; 是则执行步骤 1317, 否则执行步骤 1323 ;
步骤 1317 :发送计算安装令牌所需的数据给第二卡片数据管理模 块, 接收第二卡片数据管理模块返回的计算结果, 判断所述计算结果 与所述可选择命令中的安装令牌是否相同, 是则执行步骤 1318, 否则 执行步骤 1323 ;
具体地, 发送所述可选择命令的 Pl、 P2、 有效数据长度、 可执行 加载文件标识长度、 0x00、 0x00、 应用标识长度、 应用标识、 应用权 限长度、 应用权限以及 0x00给第二卡片数据管理模块;
步骤 1318 :将所述可选择命令中的应用标识对应的应用的状态设 置为 SELECTABLE (可选择);
具体地, 步骤 1318具体为将所述可选择命令中的应用标识对应的 应用的状态属性的值设置为 0x07;
步骤 1319: 判断所述可选择命令中的 P1是否为 0x04, 是则执行步 骤 1320, 否则执行步骤 1322;
步骤 1320: 判断第二卡片数据管理模块是否具有默认选择权限, 是则执行步骤 1321, 否则执行步骤 1323 ;
步骤 1321:设置所述可选择命令中的应用标识对应的应用为默认 应用, 执行步骤 1322;
步骤 1322: 设置返回数据为 0x00, 执行步骤 1323 ;
步骤 1323 : 生成相应状态码;
具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码; 步骤 1324: 返回设置的返回数据和 /或生成的状态码; 优选地, 参见图 14, 步骤 1401至步骤 1428具体如下:
步骤 1401: 判断所述 APDU数据是否为合法的引渡命令的命令 头, 是则执行步骤 1402, 否则执行步骤 1427 ;
具体地, 当所述 APDU数据的 CLA为 0x80或 0x84、 P2为 0x00且 Lc 不小于 0x10时, 所述 APDU数据为合法的引渡命令的命令头;
步骤 1402: 判断卡片 的当前状态是否为 TERMANATED或 CARD_LOCKED, 是则执行步骤 1427, 否则执行步骤 1403 ;
步骤 1403 : 收取引渡命令的数据域部分, 得到完整引渡命令; 步骤 1404 : 判断当前第一卡片数据管理模块的状态是否为 PERSONALIZED, 是则执行步骤 1405, 否则执行步骤 1427 ;
步骤 1405: 判断当前第一卡片数据管理模块是否具有代理权限, 是则执行步骤 1406, 否则执行步骤 1427;
步骤 1406: 判断卡片是否满足安全条件, 是则执行步骤 1407, 否 则执行步骤 1427 ;
步骤 1407 :检查卡片的安全级别,若为第一级别则执行步骤 1410, 若为第二级别则执行步骤 1408, 若为第三级别则执行步骤 1409;
具体地, 若卡片的安全级别为第一级别, 则所述引渡命令为消息 数据明文, 若卡片的安全级别为第二级别, 则所述引渡命令为消息数 据明文和消息认证码的组合, 若卡片的安全级别为第三级别, 则所述 引渡命令为消息数据密文和消息认证码的组合;
步骤 1408: 根据所述引渡命令中的消息数据明文和 MAC判断所 述引渡命令是否完整, 是则执行步骤 1410, 否则执行步骤 1427 ;
其中, 所述根据所述引渡命令中的消息数据明文和 MAC判断所 述引渡命令是否完整具体包括: 利用约定的会话密钥对 MAC进行解 密得到解密结果, 同时根据约定的散列函数对消息数据明文进行计算 得到计算结果, 判断所述解密结果和所述计算结果是否相同, 是则所 述引渡命令完整, 否则所述引渡命令不完整;
步骤 1409: 根据所述引渡命令中的消息数据密文和 MAC判断所 述引渡命令是否完整, 是则执行步骤 1410, 否则执行步骤 1427 ;
其中, 所述根据所述引渡命令中的消息数据密文和 MAC判断所 述引渡命令是否完整具体包括:对消息数据密文解密得到消息数据明 文, 利用约定的会话密钥对 MAC进行解密得到解密结果, 同时根据 约定的散列函数对消息数据明文进行计算得到计算结果,判断所述解 密结果和所述计算结果是否相同, 是则所述引渡命令完整, 否则所述 引渡命令不完整; 围内, 是则执行步骤 1411, 否则执行步骤 1427 ;
具体地, 所述预设范围为 0x05-0x10; 应的应用, 是则执行步骤 1412, 否则执行步骤 1427 ;
步骤 1412:判断所述引渡命令中的安全域标识对应的应用是否为 当前卡片提供商模块, 是则执行步骤 1427, 否则执行步骤 1413 ;
步骤 1413 :判断所述引渡命令中安全域标识之后的一个字节数据 是否为 0x00, 是则执行步骤 1414, 否则执行步骤 1427 ;
步骤 1414:判断所述引渡命令中的安全域标识对应的应用的状态 是否为 INSTALLED (安装), 是则执行步骤 1415, 否则执行步骤 1427 ; 步骤 1415 :判断所述引渡命令中的应用标识长度是否在预设范围 内, 是则执行步骤 1416, 否则执行步骤 1427 ;
具体地, 所述预设范围为 0x05-0x10;
步骤 1416:判断卡片内是否存在所述引渡命令中的应用标识对应 的应用, 是则执行步骤 1417, 否则执行步骤 1427 ;
步骤 1417 :判断所述引渡命令中的应用标识对应的应用关联的安 全域是否为当前第一卡片数据管理模块, 是则执行步骤 1418, 否则执 行步骤 1427 ; 步骤 1418:判断所述引渡命令中的安全域标识对应的应用是否具 有安全域权限, 是则执行步骤 1419, 否则执行步骤 1427 ;
步骤 1419:判断所述引渡命令中的安全域标识对应的应用的状态 是否为 LOCKED (锁定), 是则执行步骤 1427, 否则执行步骤 1420; 步骤 1420:判断所述引渡命令中的安全域标识对应的应用的状态 是否为 PERSONALIZED (个人化), 是则执行步骤 1421 , 否则执行 步骤 1427 ;
步骤 1421:判断所述引渡命令中的应用标识后的两个字节数据是 否均为 0x00, 是则执行步骤 1422, 否则执行步骤 1427 ;
步骤 1422: 判断所述引渡命令中的引渡令牌长度是否为 0x80, 是 则执行步骤 1423, 否则执行步骤 1427;
步骤 1423:发送计算引渡令牌所需的数据给第二卡片数据管理模 块, 接收第二卡片数据管理模块返回的计算结果, 判断所述计算结果 是否与所述引渡命令中的引渡令牌相同, 是则执行步骤 1424, 否则执 行步骤 1427 ;
具体地, 发送所述引渡命令的 Pl、 P2、 有效数据长度、 安全域标 识长度、安全域标识、 0x00、应用标识长度、应用标识、 0x00以及 0x00 给第二卡片数据管理模块;
步骤 1424:判断所述引渡命令中的应用标识对应的应用是否具有 安全域权限, 是则执行步骤 1427, 否则执行步骤 1425 ;
步骤 1425:将所述 !渡命令中的应用标识对应的应用关联的安全 域修改为所述引渡命令中的安全域标识对应的应用;
步骤 1426: 发送计算收条所需的数据给第二卡片数据管理模块, 接收第二卡片数据管理模块返回的收条, 设置返回数据为所述收条, 执行步骤 1427 ;
具体地, 发送本次引渡应用的: 应用标识的长度、 应用标识、 原 安全域标识的长度、 原安全域标识、 新安全域标识的长度以及新安全 域标识给第二卡片数据管理模块, 其中, 所述原安全域标识为本次引 渡应用在引渡之前关联的安全域的安全域标识;所述新安全域标识为 本次引渡应用在引渡之后将要关联的安全域的安全域标识;
步骤 1427 : 生成相应状态码;
具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码;
步骤 1428: 返回设置的返回数据和 /或生成的状态码; 优选地, 参见图 15, 步骤 1501至步骤 1517具体如下:
步骤 1501 : 判断所述 APDU数据是否为合法的个人化命令的命令 头, 是则执行步骤 1502, 否则执行步骤 1516;
具体地, 当所述 APDU数据的 CLA为 0x80或 0x84、 P2为 0x00且 Lc 不小于 OxOB时, 所述 APDU数据为合法的个人化命令的命令头;
步骤 1502: 判断卡片 的当前状态是否为 TERMANATED或 CARD_LOCKED, 是则执行步骤 1516, 否则执行步骤 1503 ;
步骤 1503 :收取个人化命令的数据域部分,得到完整个人化命令; 步骤 1504 : 判断当前第一卡片数据管理模块的状态是否为 PERSONALIZED (个人化), 是则执行步骤 1505, 否则执行步骤 1516; 步骤 1505 : 判断卡片是否满足安全条件, 是则执行步骤 1506, 否 则执行步骤 1516;
步骤 1506: 检查卡片的安全级别, 若为第一级别则执行步 1509, 若为第二级别则执行步骤 1507, 若为第三级别则执行步骤 1508;
具体地, 若卡片的安全级别为第一级别, 则所述个人化命令为消 息数据明文, 若卡片的安全级别为第二级别, 则所述个人化命令为消 息数据明文和消息认证码的组合, 若卡片的安全级别为第三级别, 则 所述个人化命令为消息数据密文和消息认证码的组合;
步骤 1507: 根据所述个人化命令中的消息数据明文和 MAC判断 所述个人化命令是否完整, 是则执行步骤 1509, 否则执行步骤 1516; 其中, 所述根据所述个人化命令中的消息数据明文和 MAC判断 所述个人化命令是否完整具体包括: 利用约定的会话密钥对 MAC进 行解密得到解密结果, 同时根据约定的散列函数对消息数据明文进行 计算得到计算结果, 判断所述解密结果和所述计算结果是否相同, 是 则所述个人化命令完整, 否则所述个人化命令不完整;
步骤 1508: 根据所述个人化命令中的消息数据密文和 MAC判断 所述个人化命令是否完整, 是则执行步骤 1509, 否则执行步骤 1516; 其中, 所述根据所述个人化命令中的消息数据密文和 MAC判断 所述个人化命令是否完整具体包括:对消息数据密文解密得到消息数 据明文, 利用约定的会话密钥对 MAC进行解密得到解密结果, 同时 根据约定的散列函数对消息数据明文进行计算得到计算结果,判断所 述解密结果和所述计算结果是否相同, 是则所述个人化命令完整, 否 则所述个人化命令不完整;。
步骤 1509:判断所述个人化命令的数据域的前两个字节数据是否 均为 0x00, 是则执行步骤 1510, 否则执行步骤 1516;
步骤 1510:判断所述个人化命令中的应用标识长度是否在预设范 围内, 是则执行步骤 1511, 否则执行步骤 1516;
具体地, 所述预设范围为 0x05-0x10;
步骤 1511 :判断卡片内是否存在所述个人化命令中的应用标识对 应的应用, 是则执行步骤 1512, 否则执行步骤 1516;
步骤 1512:判断所述个人化命令中的应用标识对应的应用关联的 安全域是否为当前第一卡片数据管理模块, 是则执行步骤 1513, 否则 执行步骤 1516;
步骤 1513 : 判断所述个人化命令的最后三个字节数据是否均为 0x00, 是则执行步骤 1514, 否则执行步骤 1516;
步骤 1514:将所述个人化命令中的应用标识对应的应用的状态设 置为个人化 (PERSONLIZED) ;
步骤 1515 : 设置返回数据为 0x00;
步骤 1516: 生成相应状态码; 具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码;
步骤 1517: 返回设置的返回数据和 /或生成的状态码; 优选地, 参见图 16, 步骤 1601至步骤 1625具体如下:
步骤 1601: 判断所述 APDU数据是否为合法的删除命令的命令 头, 是则执行步骤 1602, 否则执行步骤 1624;
具体地, 当所述 APDU数据的 CLA为 0x80或 0x84且 P1为 0x00时, 所述 APD U数据为合法的删除命令的命令头;
步骤 1602: 判断卡片 的当前状态是否为 TERMANATED或 CARD_LOCKED, 是则执行步骤 1624, 否则执行步骤 1603 ;
步骤 1603 : 收取删除命令的数据域部分, 得到完整删除命令; 步骤 1604 : 判断当前第一卡片数据管理模块的状态是否为 PERSONALIED, 是则执行步骤 1605, 否则执行步骤 1624;
步骤 1605: 判断当前第一卡片数据管理模块是否具有代理权限, 是则执行步骤 1606, 否则执行步骤 1624;
步骤 1606: 判断卡片是否满足安全条件, 是则执行步骤 1607, 否 则执行步骤 1624;
步骤 1607 :检查卡片的安全级别,若为第一级别则执行步骤 1610, 若为第二级别则执行步骤 1608, 若为第三级别则执行步骤 1609;
具体地, 若卡片的安全级别为第一级别, 则所述删除命令为消息 数据明文, 若卡片的安全级别为第二级别, 则所述删除命令为消息数 据明文和消息认证码的组合, 若卡片的安全级别为第三级别, 则所述 删除命令为消息数据密文和消息认证码的组合;
步骤 1608: 根据所述删除命令中的消息数据明文和 MAC判断所 述删除命令是否完整, 是则执行步骤 1610, 否则执行步骤 1624;
其中, 所述根据所述删除命令中的消息数据明文和 MAC判断所 述删除命令是否完整具体包括: 利用约定的会话密钥对 MAC进行解 密得到解密结果, 同时根据约定的散列函数对消息数据明文进行计算 得到计算结果, 判断所述解密结果和所述计算结果是否相同, 是则所 述删除命令完整, 否则所述删除命令不完整;
步骤 1609: 根据所述删除命令中的消息数据密文和 MAC判断所 述删除命令是否完整, 是则执行步骤 1610, 否则执行步骤 1624; 其中, 所述根据所述删除命令中的消息数据密文和 MAC判断所 述删除命令是否完整具体包括:对消息数据密文解密得到消息数据明 文, 利用约定的会话密钥对 MAC进行解密得到解密结果, 同时根据 约定的散列函数对消息数据明文进行计算得到计算结果,判断所述解 密结果和所述计算结果是否相同, 是则所述删除命令完整, 否则所述 删除命令不完整;
步骤 1610:判断所述删除命令的数据域中的第一个字节数据是否 为 0x4f, 是则执行步骤 1611, 否则执行步骤 1624;
步骤 1611 :判断所述删除命令中的数据域标识长度是否在预设范 围内, 是则执行步骤 1612, 否则执行步骤 1624;
具体地, 预设范围为 0x05-0x10;
步骤 1612:判断卡片内是否存在所述删除命令中的数据域标识对 应的应用, 是则执行步骤 1613, 否则执行步骤 1614;
步骤 1613 : 判断所述删除命令中的 P2是否为 0x80, 是则执行步骤 1614, 否则执行步骤 1619;
步骤 1614:判断卡片内是否存在所述删除命令中的数据域标识对 应的可执行文件, 是则执行步骤 1615, 否则执行步骤 1624;
步骤 1615:判断所述删除命令中的数据域标识对应的可执行文件 关联的安全域是否为当前第一卡片数据管理模块, 是则执行步骤 1616, 否则执行步骤 1624;
步骤 1616: 判断所述删除命令中的 P2是否为 0x80, 是则执行步骤 1617, 否则执行步骤 1618 ;
步骤 1617:删除所述删除命令中的数据域标识对应的可执行文件 以及所述可执行文件对应的全部应用, 执行步骤 1623; 步骤 1618 : 删除所述删除命令中的数据域标识对应的可执行文 件, 执行步骤 1623 ;
步骤 1619:判断所述删除命令中的数据域标识对应的应用是否为 其他应用或其他可执行文件关联的安全域, 是则执行步骤 1624, 否则 执行步骤 1620;
步骤 1620:判断所述删除命令中的数据域标识对应的应用是否为 当前第一卡片数据管理模块,是则执行步骤 1624,否则执行步骤 1621 ; 步骤 1621:判断所述删除命令中的数据域标识对应的应用关联的 安全域是否为当前第一卡片数据管理模块, 是则执行步骤 1622, 否则 执行步骤 1624;
步骤 1622: 删除与所述删除命令中的数据域标识对应的应用; 步骤 1623 : 发送计算收条所需的数据给第二卡片数据管理模块, 接收第二卡片数据管理模块返回的收条, 设置返回数据为所述收条, 执行步骤 1624;
具体地,发送所述删除命令中的数据域标识长度以及所述数据域 标识给第二卡片数据管理模块;
步骤 1624: 生成相应状态码;
具体地,所述相应状态码包括标识成功的状态码和标识错误的状 态码, 其中不同的错误类型对应不同的状态码;
步骤 1625: 返回设置的返回数据和 /或生成的状态码。
以上所述的实施例只是本发明较优选的具体实施方式, 本领域的 技术人员在本发明技术方案范围内进行的通常变化和替换都应包含 在本发明的保护范围内。

Claims

权 利 要 求
1、 一种管理卡片上应用的方法, 其特征在于, 当卡片内容管理 模块接收到运行环境发送的数据后执行以下步骤:
步骤 A : 检查卡片状态, 若为第一预设状态或第二预设状态则生 步骤 B : 检查接收到的数据是否符合预设格式, 若符合第一预设 格式则执行步骤 C, 若符合第二预设格式则执行步骤 D, 若符合第三 预设格式则执行步骤 E, 若符合第四预设格式则执行步骤 F, 若符合第 五预设格式则执行步骤 G, 若符合第六预设格式则执行步骤 H, 若符 合第七预设格式则执行步骤 I, 若不符合预设格式则生成并返回数据 错误状态码给运行环境, 结束;
步骤 C: 继续接收运行环境发送的数据得到完整的第一命令, 解 析所述第一命令, 得到加载文件标识和加载文件关联安全域标识, 创 建加载文件结构,并将解析得到的加载文件标识和加载文件关联域标 识填充到创建的加载文件结构中,如果搡作成功则生成并返回搡作成 功状态码并返回结果给运行环境, 结束, 如果搡作未成功则根据搡作 失败原因生成并返回相应状态码给运行环境, 结束;
步骤 D: 继续接收运行环境发送的数据得到完整的第二命令, 解 析所述第二命令, 得到加载文件数据块, 根据所述加载文件数据块获 取组件数据并进行存储, 将存储地址填充到加载文件结构中, 如果搡 作成功则生成并返回搡作成功状态码和返回结果给运行环境, 结束, 如果搡作未成功则根据搡作失败原因生成并返回相应状态码给运行 环境, 结束;
步骤 E: 继续接收运行环境发送的数据得到完整的第三命令, 解 析所述第三命令, 得到可执行加载文件标识、 可执行模块标识、 应用 标识和应用权限,根据解析得到的可执行加载文件标识查找加载文件 结构,在查找到的加载文件结构中的存储地址对应的存储空间中查找 与解析得到的可执行模块标识相对应的可执行模块,创建查找到的可 执行模块的应用, 用解析得到的应用标识标识创建的应用, 并赋予创 建的应用以解析得到的应用权限所指定的权限,并设置创建的应用的 关联安全域为与解析得到的可执行加载文件标识相对应的可执行加 载文件的关联安全域,如果搡作成功则生成并返回搡作成功状态码和 返回结果给运行环境, 结束, 如果搡作未成功则根据搡作失败原因生 成并返回相应状态码给运行环境, 结束;
步骤 F: 继续接收运行环境发送的数据得到完整的第四命令, 解 析所述第四命令, 得到应用标识和应用权限, 在卡片中查找与解析得 到的应用标识相对应的应用, 更新查找到的应用的状态为可选择状 态,以及更新查找到的应用的权限为解析得到的应用权限所指定的权 限,如果搡作成功则生成并返回搡作成功状态码和返回结果给运行环 境, 结束, 如果搡作未成功则根据搡作失败原因生成并返回相应状态 码给运行环境, 结束;
步骤 G: 继续接收运行环境发送的数据得到完整的第五命令, 解 析所述第五命令, 得到安全域标识和应用标识, 在卡片内查找与解析 得到的应用标识相对应的应用和与解析得到的安全域标识相对应的 应用,将查找到的应用的关联安全域更新为与解析得到的安全域标识 相对应的应用,如果搡作成功则生成并返回搡作成功状态码和返回结 果给运行环境, 结束, 如果搡作未成功则根据搡作失败原因生成并返 回相应状态码给运行环境, 结束;
步骤 H: 继续接收运行环境发送的数据得到完整的第六命令, 解 析所述第六命令, 得到应用标识, 在卡片内查找与解析得到的应用标 识相对应的应用, 设置查找到的应用为个人化应用, 如果搡作成功则 生成并返回搡作成功状态码和返回结果给运行环境, 结束, 如果搡作 未成功则根据搡作失败原因生成并返回相应状态码给运行环境, 结 束;
步骤 I: 继续接收运行环境发送的数据得到完整的第七命令, 解 析所述第七命令, 得到数据域标识, 在卡片内查找与解析得到的数据 域标识相对应的应用和可执行加载文件,删除查找到的应用和可执行 加载文件,如果搡作成功则生成并返回搡作成功状态码和返回结果给 运行环境, 结束, 如果搡作未成功则根据搡作失败原因生成并返回相 应状态码给运行环境, 结束。
2、如权利要求 1所述的方法, 其特征在于, 所述步骤 B具体包括: 步骤 B1 :检查接收到的数据的长度是否为五个字节,是则执行步 骤 B2,否则接收到的数据不符合预设格式, 生成并返回数据错误状态 码给运行环境, 结束;
步骤 B2:检查接收到的数据的第一个字节是否为 0x80或 0x84,是 则执行步骤 B3, 否则接收到的数据不符合预设格式,生成并返回数据 错误状态码给运行环境, 结束;
步骤 B3 : 检查接收到的数据的第二个字节, 若为 0xE6则执行步 骤 B4, 若为 0xE8则执行步骤 B5, 若为 0xE4则执行步骤 B6, 否则接收 到的数据不符合预设格式, 生成并返回数据错误状态码给运行环境, 结束;
步骤 B4:检查接收到的数据的第三至第五个字节,若第三个字节 和第个四字节分别为 0x02和 0x00且第五个字节不小于 OxOA则接收到 的数据符合第一预设格式,执行步骤 C;若第三个字节为 0x04或 0x0C、 第四个字节为 0x00且第五个字节不小于 0x18则接收到的数据符合第 三预设格式, 执行步骤 E; 若第三个字节和第四个字节分别为 0x08和 0x00且第五个字节不小于 OxOC则接收到的数据符合第四预设格式,执 行步骤 F; 若第个三字节和第个四字节分别为 0x10和 0x00且第五个字 节不小于 0x10则接收到的数据符合第五预设格式, 执行步骤 G; 若第 三个字节和第四个字节分别为 0x20和 0x00且第五字节不小于 OxOB则 接收到的数据符合第六预设格式, 执行步骤 H; 否则接收到的数据不 符合预设格式, 生成并返回数据错误状态码给运行环境, 结束;
步骤 B5 :检查接收到的数据的第三个字节是否为 0x00或 0x80,是 则接收到的数据符合第二预设格式, 执行步骤 D, 否则接收到的数据 不符合预设格式, 生成并返回数据错误状态码给运行环境, 结束; 步骤 B6:检查接收到的数据的第三个字节是否为 0x00, 是则接收 到的数据符合第七预设格式, 执行步骤 I, 否则接收到的数据不符合 预设格式, 生成并返回数据错误状态码给运行环境, 结束。
3、 如权利要求 1所述的方法, 其特征在于, 所述根据所述第一命 令准备加载应用具体包括:
步骤 C1 :判断所述第一命令的第一个数据块是否合法, 若合法则 检查卡片内是否有与所述第一个数据块相对应的可执行文件,是则搡 作条件不满足, 搡作失败, 否则执行步骤 C2; 若不合法则数据错误, 搡作失败;
步骤 C2: 判断所述第一命令的第二个数据块是否满足预设要求, 若满足第一预设要求则设置与所述第一个数据块对应的加载文件的 关联安全域为所述卡片内容管理模块, 执行步骤 C4; 若满足第二预设 要求则执行步骤 C3 ; 若不满足预设要求则数据错误, 搡作失败; 步骤 C3 : 检查卡片内是否有与所述第二个数据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则检查与所述第二个数据 块相对应的应用是否具有安全域权限,若具有安全域权限则设置与所 述第一个数据块对应的加载文件的关联安全域为与所述第二个数据 块相对应的应用, 执行步骤 C4; 若不具有安全域权限则搡作条件不满 足, 搡作失败;
步骤 C4:判断所述第一命令的第三个数据块是否合法, 是则存储 所述第三个数据块中的相应数据, 执行步骤 C5 ; 否则数据错误, 搡作 失败;
步骤 C5 : 处理所述第一命令的第四个数据块, 执行步骤 C6; 步骤 C6:判断所述第一命令的第五个数据块是否合法, 是则创建 加载文件结构,并根据所述第一个数据块和所述第二个数据块对加载 文件结构进行填充, 初始化卡片内的全局块编号, 搡作成功; 否则数 据错误, 搡作失败。
4、 如权利要求 3所述的方法, 其特征在于, 所述第一命令的第一 个数据块包括: 加载文件标识长度和加载文件标识; 判断所述第一命 令的第一个数据块是否合法具体为:判断所述加载文件标识长度是否 在预设范围内, 且所述加载文件标识的每个字节不都是 0x00, 若同时 满足上述两个条件则所述第一命令的第一个数据块合法,否则所述第 一命令的第一个数据块不合法;与所述第一个数据块相对应的可执行 文件具体为: 与所述加载文件标识对应的可执行文件; 与所述第一个 数据块相对应的加载文件具体为:与所述加载文件标识对应的加载文 件;
所述第一命令的第二个数据块包括:加载文件关联安全域标识长 度和加载文件关联安全域标识;所述判断所述第一命令的第二个数据 块是否满足预设要求具体为:判断所述加载文件关联安全域标识长度 是否为 0x00, 是则所述第一命令的第二个数据块满足第一预设要求, 否则检查所述加载文件关联安全域标识,若所述加载文件关联安全域 标识的每个字节都是 0x00则所述第一命令的第二个数据块不满足预 设要求,若所述加载文件关联安全域标识的每个字节不都是 0x00则所 述第一命令的第二个数据块满足第二预设要求;所述与所述第二个数 据块相对应的应用具体为:与所述加载文件关联安全域标识对应的应 用;
所述第一命令的第三个数据块包括:加载文件数据块哈希值长度 和加载文件数据块哈希值;所述判断所述第一命令的第三个数据块是 否合法具体为: 判断所述加载文件数据块哈希值长度是否为 0x00, 是 则所述第一命令的第三个数据块不合法,否则所述第一命令的第三个 数据块合法; 所述存储所述第三个数据块中的相应数据具体为: 存储 所述加载文件数据块哈希值;
所述第一命令的第四个数据块包括: 加载参数域; 所述处理所述 第一命令的第四个数据块具体为: 处理所述加载参数域;
所述第一命令的第五个数据块包括: 加载令牌长度和加载令牌; 所述判断所述第一命令的第五个数据块是否合法具体为:判断所述加 载令牌长度是否为 0x00, 是则所述第一命令的第五个数据块合法, 否 则所述第一命令的第五个数据块不合法;
所述预设范围为 0x05-0x10。
5、 如权利要求 1所述的方法, 其特征在于, 所述根据所述第二命 令加载应用具体包括:
步骤 D1 : 判断所述第二命令的第四个字节是否等于卡片内的全 局块编号, 是则执行步骤 D2, 否则数据错误, 搡作失败;
步骤 D2: 检查所所述第二命令中是否包含数据验证模式块信息, 若包含则验证所述数据验证模式快信息, 若验证通过则执行步骤 D3, 若验证未通过则数据错误, 搡作失败; 若不包含则执行步骤 D3 ; 步骤 D3 : 根据所述第二命令中的加载文件数据块获取组件数据 并进行存储, 将存储地址填充到加载文件结构中, 更新卡片内的全局 块编号为其当前值加 1, 判断所述加载文件数据块是否为加载文件的 最后一个加载文件数据块, 是则执行步骤 D4, 否则搡作成功;
步骤 D4: 判断卡片内的加载文件数据块哈希值是否有值, 若有 值则对由卡片内存储的全部加载文件数据块构成的整体进行哈希计 算, 并判断计算结果是否等于所述加载文件数据块哈希值, 若等于则 执行步骤 D5, 若不等于则数据错误, 搡作失败; 若没有值则执行步 骤 D5;
步骤 D5 : 存储并提交可执行加载文件结构, 搡作成功。
6、 如权利要求 1所述的方法, 其特征在于, 所述根据所述第三命 令安装应用具体包括:
步骤 E1 : 判断所述第三命令的第一个数据块是否合法, 若合法则 检查卡片内是否有与所述第一个数据块相对应的加载文件结构,是则 执行步骤 E2,否则搡作条件不满足,搡作失败;若不合法则数据错误, 搡作失败;
步骤 E2: 判断所述第三命令的第二个数据块是否合法, 若合法则 检查所述加载文件结构中的存储地址对应的存储空间中是否有与所 述第二个数据块相对应的可执行模块, 是则执行步骤 E3, 否则搡作条 件不满足, 搡作失败; 若不合法则数据错误, 搡作失败;
步骤 E3 : 判断所述第三命令的第三个数据块是否合法, 若合法则 检查卡片内是否有与所述第三个数据块相对应的应用,是则执行步骤 E4, 否则搡作条件不满足, 搡作失败; 若不合法则数据错误, 搡作失 败;
步骤 E4: 判断所述第三命令的第四个数据块是否合法, 若合法则 判断与所述第三个数据块相对应的应用是否具有默认选择权限,是则 执行步骤 E5, 否则执行步骤 E6; 若不合法则数据错误, 搡作失败; 步骤 E5 : 判断所述第三命令的第三个字节是否等于预设值, 若为 预设值则数据错误, 搡作失败; 若不为预设值则判断所述卡片内容管 理模块是否具有默认选择权限, 是则执行步骤 E7, 否则搡作条件不满 足, 搡作失败;
步骤 E6: 判断所述第三命令的第三个数据块是否满足预设条件, 若满足第一预设条件或第二预设条件则处理所述第三命令的第五个 数据块, 执行步骤 E7, 若不满足预设条件则搡作条件不满足, 搡作失 败;
步骤 E7 : 判断所述第三命令的第六个数据块是否合法, 是则根据 所述第三命令注册应用, 执行步骤 E8, 否则数据错误, 搡作失败; 步骤 E8: 判断所述第三命令的第三个字节是否等于所述预设值, 是则设置与所述第三命令的第三个数据块相对应的应用的状态为安 装, 搡作成功; 否则设置与所述第三命令的第三个数据块相对应的应 用的状态为可选择, 执行步骤 E9;
步骤 E9:判断与所述第三命令的第三个数据块相对应的应用是否 具有默认选择权限,是则设置与所述第三命令的第三个数据块相对应 的应用为默认应用, 搡作成功, 否则搡作成功。
7、 如权利要求 1所述的方法, 其特征在于, 所述根据第四命令设 置应用状态具体包括:
步骤 F1 :判断所述第四命令的第一个数据块和第二个数据块是否 均合法, 是则执行步骤 F2, 否则数据错误, 搡作失败;
步骤 F2: 判断所述第四命令的第三个数据块是否合法, 若不合法 则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第三个数 据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则判 断与所述第三个数据块相对应的应用的状态是否为安装,若不为安装 则搡作条件不满足, 搡作失败; 若为安装则执行步骤 F3 ;
步骤 F3 : 判断所述第四命令的第四个数据块是否合法, 是则执行 步骤 F4, 否则数据错误, 搡作失败;
步骤 F4: 判断所述第四命令的第五个数据块是否合法, 是则执行 步骤 F5, 否则数据错误, 搡作失败;
步骤 F5 : 判断所述第四命令的第六个数据块是否合法, 是则设置 与所述第三个数据块相对应的应用的状态为可选择, 执行步骤 F6, 否 则数据错误搡作失败;
步骤 F6:判断与所述第三个数据块相对应的应用是否具有默认选 择权限, 若没有则搡作成功; 若有则判断所述卡片内容管理模块是否 具有默认选择权限,是则设置与所述第三个数据块相对应的应用为默 认应用, 搡作成功, 否则搡作条件不满足, 搡作失败。
8、 如权利要求 1所述的方法, 其特征在于, 所述根据所述第六命 令个人化应用具体包括:
步骤 HI : 判断所述第六命令的第一个数据块和第二个数据块是 否均合法, 是则执行步骤 H2, 否则数据错误, 搡作失败;
步骤 H2: 判断所述第六命令的第三个数据块是否合法, 若不合 法则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第三个 数据块相对应的应用, 若没有则搡作条件不满足, 搡作失败; 若有则 判断与所述第三个数据块相对应的应用的关联安全域是否为所述卡 片内容管理模块, 是则执行步骤 H3, 否则搡作条件不满足, 搡作失 败;
步骤 H3 : 判断所述第六命令的第四个数据块、 第五个数据块和 第六个数据块是否均合法,是则设置与所述第三个数据块相对应的应 用为个人化应用, 否则搡作条件不满足, 搡作失败。
9、 如权利要求 1所述的方法, 其特征在于, 所述根据所述第七命 令删除应用及可执行加载文件具体包括:
步骤 II: 判断所述第七命令的第一个数据块是否合法, 是则执行 步骤 12, 否则数据错误, 搡作失败;
步骤 12: 判断所述第七命令的第二个数据块是否合法, 若不合法 则数据错误, 搡作失败; 若合法则检查卡片内是否有与所述第二个数 据块相对应的应用, 是则执行步骤 13, 否则执行步骤 14;
步骤 13 : 判断所述第七命令的第四个字节是否等于预设值, 是则 执行步骤 14, 否则执行步骤 15 ;
步骤 14: 检查卡片内是否有与所述第二个数据块相对应的可执行 加载文件, 若没有则搡作条件不满足, 搡作失败; 若有则判断所述第 七命令的第四个字节是否等于预设值,若等于则删除与所述第二个数 据块相对应的应用和可执行加载文件, 搡作成功, 若不等于则删除与 所述第二个数据块相对应的可执行加载文件, 搡作成功;
步骤 15 : 检查与所述第二个数据块相对应的应用是否为其他应用 或其他可执行加载文件的关联安全域, 是则搡作条件不满足, 搡作失 败; 否则执行步骤 16;
步骤 16: 判断与所述第二个数据块相对应的应用是否为所述卡片 内容管理模块, 是则搡作条件不满足, 搡作失败, 否则删除与所述第 二个数据块相对应的应用, 搡作成功。
10、 一种管理卡片数据的实现方法, 其特征在于, 当第一卡片数 据管理模块接收到运行环境发送的应用协议数据单元 APDU数据后, 将自身作为当前第一卡片数据管理模块, 执行以下步骤:
步骤 A、 检查所述 APDU数据的指令码, 若所述指令码为有效数 值 0xE8则执行步骤 D, 若所述指令码为有效数值 0xE6则执行步骤 B, 若所述指令码为有效数值 0xE4则执行步骤 I;
步骤 B、检查所述 APDU数据的第一参数,若所述第一参数为 0x02 则执行步骤 C, 若所述第一参数为 0x04或 OxOC则执行步骤 E, 若所述 第一参数为 0x08则执行步骤 F, 若所述第一参数为 0x10则执行步骤 G, 若所述第一参数为 0x20则执行步骤 H;
步骤 C、 收取预加载命令的数据域部分, 得到预加载命令的全部 内容, 根据所述预加载命令的内容检查卡片是否满足预加载条件, 是 则新建可执行加载文件结构并设置相应数据, 执行步骤 J, 否则直接 执行步骤 J;
步骤 D、收取加载命令的数据域部分,得到加载命令的全部内容, 根据所述加载命令的内容检查卡片是否满足加载条件,是则存储所述 加载命令的相应内容, 执行步骤 J, 否则直接执行步骤 J;
步骤 E、 收取安装命令的数据域部分, 得到安装命令的全部内容, 根据所述安装命令的内容检查卡片是否满足安装条件,是则创建应用 并设置相应状态, 执行步骤 J, 否则直接执行步骤 J;
步骤 F、 收取可选择命令的数据域部分, 得到可选择命令的全部 内容, 根据所述可选择命令的内容检查卡片是否满足可选择条件, 是 则设置相应应用的状态为可选择, 执行步骤 J, 否则直接执行步骤 J; 步骤 G、收取引渡命令的数据域部分,得到引渡命令的全部内容, 根据所述引渡命令的内容检查卡片是否满足引渡条件,是则重置相应 应用关联的安全域, 执行步骤 J, 否则直接执行步骤 J;
步骤 H、 收取个人化命令的数据域部分, 得到个人化命令的全部 内容, 根据所述个人化命令的内容检查卡片是否满足个人化条件, 是 则将相应数据发送给相应应用, 执行步骤 J, 否则直接执行步骤 J; 步骤 I、 收取删除命令的数据域部分, 得到删除命令的全部内容, 根据所述删除命令的内容检查卡片是否满足删除条件,是则删除所述 删除命令中指定的卡片内的相应数据, 执行步骤 J, 否则直接执行步 骤 J;
步骤 J、 生成并返回相应返回数据和 /或相应状态码给所述运行环 境。
11、 根据权利要求 10所述方法, 其特征在于, 步骤 C、 步骤 D、 步骤 E、 步骤 F、 步骤 G、 步骤 H以及步骤 I之前还包括:判断所述 APDU 数据是否为合法的命令头, 是则检查卡片的当前状态, 若卡片的当前 状态为终止或锁定则执行步骤 J, 若卡片的当前状态既不是终止也不 是锁定则顺序执行下一步; 否则执行步骤 J; 或者
检查卡片的当前状态,若卡片的当前状态为终止或锁定则执行步 是否为合法的命令头, 是则顺序执行下一步, 否则执行步骤 J。
12、 根据权利要求 11所述的方法, 其特征在于, 所述步骤 C具体 包括:
步骤 cl、 收取预加载命令的数据域部分, 得到预加载命令的全部 内容, 检查当前第一卡片数据管理模块的状态, 若当前第一卡片数据 管理模块的状态为个人化则判断当前第一卡片数据管理模块是否具 有代理权限, 是则执行步骤 c2, 否则执行步骤 c4; 若当前第一卡片数 据管理模块的状态不为个人化则执行步骤 c4;
步骤 c2、判断卡片是否满足安全条件,是则检查卡片的安全级别, 若为第一级别则执行步骤 c3, 若为第二级别或第三级别则判断所述预 加载命令是否完整, 当所述预加载命令完整时执行步骤 C3, 当所述预 加载命令不完整时执行步骤 C4, 否则执行步骤 c4;
步骤 c3、 对所述预加载命令进行格式检查, 若检查通过则设置所 述预加载命令中的加载文件标识对应的加载文件的关联安全域为所 述预加载命令中的安全域标识对应的应用,存储所述预加载命令中的 加载文件数据块哈希值并设置哈希值验证标识,处理所述预加载命令 中的加载参数域, 新建加载文件结构, 初始化全局块编号, 设置返回 数据为 0x00, 执行步骤 c4, 若检查未通过则执行步骤 c4; 步骤 c4、 生成相应状态码, 返回设置的返回数据和 /或生成的状 态码。
13、 根据权利要求 12所述的方法, 其特征在于, 所述步骤 c3具体 包括:
步骤 c3- l、 判断所述预加载命令中的加载文件标识长度是否在预 设范围内, 是则检查所述预加载命令中的加载文件标识是否合法, 若 合法则执行步骤 c3-2, 若不合法则执行步骤 c4 ; 否则执行步骤 c4 ; 步骤 c3-2、 检查卡片内是否已存在所述预加载命令中的加载文件 标识对应的加载文件, 是则执行步骤 c4 ; 否则判断所述预加载命令中 的安全域标识长度是否在预设范围内, 若在预设范围内则执行步骤 c3-3 , 若不在预设范围内则执行步骤 c4 ;
步骤 c3-3、 判断所述预加载命令中的安全域标识是否合法, 是则 检查卡片内是否存在所述预加载命令中的安全域标识对应的应用,若 存在则执行步骤 c3-4, 若不存在则执行步骤 c4 ; 否则执行步骤 c4 ; 步骤 c3-4、 判断所述预加载命令中的安全域标识对应的应用是否 具有安全域权限,若有安全域权限则判断所述预加载命令中的安全域 标识对应的应用是否为当前第一卡片数据管理模块, 是则执行步骤 c3-6, 否则执行步骤 c3-5 ; 若没有安全域权限则执行步骤 c4 ;
步骤 c3-5、 判断所述预加载命令中的安全域标识对应的应用的状 态是否为个人化, 是则执行步骤 c3-6, 否则执行步骤 c4 ;
步骤 c3-6、 设置所述预加载命令中的加载文件标识对应的加载文 件的关联安全域为所述预加载命令中的安全域标识对应的应用,判断 所述预加载命令中的加载文件数据块哈希值长度是否为预设值,是则 存储所述预加载命令中的加载文件数据块哈希值并设置哈希值验证 标志, 处理所述预加载命令中的加载参数域, 执行步骤 c3-7, 否则执 行步骤 c4 ;
步骤 c3-7、 判断所述预加载命令中的加载令牌长度是否为 0x80, 是则发送计算加载令牌所需的数据给第二卡片数据管理模块,接收第 二卡片数据管理模块返回的计算结果,判断所述计算结果与所述预加 载命令中的加载令牌是否相同, 是则新建加载文件结构, 初始化全局 块编号, 设置返回数据为 0x00, 执行步骤 c4, 否则执行步骤 c4。
14、 根据权利要求 11所述的方法, 其特征在于, 所述步骤 D具体 包括:
步骤 dl、收取加载命令的数据域部分,得到加载命令的全部内容, 检查当前第一卡片数据管理模块的状态,若当前第一卡片数据管理模 块的状态为个人化则判断当前第一卡片数据管理模块是否具有代理 权限, 是则执行步骤 d2, 否则执行步骤 d4; 若当前第一卡片数据管理 模块的状态不为个人化则执行步骤 d4;
步骤 d2、判断卡片是否满足安全条件,是则检查卡片的安全级别, 若为第一级别则执行步骤 d3,若为第二级别或第三级别则判断所述加 载命令是否完整, 当所述加载命令完整时执行步骤 d3, 当所述加载命 令不完整时执行步骤 d4, 否则执行步骤 d4;
步骤 d3、 对所述加载命令进行格式检查, 若检查通过则以组件为 单位处理所述加载命令中的加载文件数据块, 当所述加载命令中的加 载文件数据块为加载文件的最后一个加载文件数据块时提交存储可 执行加载文件结构, 发送计算收条所需的数据给第二卡片数据管理模 块, 接收第二卡片数据管理模块返回的收条, 设置返回数据为所述收 条, 执行步骤 d4, 否则设置返回数据为 0x00, 执行步骤 d4; 若检查未 通过则执行步骤 d4;
步骤 d4、 生成相应状态码, 返回设置的返回数据和 /或生成的状 态码。
15、 根据权利要求 14所述的方法, 其特征在于, 所述步骤 d3具体 包括:
步骤 d3-l、 检查所述加载命令中的第二参数是否等于全局块编 号, 是则判断所述全局块编号是否为 0, 若所述全局块编号为 0则验证 所述加载文件中的数据验证模式块信息, 当验证通过时执行步骤 d3-2, 当验证不通过时执行步骤 d4, 若所述全局块编号不为 0则执行 步骤 d3-2; 否则执行步骤 d4;
步骤 d3-2、 判断卡片内是否存在哈希值验证标志, 是则保存所述 加载命令中的加载文件数据块, 执行步骤 d3-3, 否则直接执行步骤 d3-3 ;
步骤 d3-3、 判断所述可执行加载文件结构中是否有未提交存储的 组件, 是则执行步骤 d3-5, 否则执行步骤 d3-4;
步骤 d 3 - 4、 检查所述加载命令中是否包含组件编号和组件大小, 是则读取所述组件编号, 判断所述编号是否合法, 若所述编号合法则 根据所述组件大小分派相应大小的空间, 执行步骤 d3-5, 若不合法则 执行步骤 d4, 否则执行步骤 d4;
步骤 d3-5、 开始处理所述加载命令中的加载文件数据块, 判断当 前组件是否处理完成,是则提交当前组件的处理结果,执行步骤 d3-6, 否则执行步骤 d3-6 ;
步骤 d3-6、 判断是否还有未处理的加载文件数据块数据, 是则返 回执行步骤 d3-5, 否则所述全局块编号自增, 判断所述加载命令中的 第一参数是否为 0x80, 若为 0x80则执行步骤 d3-7, 若不为 0x80则设置 返回数据为 0x00, 执行步骤 d4;
步骤 d3-7、 判断卡片内是否存在哈希值验证标志, 是则对已存储 的加载文件数据块进行哈希计算,判断计算结果是否等于卡内存储的 加载文件数据块哈希值, 若等于则执行步骤 d3-8, 若不等于则执行步 骤 d4, 否则执行步骤 d3-8 ;
步骤 d3-8、 提交存储所述可执行加载文件结构, 发送计算收条所 需的数据给第二卡片数据管理模块,接收第二卡片数据管理模块返回 的收条, 设置返回数据为所述收条, 执行步骤 d4。
16、 根据权利要求 11所述的方法, 其特征在于, 所述步骤 E具体 包括:
步骤 el、收取安装命令的数据域部分,得到安装命令的全部内容, 检查当前第一卡片数据管理模块的状态,若当前第一卡片数据管理模 块的状态为个人化则判断当前第一卡片数据管理模块是否具有代理 权限, 是则执行步骤 e2, 否则执行步骤 e4,; 若当前第一卡片数据管理 模块的状态不为个人化则执行步骤 e4;
步骤 e2、判断卡片是否满足安全条件,是则检查卡片的安全级别, 若为第一级别则执行步骤 e3, 若为第二级别或第三级别则判断所述安 装命令是否完整, 当所述安装命令完整时执行步骤 e3, 当所述安装命 令不完整时执行步骤 e4, 否则执行步骤 e4;
步骤 e3、 对所述安装命令进行格式检查, 若检查通过则处理所述 安装命令中的安装参数域,根据所述安装命令的数据域中的数据注册 应用以及设置所述安装命令中的应用标识对应的应用的状态和权限, 发送计算收条所需的数据给第二卡片数据管理模块,接收第二卡片数 据管理模块返回的收条, 设置返回数据为所述收条, 执行步骤 e4; 若 检查未通过则执行步骤 e4;
步骤 e4、 生成相应状态码, 返回设置的返回数据和 /生成的状态 码。
17、 根据权利要求 11所述的方法, 其特征在于所述步骤 G具体包 括:
步骤 gl、收取引渡命令的数据域部分,得到引渡命令的全部内容, 检查当前第一卡片数据管理模块的状态,若当前第一卡片数据管理模 块的状态为个人化则判断当前第一卡片数据管理模块是否具有代理 权限, 是则执行步骤 g2, 否则执行步骤 g4; 若当前第一卡片数据管理 模块的状态不为个人化则执行步骤 g4;
步骤 g2、判断卡片是否满足安全条件,是则检查卡片的安全级别, 若为第一级别则执行步骤 g3,若为第二级别或第三级别则判断所述引 渡命令是否完整, 当所述引渡命令完整时执行步骤 g3, 当所述引渡命 令不完整时执行步骤 g4, 否则执行步骤 g4;
步骤 g3、 对所述引渡命令进行格式检查, 若检查通过则将所述引 渡命令中的应用标识对应的应用关联的安全域修改为所述引渡命令 中的安全域标识对应的应用, 发送计算收条所需的数据给第二卡片数 据管理模块, 接收第二卡片数据管理模块返回的收条, 设置返回数据 为所述收条, 执行步骤 g4, 若检查未通过则执行步骤 g4;
步骤 g4、 生成相应状态码, 返回设置的返回数据和 /生成的状态 码。
18、 根据权利要求 17所述的方法, 其特征在于, 所述步骤 g3具体 包括:
应用, 若存在则执行步骤 g3-2, 若不存在则执行步骤 g4; 否则执行步 骤 g4;
步骤 g3-2、 判断所述引渡命令中的安全域标识对应的应用是否为 当前卡片提供商模块, 是则执行步骤 g4; 否则判断所述引渡命令中安 全域标识之后的一个字节数据是否为 0x00, 是则执行步骤 g3-3, 否则 执行步骤 g4;
步骤 g3-3、 判断所述引渡命令中的安全域标识对应的应用的状态 是否为安装,是则判断所述引渡命令中的应用标识长度是否在预设范 围内, 若在预设范围内则执行步骤 g3-4, 若不在预设范围内则执行步 骤 g4; 否则执行步骤 g4;
步骤 g3-4、 判断卡片内是否存在所述引渡命令中的应用标识对应 的应用,是则判断所述引渡命令中的应用标识对应的应用关联的安全 域是否为当前第一卡片数据管理模块,若为当前第一卡片数据管理模 块则执行步骤 g3-4, 若不为当前第一卡片数据管理模块则执行步骤 g4; 否则执行步骤 g4;
步骤 g3-5、 判断所述引渡命令中的安全域标识对应的应用是否具 有安全域权限,是则判断所述引渡命令中的安全域标识对应的应用的 状态是否为锁定, 若为锁定则执行步骤 g4, 若不为锁定则执行步骤 g3-6 ; 否则执行步骤 g4;
步骤 g3-6、 判断所述引渡命令中的安全域标识对应的应用的状态 是否为个人化,若为个人化则判断所述引渡命令中的应用标识后的两 个字节数据是否均为 0x00, 是则执行步骤 g3-6, 否则执行步骤 g4; 若 不为个人化则执行步骤 g4; 是则发送计算引渡令牌所需的数据给第二卡片数据管理模块,接收第 二卡片数据管理模块返回的计算结果,判断所述计算结果是否与所述 引渡命令中的引渡令牌相同, 若相同则执行步骤 g3-8, 若不相同则执 行步骤 g4; 否则执行步骤 g4;
步骤 g3-8、 判断所述引渡命令中的应用标识对应的应用是否具有 安全域权限, 是则执行步骤 g4, 否则将所述引渡命令中的应用标识对 应的应用关联的安全域修改为所述引渡命令中的安全域标识对应的 应用, 发送计算收条所需的数据给第二卡片数据管理模块, 接收第二 卡片数据管理模块返回的收条, 设置返回数据为所述收条, 执行步骤 g4。
19、 根据权利要求 11所述的方法, 其特征在于, 所述步骤 H具体 包括:
步骤 hl、 收取个人化命令的数据域部分, 得到个人化命令的全部 内容, 判断当前第一卡片数据管理模块的状态, 若当前第一卡片数据 管理模块的状态为个人化则执行步骤 h2, 否则执行步骤 h4;
步骤 h2、判断卡片是否满足安全条件,是则检查卡片的安全级别, 若为第一级别则执行步骤 h3,若为第二级别或第三级别则判断所述个 人化命令是否完整, 当所述个人化命令完整时执行步骤 h3, 当所述个 人化命令不完整时执行步骤 h4; 否则执行步骤 h4;
步骤 h3、 对所述可选择命令进行格式检查, 若检查通过则将所述 个人化命令中的应用标识对应的应用的状态设置为个人化,设置返回 数据为 0x00, 执行步骤 h4, 若检查未通过则执行步骤 h4; 步骤 h4、 生成相应状态码, 返回设置的返回数据和 /生成的状态 码。
20、 根据权利要求 11所述的方法, 其特征在于所述步骤 I具体包 括:
步骤 il、收取删除命令的数据域部分,得到删除命令的全部内容, 检查当前第一卡片数据管理模块的状态,若当前第一卡片数据管理模 块的状态为个人化则判断当前第一卡片数据管理模块是否具有代理 权限, 是则执行步骤 i2, 否则执行步骤 i4; 若当前第一卡片数据管理 模块的状态不为个人化则执行步骤 i4;
步骤 i2、判断卡片是否满足安全条件,是则检查卡片的安全级别, 若为第一级别则执行步骤 i3, 若为第二级别或第三级别则判断所述删 除命令是否完整, 当所述删除命令完整时执行步骤 i3, 当所述删除命 令不完整时执行步骤 i4, 否则执行步骤 i4;
步骤 i3、 对所述删除命令进行格式检查, 若检查通过则根据所述 删除命令中的数据域标识删除相应可执行文件和 /或相应应用, 发送 计算收条所需的数据给第二卡片数据管理模块,接收第二卡片数据管 理模块返回的收条, 设置返回数据为所述收条, 执行步骤 i4, 若检查 未通过则执行步骤 i4;
步骤 i4、生成相应状态码,返回设置的返回数据和 /生成的状态码。
PCT/CN2014/076030 2013-04-25 2014-04-23 一种管理卡片上应用的方法 WO2014173298A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US14/786,213 US10324781B2 (en) 2013-04-25 2014-04-23 Method for managing application on card

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201310146939.4A CN103218560B (zh) 2013-04-25 2013-04-25 一种管理卡片数据的实现方法
CN201310146939.4 2013-04-25
CN201310399702.7 2013-09-05
CN201310399702.7A CN103473093B (zh) 2013-09-05 2013-09-05 一种管理卡片上应用的方法

Publications (1)

Publication Number Publication Date
WO2014173298A1 true WO2014173298A1 (zh) 2014-10-30

Family

ID=51791060

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/076030 WO2014173298A1 (zh) 2013-04-25 2014-04-23 一种管理卡片上应用的方法

Country Status (2)

Country Link
US (1) US10324781B2 (zh)
WO (1) WO2014173298A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103544037B (zh) 2013-10-29 2016-08-17 飞天诚信科技股份有限公司 一种支持OpenSC的软硬件驱动的实现方法
US11138076B2 (en) * 2017-06-30 2021-10-05 Redis Ltd. Methods, systems, and media for controlling append-only file rewrites

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101042736A (zh) * 2006-03-24 2007-09-26 中国银联股份有限公司 一种智能卡及智能卡中存取对象的方法
US7340748B2 (en) * 2000-12-21 2008-03-04 Gemplus Automatic client proxy configuration for portable services
CN102801705A (zh) * 2012-06-25 2012-11-28 飞天诚信科技股份有限公司 一种java卡上安全域的实现方法
CN103218560A (zh) * 2013-04-25 2013-07-24 飞天诚信科技股份有限公司 一种管理卡片数据的实现方法
CN103473093A (zh) * 2013-09-05 2013-12-25 飞天诚信科技股份有限公司 一种管理卡片上应用的方法

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0917119A3 (en) * 1997-11-12 2001-01-10 Citicorp Development Center, Inc. Distributed network based electronic wallet
US6824045B2 (en) * 2000-04-20 2004-11-30 Canon Kabushiki Kaisha Method and system for using multiple smartcards in a reader
US6816882B1 (en) * 2000-05-31 2004-11-09 International Business Machines Corporation System and method for automatically negotiating license agreements and installing arbitrary user-specified applications on application service providers
US7113883B1 (en) * 2001-08-24 2006-09-26 Vi Technology, Inc. Test configuration and data management system and associated method for enterprise test operations
US7850066B2 (en) * 2001-12-07 2010-12-14 Ecebs Limited Smartcard system
US9959544B2 (en) * 2003-05-22 2018-05-01 International Business Machines Corporation Updating an application on a smart card and displaying an advertisement
US20040236680A1 (en) * 2003-05-22 2004-11-25 International Business Machines Corporation Method and apparatus for displaying embedded chip states and embedded chip end-user application states
US7272776B2 (en) * 2003-12-30 2007-09-18 Sap Aktiengesellschaft Master data quality
US8355042B2 (en) * 2008-10-16 2013-01-15 Spatial Cam Llc Controller in a camera for creating a panoramic image
US8819286B2 (en) * 2010-10-19 2014-08-26 Hewlett-Packard Development Company, L.P. Methods, systems, and apparatus for processing messaging data sets using structured data sets
US8803666B2 (en) * 2012-07-10 2014-08-12 Honeywell International Inc. Universal access device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7340748B2 (en) * 2000-12-21 2008-03-04 Gemplus Automatic client proxy configuration for portable services
CN101042736A (zh) * 2006-03-24 2007-09-26 中国银联股份有限公司 一种智能卡及智能卡中存取对象的方法
CN102801705A (zh) * 2012-06-25 2012-11-28 飞天诚信科技股份有限公司 一种java卡上安全域的实现方法
CN103218560A (zh) * 2013-04-25 2013-07-24 飞天诚信科技股份有限公司 一种管理卡片数据的实现方法
CN103473093A (zh) * 2013-09-05 2013-12-25 飞天诚信科技股份有限公司 一种管理卡片上应用的方法

Also Published As

Publication number Publication date
US20160085609A1 (en) 2016-03-24
US10324781B2 (en) 2019-06-18

Similar Documents

Publication Publication Date Title
JP7372434B2 (ja) スクリプトに基づくブロックチェーン相互作用
US9398025B2 (en) Method for generating and check-controlling network identity indentification code in network electronic identification card
CN110912707B (zh) 基于区块链的数字证书处理方法、装置、设备及存储介质
CN112671720B (zh) 一种云平台资源访问控制的令牌构造方法、装置及设备
CN110989994A (zh) 基于区块链的代码版本管理方法、装置、终端及存储介质
WO2015156786A1 (en) Redactable document signatures
WO2009157133A1 (ja) 情報処理装置、情報処理方法、これらを実現するコンピュータプログラム及び集積回路
US20100235754A1 (en) User information widgets and methods for updating and retrieving user information
US10621335B2 (en) Method and device for verifying security of application
WO2018153353A1 (zh) 实现认证/授权的方法、装置、云计算系统及计算机系统
CN112347521A (zh) 一种基于医疗区块链的医疗数据管理方法及系统
CN109257332B (zh) 数字货币硬件钱包应用更新的安全通道的创建方法及装置
US20200349556A1 (en) Methods and devices for managing access to account in blockchain system
CN111612456A (zh) 过期数字证书管控方法、系统、装置及存储介质
KR20230044262A (ko) 블록체인 토큰들
US20050154899A1 (en) Mobile software authentication and validation
CN110213290A (zh) 数据获取方法、api网关以及存储介质
CN103152724B (zh) 一种硬件锁sim卡的方法及系统
CN104158797A (zh) 口令和标识型密码相集成的用户登录鉴别实施方法
CN106487505B (zh) 密钥管理、获取方法及相关装置和系统
WO2014173298A1 (zh) 一种管理卡片上应用的方法
CN103218560B (zh) 一种管理卡片数据的实现方法
CN111241492A (zh) 一种产品多租户安全授信方法、系统及电子设备
CN103473093B (zh) 一种管理卡片上应用的方法
CN105677693A (zh) 一种访问数据库的方法及装置

Legal Events

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

Ref document number: 14788882

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 14786213

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14788882

Country of ref document: EP

Kind code of ref document: A1