CN105427098B - Method and device for realizing information sharing among different applications - Google Patents
Method and device for realizing information sharing among different applications Download PDFInfo
- Publication number
- CN105427098B CN105427098B CN201510733498.7A CN201510733498A CN105427098B CN 105427098 B CN105427098 B CN 105427098B CN 201510733498 A CN201510733498 A CN 201510733498A CN 105427098 B CN105427098 B CN 105427098B
- Authority
- CN
- China
- Prior art keywords
- instruction
- card
- data
- electronic cash
- electronic
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/30—Payment architectures, schemes or protocols characterised by the use of specific devices or networks
- G06Q20/36—Payment architectures, schemes or protocols characterised by the use of specific devices or networks using electronic wallets or electronic money safes
- G06Q20/367—Payment architectures, schemes or protocols characterised by the use of specific devices or networks using electronic wallets or electronic money safes involving electronic purses or money safes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/30—Payment architectures, schemes or protocols characterised by the use of specific devices or networks
- G06Q20/34—Payment architectures, schemes or protocols characterised by the use of specific devices or networks using cards, e.g. integrated circuit [IC] cards or magnetic cards
Landscapes
- Business, Economics & Management (AREA)
- Engineering & Computer Science (AREA)
- Accounting & Taxation (AREA)
- Computer Networks & Wireless Communication (AREA)
- Strategic Management (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Finance (AREA)
- Microelectronics & Electronic Packaging (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
The invention discloses a method and a device for realizing information sharing among different applications, wherein the method comprises the following steps: when the card receives an application selection instruction sent by the upper computer, the card judges the application needing to be selected, if the application is an electronic wallet application, the current electronic wallet data of the electronic wallet application is synchronized by the current electronic cash information under the electronic cash application of the card, and when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received electronic wallet access data instruction, and returns the processing result to the upper computer; if the electronic cash application is the electronic cash application, the electronic wallet balance in the current electronic wallet data applied to the card is synchronized with the electronic cash balance in the current electronic cash information applied to the card, when the card judges that the condition for accessing the electronic cash data meets the requirement, the current electronic cash information is processed according to the received electronic cash data accessing instruction, and the processing result is returned to the upper computer.
Description
Technical Field
The present invention relates to the field of information security, and in particular, to a method and an apparatus for implementing information sharing between different applications.
Background
In the prior art, electronic commerce is generally realized through an electronic wallet, but the electronic wallet and the electronic cash can not be used in one card at the same time due to the characteristics of the electronic wallet and the electronic cash, and information in the electronic wallet and the electronic cash needs to be shared if the card is compatible with an old system and an old transaction and is compatible with a new system and a card in a new environment. How to share information in an electronic wallet in a card and electronic cash is a problem to be solved urgently in the prior art.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a method and a device for realizing information sharing among different applications.
The invention provides a method for realizing information sharing among different applications, which comprises the following steps: 1. a method for realizing information sharing among different applications is characterized by comprising the following steps:
step S1: the card waits for receiving an application selection instruction sent by an upper computer, judges an application needing to be selected when the application selection instruction is received, and executes the step S2 if the application is an electronic wallet application, and executes the step S3 if the application is an electronic cash application;
step S2: the current electronic cash information under the electronic cash application for the card synchronizes the current electronic wallet data of the electronic wallet application, and when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data and returns the processing result to the upper computer;
step S3: and when the card judges that the condition of accessing the electronic cash data meets the requirement, the card processes the current electronic cash information according to the received instruction of accessing the electronic cash data and returns the processing result to the upper computer.
Further, the card synchronizing the electronic wallet application current electronic wallet data with current electronic cash information under an electronic cash application, comprising:
step A1: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, the step A2 is executed, otherwise, the step is continued;
step A2: and the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information and continues.
Further, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the data instruction for accessing the electronic wallet received by the card is a load instruction, the card judges whether a load operation condition meets a first requirement, if so, the card updates the balance of the electronic wallet by using the saved load amount, updates the overdrawn amount of electronic cash by using the overdrawn amount of the electronic wallet, sets an electronic wallet balance change identifier, returns a successful response to the upper computer, and waits for receiving an instruction sent by the upper computer; otherwise, error is reported and the process is finished.
Further, the card judges whether the earmark operation condition meets the first requirement, including:
the card judges whether the loading instruction is correct or not, the card judges whether the current security state is the first security state or not, the card judges whether the MAC value in the data field of the loading instruction is correct or not, the card judges whether the transaction authentication code key exists or not, if the four judgment results are yes, the loading operation condition meets a first requirement, and if not, the loading operation condition does not meet the first requirement.
Further, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the data command for accessing the electronic wallet received by the card is a consumption command, the card judges whether consumption operation conditions meet second requirements, if so, the card updates the balance of the electronic wallet according to the saved consumption amount, updates the overdrawn amount of electronic cash by the overdrawn amount of the electronic wallet, sets an electronic wallet balance change identifier, returns a successful response to the upper computer, and waits for receiving the command sent by the upper computer; otherwise, error is reported and the process is finished.
Further, the card determining whether the consumption operation condition satisfies the second requirement includes:
the card judges whether the consumption instruction is correct, the card judges whether the current safety state is the second safety state or the third safety state, the card judges whether the MAC value in the data field of the consumption instruction is correct, the card judges whether the transaction authentication code key exists, if the four conditions are judged to be yes, the consumption operation condition meets the second requirement, otherwise, the consumption operation condition does not meet the second requirement.
Further, the setting of the electronic wallet balance change identifier and the return of the successful response to the upper computer comprises:
step B1: the card judges whether the current safety state is the third safety state, if so, the step B2 is executed, otherwise, the card waits for receiving an instruction sent by the upper computer;
step B2: the card judges whether the electronic cash application has a corresponding extended application record file, if so, the step B3 is executed, otherwise, the step B4 is executed;
step B3: the card updates the data in the composite application record cache to an extended application record file of the electronic cash and continues;
step B4: and the card updates the data in the composite application record cache to the composite transaction record file of the electronic wallet and continues.
Further, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the data instruction for accessing the electronic wallet received by the card is a load initialization instruction, the card judges whether a load initialization operation condition meets a fifth requirement, if so, the card stores the load amount in a data field of the load initialization instruction, sets a first safety state, returns a successful response to the upper computer, waits for receiving the instruction sent by the upper computer, otherwise, reports an error, and ends.
Further, the card determines whether the load initialization operation condition meets a fifth requirement, including:
the card judges whether the earmark initialization instruction is correct or not, the card judges whether a corresponding earmark key exists or not according to an earmark key index in a data field of the earmark initialization instruction, the card judges whether the earmark amount in the data field of the earmark initialization instruction plus the balance of the current electronic wallet exceeds the upper limit value of the balance of the electronic cash, if the three judgment results are yes, the earmark initialization operation condition meets a fifth requirement, otherwise, the earmark initialization operation condition does not meet the fifth requirement.
Further, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the data access instruction received by the card is a consumption initialization instruction, the card judges whether consumption initialization operation conditions meet sixth requirements, if so, the card sets a second safety state, returns a successful response to the upper computer, and waits for receiving an instruction issued by the upper computer; otherwise, error is reported and the process is finished.
Further, the card determining whether the consumption initialization operating condition meets a sixth requirement includes:
the card judges whether the consumption initialization instruction is correct or not, the card judges whether a corresponding consumption key exists or not according to the consumption key index in the data field of the consumption initialization instruction, the card judges whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet, if yes, the consumption initialization operation condition meets a sixth requirement, and if not, the consumption initialization operation condition does not meet the sixth requirement.
Further, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the data command for accessing the electronic wallet received by the card is a composite consumption initialization command, the card judges whether a composite consumption initialization operation condition meets a seventh requirement, if so, the card sets the third safety state, returns a successful response to the upper computer, and waits for receiving a command sent by the upper computer; otherwise, error is reported and the process is finished.
Further, the card determining whether the composite consumption initialization operating condition satisfies a seventh requirement includes:
the card judges whether the composite consumption initialization instruction is correct or not, the card judges whether the corresponding composite consumption key exists or not according to the composite consumption key index in the data field of the composite consumption initialization instruction, the card judges whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet or not, if the three judgment results are yes, the composite consumption initialization operation condition meets a seventh requirement, and if not, the composite consumption initialization operation condition does not meet the seventh requirement.
Further, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the command for accessing the electronic wallet data received by the card is a compound consumption file updating command, executing step F1;
step F1: the card judges whether the updating operation condition of the compound consumption file meets the eighth requirement, if so, the step F2 is executed, otherwise, an error is reported, and the operation is finished;
step F2: the card judges whether the corresponding electronic cash expansion application file exists according to the composite consumption file updating instruction, if so, the step F3 is executed, otherwise, the step F4 is executed;
step F3: the card updates electronic cash information by using the recorded content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and waits for receiving an instruction sent by the upper computer;
step F4: and the card updates the balance of the electronic wallet by using the record content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and waits for receiving the instruction sent by the upper computer.
Further, the card determining whether the composite consumption file updating operation condition meets an eighth requirement includes:
the card judges whether a preset composite transaction record file of the electronic wallet exists according to the short file identifier in the composite consumption file updating instruction, judges whether a corresponding record in the composite transaction file of the electronic wallet exists according to the record identifier in the composite consumption file updating instruction, judges whether the record length in the composite consumption file updating instruction is correct or not, if the three judgment results are yes, the composite consumption file updating operation condition meets an eighth requirement, and otherwise, the composite consumption file updating operation condition does not meet the eighth requirement.
Further, synchronizing the electronic cash balance in the current electronic cash information under the electronic cash application with the electronic wallet balance in the current electronic wallet data under the electronic wallet application for the card comprises:
step P1: the card judges whether the balance of the electronic wallet changes according to the change identification of the balance of the electronic wallet, if so, the step P2 is executed, otherwise, the step is continued;
step P2: and the card updates the balance of the electronic cash by using the balance of the electronic wallet, and clears the change identifier of the balance of the electronic wallet.
Further, when the card determines that the condition for accessing the electronic cash data meets the requirement, the card processes the current electronic cash information according to the received instruction for accessing the electronic cash data, including:
and when the data command for accessing the electronic wallet received by the card is a reading and recording command, the card judges whether the reading and recording operation condition meets a third requirement, if so, the card updates the electronic cash balance information according to the current actually available electronic cash balance and the transaction amount, sets an electronic cash information change mark, returns a successful response to the upper computer, waits for receiving the command sent by the upper computer, otherwise, reports an error, and ends.
Further, the card determines whether the reading and recording operation condition meets a third requirement, including:
step X1: the card judges whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the step X2 is executed, otherwise, an error is reported, and the operation is finished;
step X2: the card judges whether corresponding data in a corresponding file in the electronic cash application exists according to the data on the third byte of the reading record instruction, if so, the corresponding data is taken as current data, and the step X3 is executed, otherwise, an error is reported, and the operation is finished;
step X3: the card judges whether the current safety state meets the condition, if so, the step X4 is executed, otherwise, the current data are returned to the upper computer, and the card waits for receiving the instruction sent by the upper computer;
step X4: the card judges whether the current data is the last unread data of the file locator, if so, the read record operation condition meets the third requirement, otherwise, the step X5 is executed;
step X5: and the card returns current data to the upper computer and waits for receiving an instruction sent by the upper computer.
Further, the step between the setting of the electronic cash information change flag and the return of the successful response to the upper computer further comprises:
step W1: the card judges whether an instruction for updating the extended application record cache is received, if so, the step W3 is executed, otherwise, the step W2 is executed;
step W2: the card clears a flag bit arranged in the electronic cash application, returns current data to the upper computer and waits for receiving an instruction sent by the upper computer;
step W3: and the card stores the data in the update extended application record caching instruction into a composite transaction record file of the electronic cash, clears a flag bit arranged in the electronic cash application, returns the current data to the upper computer and waits for receiving the instruction sent by the upper computer.
Further, when the card determines that the condition for accessing the electronic cash data meets the requirement, the card processes the current electronic cash information according to the received instruction for accessing the electronic cash data, including:
when the data access instruction received by the card is a data modification instruction, the card judges whether the data modification operation condition meets a fourth requirement, if so, the card updates the electronic cash balance by using the amount in the data field of the data modification instruction, sets an electronic cash information change mark, returns a successful response to the upper computer, and waits for receiving the instruction sent by the upper computer; otherwise, error is reported and the process is finished.
Further, the card determines whether the modified data operation condition satisfies a fourth requirement, including:
the card judges whether the data modification instruction is correct or not, the card judges whether the label code in the data modification instruction is legal or not, the card judges whether the length of the label value in the data modification instruction is correct or not, the card judges whether the MAC value in the data domain of the data modification instruction is correct or not, if the four judgment results are yes, the data modification operation condition meets a fourth requirement, and if not, the data modification operation condition does not meet the fourth requirement.
Further, the card uses the amount of money in the data field of the data modification instruction to update the balance of the electronic cash, sets an electronic cash information change mark, returns a successful response to the upper computer, and waits for receiving the instruction issued by the upper computer, and the method comprises the following steps:
step D1: the card judges whether the label in the data modification instruction is preset data, if so, the step D2 is executed, otherwise, the card waits for receiving an instruction issued by the upper computer;
step D2: and the card updates the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change identifier, returns a successful response to the upper computer and waits for receiving the instruction sent by the upper computer.
The invention also provides a device for realizing information sharing among different applications, which comprises:
the receiving module is used for waiting and receiving the instruction sent by the upper computer;
the first judgment module is used for judging the application needing to be selected when the receiving module receives an application selection instruction, triggering the first synchronization module to work if the application is an electronic wallet application, and triggering the second synchronization module to work if the application is an electronic cash application;
the first synchronization module is used for synchronizing the current electronic wallet data of the electronic wallet application by using the current electronic cash information of the electronic cash application;
the first processing module is used for processing the current electronic wallet data according to the received instruction for accessing the electronic wallet data when the condition for accessing the electronic wallet data meets the requirement;
the second synchronization module is used for synchronizing the electronic cash balance in the current electronic cash information under the electronic cash application by using the electronic wallet balance in the current electronic wallet data under the electronic wallet application;
the second processing module is used for processing the current electronic cash information according to the received electronic cash data access instruction when the condition for accessing the electronic cash data meets the requirement;
and the return module is used for returning the processing result of the first processing module or the second processing module to the upper computer.
Further, the first synchronization module comprises:
the first judgment unit is used for judging whether the electronic cash information changes according to the electronic cash information change identifier, if so, the first updating and clearing unit is triggered to work, and if not, the first processing module is triggered to work;
the first updating and clearing unit is used for acquiring the balance and the overdrawn amount of the electronic cash in the electronic cash information, updating the balance and the overdrawn amount of the electronic wallet, clearing the change mark of the electronic cash information and triggering the first processing module to work.
Further, the first processing module includes:
the second judging unit is used for judging whether the load operation condition meets a first requirement or not when the receiving module receives the load instruction, if so, the first updating setting unit is triggered to work, and otherwise, the error reporting unit is triggered to work;
the first updating setting unit is used for updating the balance of the electronic purse by using the saved earmark amount, updating the overdrawn amount of electronic cash by using the overdrawn amount of the electronic purse, and setting a balance change identifier of the electronic purse;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
Further, the second determining unit is specifically configured to determine whether the load instruction is correct, determine whether the current security state is the first security state, determine whether an MAC value in a data field of the load instruction is correct, and determine whether the transaction authentication code key exists, where if all the four determination results are yes, the load operation condition satisfies the first requirement, and otherwise, the load operation condition does not satisfy the first requirement.
Further, the first processing module includes:
the third judging unit is used for judging whether the consumption operating condition meets a second requirement or not when the receiving module receives the consumption instruction, if so, the second updating setting unit is triggered to work, and otherwise, the error reporting unit is triggered to work;
the second updating and setting unit is used for updating the balance of the electronic purse according to the saved consumption amount, updating the overdrawn amount of electronic cash by the overdrawn amount of the electronic purse and setting a balance change identifier of the electronic purse;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
Further, the third determining unit is specifically configured to determine whether the consumption instruction is correct, determine whether the current security state is the second security state or the third security state, determine whether the MAC value in the data field of the consumption instruction is correct, and determine whether the transaction authentication code key exists, where if all the four values are determined to be yes, the consumption operating condition meets the second requirement, and otherwise, the consumption operating condition does not meet the second requirement.
Further, the first processing module further comprises:
the fourth judging unit is used for judging whether the current safety state is the third safety state, if so, the fifth judging unit is triggered to work, and otherwise, the receiving module is triggered to work;
the fifth judging unit is used for judging whether the electronic cash application has a corresponding extended application record file, if so, the first updating unit is triggered to work, and if not, the second updating unit is triggered to work;
the first updating unit is used for updating the data in the composite application record cache into an extended application record file of the electronic cash;
and the second updating unit is used for updating the data in the composite application record cache into the composite transaction record file of the electronic wallet.
Further, the first processing module includes:
the sixth judging unit is used for judging whether the load initialization operating condition meets a fifth requirement or not when the receiving module receives the load initialization instruction, if so, triggering the first storage setting unit to work, and otherwise, triggering the error reporting unit to work;
the first saving setting unit is used for saving the load amount in the data field of the load initialization instruction and setting a first safety state;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
Further, the sixth determining unit is specifically configured to determine whether the load initialization instruction is correct, determine whether a corresponding load key exists according to a load key index in a data field of the load initialization instruction, determine whether a result of adding the load amount in the data field of the load initialization instruction and the current electronic wallet balance exceeds an electronic cash balance upper limit value, and if all the three determination results are yes, the load initialization operating condition satisfies a fifth requirement, otherwise, the load initialization operating condition does not satisfy the fifth requirement.
Further, the first processing module includes:
the seventh judging unit is used for judging whether the consumption initialization operating condition meets the sixth requirement or not when the receiving module receives the consumption initialization instruction, if so, triggering the first setting unit to work, and otherwise, triggering the error reporting unit to work;
the first setting unit is used for setting a second safety state;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
Further, the seventh determining unit is specifically configured to determine whether the consumption initialization instruction is correct, determine whether a corresponding consumption key exists according to a consumption key index in a data field of the consumption initialization instruction, and determine whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet, where if all three determination results are yes, the consumption initialization operating condition satisfies a sixth requirement, and otherwise, the consumption initialization operating condition does not satisfy the sixth requirement.
Further, the first processing module includes:
the eighth judging unit is used for judging whether the composite consumption initialization operating condition meets a seventh requirement or not when the receiving module receives the composite consumption initialization instruction, if so, triggering the second setting unit to work, and otherwise, triggering the error reporting unit to work;
the second setting unit is used for setting the third safety state;
the return module is also used for returning a successful response to the upper computer;
the error reporting unit is also used for reporting errors.
Further, the eighth determining unit is specifically configured to determine whether the composite consumption initialization instruction is correct, determine whether a corresponding composite consumption key exists according to a composite consumption key index in a data field of the composite consumption initialization instruction, determine whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet, and if all the three determination results are yes, determine that the composite consumption initialization operating condition satisfies a seventh requirement, otherwise, determine that the composite consumption initialization operating condition does not satisfy the seventh requirement.
Further, the first processing module includes:
a ninth judging unit, configured to, when the receiving module receives a compound consumption file update instruction, judge whether the compound consumption file update operation condition meets an eighth requirement, if yes, trigger a tenth judging unit to operate, and otherwise trigger an error reporting unit to operate;
the error reporting unit is used for reporting errors;
the tenth judging unit is used for judging whether the corresponding electronic cash extended application file exists according to the composite consumption file updating instruction, if so, triggering a third updating unit to work, and otherwise, triggering a fourth updating unit to work;
the third updating unit is used for updating the electronic cash information by using the record content in the data field of the compound consumption file updating instruction;
the fourth updating unit is used for updating the balance of the electronic wallet by using the record content in the data field of the compound consumption file updating instruction;
the return module is also used for returning a successful response to the upper computer.
Further, the ninth determining unit is specifically configured to determine whether a preset composite transaction record file of the electronic wallet exists according to the short file identifier in the composite consumption file updating instruction, determine whether a corresponding record in the composite transaction file of the electronic wallet exists according to the record identifier in the composite consumption file updating instruction, and determine whether the record length in the composite consumption file updating instruction is correct, where if all three determination results are yes, the composite consumption file updating operation condition satisfies the eighth requirement, and otherwise, the composite consumption file updating operation condition does not satisfy the eighth requirement.
Further, the second synchronization module includes:
the eleventh judging unit is used for judging whether the balance of the electronic wallet changes according to the balance change identifier of the electronic wallet, if so, the second updating and clearing unit is triggered to work, and if not, the second processing module is triggered to work;
and the second updating and clearing unit is used for updating the balance of the electronic cash by using the balance of the electronic wallet, clearing the change identifier of the balance of the electronic wallet and triggering the second processing module to work.
Further, the second processing module comprises:
a twelfth judging unit, configured to, when the receiving module receives the read record instruction, judge whether the read record operation condition meets a third requirement, if yes, trigger a third update setting unit to operate, and otherwise trigger an error reporting unit to operate;
the third updating and setting unit is used for updating the electronic cash balance information according to the current actually available electronic cash balance and the transaction amount and setting an electronic cash information change mark;
the return module is also used for returning a successful response to the upper computer;
the error reporting unit is used for reporting errors.
Further, the twelfth judging unit includes:
the first judging subunit is used for judging whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the second judging subunit is triggered to work, and if not, the error reporting unit is triggered to work;
the second judging subunit is used for judging whether corresponding data in a corresponding file in the electronic cash application exists according to the data on the third byte of the reading record instruction, if so, the corresponding data is used as current data, and the third judging subunit is triggered to work, otherwise, the error reporting unit is triggered to work;
the third judging subunit is used for judging whether the current safety state meets the condition, if so, the fourth judging subunit is triggered to work, and if not, the return module is triggered to work;
the return module is used for returning the current data to the upper computer;
and the fourth judging subunit is configured to judge whether the current data is the last unread data of the file locator, if so, trigger the third update setting unit to operate, and otherwise, trigger the return module to operate.
Further, the second processing module further comprises:
a thirteenth judging unit, configured to judge whether an update extended application record caching instruction is received, if yes, trigger a third update clearing unit to work, and otherwise, trigger the first clearing module unit;
the first clearing unit is used for clearing a flag bit arranged in the electronic cash application;
the return module is also used for returning the current data to the upper computer;
and the third updating and clearing unit is used for saving the data in the updating and expanding application record caching instruction into a composite transaction record file of the electronic cash and clearing a flag bit arranged in the electronic cash application.
Further, a second processing module comprising:
a fourteenth judging unit, configured to, when the receiving module receives the data modification instruction, judge whether the data modification operation condition meets a fourth requirement, if yes, trigger a fourth update setting unit to operate, and otherwise trigger an error reporting unit to operate;
the fourth updating and setting unit is used for updating the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, setting an electronic cash information change mark and triggering a return module to work;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
Further, the fourteenth determining unit is specifically configured to determine whether the modified data instruction is correct, determine whether a tag code in the modified data instruction is legal, determine whether a length of a tag value in the modified data instruction is correct, and determine whether an MAC value in a data field of the modified data instruction is correct, where if all the four determination results are yes, the modified data operation condition satisfies a fourth requirement, and otherwise, the modified data operation condition does not satisfy the fourth requirement.
Further, the fourth update setting unit includes:
a fifteenth judging subunit, configured to judge whether a tag in the modified data instruction is preset data, if so, trigger a fifth update setting unit to operate, and otherwise trigger the receiving module to operate;
and the fifth updating setting subunit is used for updating the balance of the electronic cash by using the amount of money in the data field of the modification data instruction and setting an electronic cash information change identifier.
Compared with the prior art, the invention has the following advantages:
the technical scheme of the invention is compatible with the electronic wallet system and the electronic cash system, thereby reducing the modification cost of the electronic wallet system; single account and multiple users are realized, and excessive fund stockpiling is reduced; the information needing to be shared is used as the shared content to be independent, and each application accesses the data through the shared interface, so that the effect that one account uses a plurality of systems is achieved, and the use of a user is facilitated.
Drawings
Fig. 1 is a flowchart of an implementation method for information sharing between different applications according to an embodiment of the present invention;
fig. 2, fig. 3 and fig. 4 are flowcharts of a method for implementing information sharing between an electronic wallet application and an electronic cash application according to a second embodiment of the present invention;
fig. 5, fig. 6, and fig. 7 are flowcharts of an implementation method for information sharing between different applications according to a third embodiment of the present invention;
fig. 8 is a block diagram of an apparatus for implementing information sharing between different applications according to a fourth embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this embodiment, the commands received by the card all conform to the APDU format, which specifically includes: CLA INS P1P 2 LcData Le, wherein CLA is the instruction type, INS is the instruction code, P1 and P2 are parameters, Lc is the length of Data, and Le is the length of return Data.
Example one
An embodiment of the present invention provides a method for implementing information sharing between different applications, as shown in fig. 1, including:
step S1: the card waits for and receives an application selection instruction sent by the upper computer, when the application selection instruction is received, the card judges the application needing to be selected, if the application is an electronic wallet application, the step S2 is executed, and if the application is an electronic cash application, the step S3 is executed;
step S2: the card uses the current electronic cash information under the electronic cash application to synchronize the current electronic wallet data applied by the electronic wallet, when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data and returns the processing result to the upper computer;
specifically, in this embodiment, the card synchronizing the current electronic wallet data of the electronic wallet application with the current electronic cash information under the electronic cash application includes:
step A1: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, the step A2 is executed, otherwise, the step is continued;
step A2: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, and clears the change mark of the electronic cash information.
In this embodiment, the synchronization operation may be performed before receiving the instruction, or may be performed before processing the instruction after receiving the instruction, and if the synchronization operation is performed before receiving the instruction, the file control information needs to be returned to the upper computer after the synchronization, and then the synchronization operation waits for receiving the instruction issued by the upper computer;
in this embodiment, the instruction to access the data of the electronic wallet includes: when the card judges that the condition of accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction of accessing the electronic wallet data and returns the processing result to the upper computer, the method comprises the following steps:
(1) when the data instruction for accessing the electronic wallet received by the card is a load instruction, the card judges whether the load operation condition meets a first requirement, if so, the card updates the balance of the electronic wallet by using the saved load amount, updates the overdrawn amount of electronic cash by using the overdrawn amount of the electronic wallet, sets an electronic wallet balance change identifier, returns a successful response to the upper computer, and waits for receiving an instruction sent by the upper computer; otherwise, error is reported and the process is finished.
Wherein, whether card judgement load operation condition satisfies first requirement includes: the card judges whether the loading instruction is correct or not, whether the current security state is the first security state or not, whether the MAC value in the data field of the loading instruction is correct or not is judged by the card, whether the transaction authentication code key exists or not is judged by the card, if the four judgment results are yes, the loading operation condition meets a first requirement, and if not, the loading operation condition does not meet the first requirement.
(2) When the data command for accessing the electronic wallet received by the card is a consumption command, the card judges whether the consumption operation condition meets a second requirement, if so, the card updates the balance of the electronic wallet according to the saved consumption amount, updates the overdrawn amount of electronic cash by the overdrawn amount of the electronic wallet, sets an electronic wallet balance change identifier, returns a successful response to the upper computer, and waits for receiving the command sent by the upper computer; otherwise, error is reported and the process is finished.
Wherein, whether card judgement consumption operating condition satisfies the second requirement includes: the card judges whether the consumption instruction is correct, whether the current safety state is the second safety state or the third safety state, whether the MAC value in the data field of the consumption instruction is correct or not is judged by the card, whether the transaction authentication code key exists or not is judged by the card, if yes, the consumption operation condition meets the second requirement, and if not, the consumption operation condition does not meet the second requirement.
After the instruction for accessing the electronic wallet data received by the card is a consumption instruction, setting an electronic wallet balance change identifier and returning a successful response to the upper computer may include:
step B1: the card judges whether the current safety state is the third safety state, if so, the step B2 is executed, otherwise, the card waits for receiving an instruction sent by the upper computer;
step B2: the card judges whether the electronic cash application has a corresponding extended application record file, if so, the step B3 is executed, otherwise, the step B4 is executed;
step B3: the card updates the data in the composite application record cache to an extended application record file of the electronic cash and continues;
step B4: and the card updates the data in the composite application record cache to the composite transaction record file of the electronic wallet and continues.
(3) And when the data instruction for accessing the electronic wallet received by the card is a load initialization instruction, the card judges whether the load initialization operation condition meets a fifth requirement, if so, the card stores the load amount in the data field of the load initialization instruction, sets a first safety state, returns a successful response to the upper computer, waits for receiving the instruction sent by the upper computer, otherwise, reports an error, and ends.
Wherein, whether the card judges the earmark initialization operation condition and satisfies the fifth requirement includes:
the card judges whether the earmark initialization instruction is correct or not, the card judges whether the corresponding earmark key exists or not according to the earmark key index in the data field of the earmark initialization instruction, the card judges whether the earmark amount in the data field of the earmark initialization instruction plus the current balance of the electronic wallet exceeds the upper limit value of the balance of the electronic cash, if the three judgment results are yes, the earmark initialization operation condition meets the fifth requirement, otherwise, the earmark initialization operation condition does not meet the fifth requirement.
(4) When the command for accessing the electronic wallet data received by the card is a consumption initialization command, the card judges whether the consumption initialization operation condition meets a sixth requirement, if so, the card sets a second safety state, returns a successful response to the upper computer, and waits for receiving a command sent by the upper computer; otherwise, error is reported and the process is finished.
Wherein, whether the card judges that the consumption initialization operation condition satisfies the sixth requirement includes:
and judging whether the consumption initialization instruction is correct or not by the card, judging whether the corresponding consumption key exists or not by the card according to the consumption key index in the data field of the consumption initialization instruction, judging whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet or not by the card, if so, judging that the consumption initialization operation condition meets the sixth requirement, and otherwise, judging that the consumption initialization operation condition does not meet the sixth requirement.
(5) When the data access instruction of the electronic wallet received by the card is a composite consumption initialization instruction, the card judges whether the composite consumption initialization operation condition meets a seventh requirement, if so, the card sets a third safety state, returns a successful response to the upper computer, and waits for receiving an instruction sent by the upper computer; otherwise, error is reported and the process is finished.
Wherein, whether the card judges that the composite consumption initialization operation condition meets the seventh requirement or not includes:
and judging whether the composite consumption initialization instruction is correct or not by the card, judging whether the corresponding composite consumption key exists or not by the card according to the composite consumption key index in the data field of the composite consumption initialization instruction, judging whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet or not by the card, if so, judging that the composite consumption initialization operation condition meets the seventh requirement, otherwise, judging that the composite consumption initialization operation condition does not meet the seventh requirement.
(6) When the command for accessing the electronic wallet data received by the card is a compound consumption file updating command, executing step F1;
step F1: the card judges whether the composite consumption file updating operation condition meets the eighth requirement, if so, the step F2 is executed, otherwise, an error is reported, and the operation is ended;
in this embodiment, step F1 specifically includes: and judging whether a preset composite transaction record file of the electronic wallet exists or not by the card according to the short file identifier in the composite consumption file updating instruction, judging whether a corresponding record in the composite transaction file of the electronic wallet exists or not by the card according to the record identifier in the composite consumption file updating instruction, judging whether the record length in the composite consumption file updating instruction is correct or not by the card, if the three judgment results are yes, the composite consumption file updating operation condition meets the eighth requirement, and if not, the composite consumption file updating operation condition does not meet the eighth requirement.
Step F2: the card judges whether the corresponding electronic cash expansion application file exists according to the composite consumption file updating instruction, if so, the step F3 is executed, otherwise, the step F4 is executed;
step F3: the card updates the electronic cash information by using the recorded content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and waits for receiving an instruction sent by the upper computer;
step F4: and the card updates the balance of the electronic wallet by using the record content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and waits for receiving the instruction sent by the upper computer.
Step S3: and when the card judges that the condition for accessing the electronic cash data meets the requirement, the card processes the current electronic cash information according to the received instruction for accessing the electronic cash data and returns the processing result to the upper computer.
Specifically, in this embodiment, synchronizing the electronic wallet balance in the current electronic wallet data under the electronic wallet application with the electronic cash balance in the current electronic cash information under the electronic cash application for the card includes:
step P1: the card judges whether the balance of the electronic wallet changes according to the change identifier of the balance of the electronic wallet, if so, the step P2 is executed, otherwise, the step is continued;
step P2: the card updates the balance of the electronic cash by the balance of the electronic wallet, and clears the change identifier of the balance of the electronic wallet.
In this embodiment, the synchronization process may be performed before receiving the instruction, or may be performed after receiving the instruction, and if the synchronization process is performed before receiving the instruction, the file control information needs to be returned to the upper computer after the synchronization, and then the synchronization process waits for receiving the instruction issued by the upper computer;
in this embodiment, the instructions to access electronic cash data comprise: reading a recording instruction and a data modification instruction; synchronizing an electronic cash balance in current electronic cash information under an electronic cash application with an electronic wallet balance in current electronic wallet data under the card-using electronic wallet application, comprising:
and (I) when the data command for accessing the electronic wallet received by the card is a reading and recording command, the card judges whether the reading and recording operation condition meets a third requirement, if so, the card updates the electronic cash balance information according to the current actually available electronic cash balance and the transaction amount, sets an electronic cash information change mark, returns a successful response to the upper computer, waits for receiving the command sent by the upper computer, otherwise, reports an error, and ends.
Wherein, the card judges whether the record operating condition satisfies the third requirement, including:
step X1: the card judges whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the step X2 is executed, otherwise, an error is reported, and the operation is finished;
step X2: the card judges whether corresponding data in a corresponding file in the electronic cash application exists according to data on a third byte of the reading record instruction, if so, the corresponding data is taken as current data, and the step X3 is executed, otherwise, an error is reported, and the operation is finished;
step X3: the card judges whether the current safety state meets the condition, if so, the step X4 is executed, otherwise, the current data is returned to the upper computer to wait for receiving the instruction sent by the upper computer;
step X4: the card judges whether the current data is the last unread data of the file locator, if so, the read record operation condition meets the third requirement, otherwise, the step X5 is executed;
step X5: the card returns the current data to the upper computer and waits for receiving the instruction sent by the upper computer.
In this embodiment, in the process of operating the reading record instruction, the step between setting the electronic cash information change flag and returning a successful response to the upper computer further includes:
step W1: the card judges whether an instruction for updating the extended application record cache is received, if so, the step W3 is executed, otherwise, the step W2 is executed;
step W2: the card clears the flag bit set in the electronic cash application, returns the current data to the upper computer and waits for receiving the instruction sent by the upper computer;
step W3: and the card stores the data in the update extended application record cache instruction into a composite transaction record file of the electronic cash, clears a flag bit arranged in the electronic cash application, returns the current data to the upper computer and waits for receiving the instruction sent by the upper computer.
When the data access instruction received by the card is a data modification instruction, the card judges whether the data modification operation condition meets a fourth requirement, if so, the card updates the electronic cash balance by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change mark, returns a successful response to the upper computer, and waits for receiving an instruction sent by the upper computer; otherwise, error is reported and the process is finished.
Wherein, the card judges whether the operation condition of the modified data meets the fourth requirement, including:
and judging whether the data modification instruction is correct or not by the card, judging whether the label code in the data modification instruction is legal or not by the card, judging whether the length of the label value in the data modification instruction is correct or not by the card, judging whether the MAC value in the data domain of the data modification instruction is correct or not by the card, if the four judgment results are yes, the data modification operation condition meets the fourth requirement, and if not, the data modification operation condition does not meet the fourth requirement.
The specific operation of the card after judging that the operation condition of the modified data meets the fourth requirement is as follows:
step D1: the card judges whether the label in the data modification instruction is preset data, if so, the step D2 is executed, otherwise, the card waits for receiving an instruction sent by an upper computer;
step D2: and the card updates the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change identifier, returns a successful response to the upper computer, and waits for receiving an instruction sent by the upper computer.
Example two
An embodiment of the present invention provides a method for implementing information sharing between an electronic wallet application and an electronic cash application, as shown in fig. 2, fig. 3, and fig. 4, including:
step 200: the card waits for and receives an application selection instruction issued by an upper computer, when the application selection instruction is received, the card judges the application needing to be selected, if the application is an electronic wallet application, step 201 is executed, and if the application is an electronic cash application, step 301 is executed;
specifically, in the present embodiment, the selected application instruction conforms to the APDU format, where CLA is 0x00, and INS is 0xa 4; the card judges the application to be selected by selecting the application identifier of the data field in the application instruction, if the application identifier is consistent with the electronic wallet application identifier, the application to be selected is the electronic wallet application, and if the application identifier is consistent with the electronic cash application identifier, the application to be selected is the electronic cash application;
step 201: the card judges whether the electronic cash information changes, if so, step 202 is executed, otherwise, step 203 is executed;
specifically, in this embodiment, the card calls the first sharing interface, reads the electronic cash information change identifier, and sends the electronic cash information change identifier to the card through the return value, and the card determines whether the electronic cash information change identifier is set, if so, the electronic cash information changes, otherwise, the electronic cash information does not change;
in this embodiment, the electronic cash information includes: electronic cash balance, overdrawn electronic cash, electronic cash balance upper limit value, electronic cash overdrawn limit value and the like;
step 202: the card acquires the balance and the overdrawn amount of the electronic cash from the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change identifier of the electronic cash information, and executes step 203;
specifically, in this embodiment, the card calls the second sharing interface with the APDU object as a parameter, acquires the electronic cash balance and the overdrawn amount of the electronic cash and places the electronic cash balance and the overdrawn amount of the electronic cash in the cache area of the APDU object, and after the second sharing interface is called, the card acquires the electronic cash balance and the overdrawn amount from the cache area of the APDU object, and updates the electronic wallet balance and the overdrawn amount of the electronic wallet with the acquired electronic cash balance and the overdrawn amount of the electronic cash; calling a third sharing interface by the card, clearing the change identification of the electronic cash information, and returning the result of whether the operation is successful to the card through a return value;
the APDU object is a java object encapsulated by the java card virtual machine after receiving the APDU instruction, and a space with 260 bytes in the object can temporarily store data;
step 203: the card returns file control information to the upper computer, and step 204 is executed;
step 204: the card waits for and receives an operation instruction issued by an upper computer, the type of the operation instruction is judged when the operation instruction is received, if the operation instruction is a load initialization instruction, the step 205 is executed, and if the operation instruction is a load instruction, the step 209 is executed; if the command is a consume initialization command, go to step 214, and if the command is a consume command, go to step 218; if the command is a composite consumption initialization command, go to step 227; if the command is a compound consumption file update command, go to step 231;
specifically, in this embodiment, the load initialization instruction conforms to the APDU instruction format, for example, if INS is 0x50, P1 is 0x00, and P2 is 0x02 in the instruction is the load initialization instruction, the data field includes a load key index, a load amount, and an upper computer number; if INS in the instruction is 0x52, the instruction is a load instruction, and the data field comprises a load date, a load time and a MAC value; if INS 0x50, P1 0x01 and P2 0x02 in the command are consumption initialization commands, the data field comprises consumption key index, transaction amount and upper computer number; if INS in the command is 0x54, the command is a consumption command, and the data field comprises a transaction serial number, a transaction date, a transaction time and a MAC value; if INS 0x50, P1 0x03 and P2 0x02 in the command are composite consumption initialization commands, the data field packet composite consumption key index, transaction amount and upper computer number; if CLA (0 x 80) and INS (0 xdc) in the command are complex consumption file updating commands, the data field comprises record values;
step 205: the card judges whether the load initialization instruction is correct, if so, the step 206 is executed, otherwise, an error is reported, and the operation is finished;
in this embodiment, step 205 includes: the card specifically judges whether P1, P2 and Le in the load initialization command conform to a first set value, if so, the load initialization command is correct, otherwise, the load initialization command is incorrect; preferably, the first set value in this embodiment is 0x 000210;
step 206: the card judges whether the corresponding load key exists according to the load key index in the data field of the load initialization instruction, if so, step 207 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, the data field of the load initialization instruction includes a 6-byte upper computer number, a 1-byte load key index, and a 4-byte load amount;
step 207: the card judges whether the result of the sum of the load amount in the data field of the load initialization instruction and the balance of the electronic wallet exceeds the upper limit value of the balance of the electronic cash, if so, an error is reported, and if not, the step 208 is executed;
step 208: the card saves the earmark amount in the data field of the earmark initialization instruction, sets a first safety state, returns a 16-byte successful response to the upper computer and returns to the step 204;
specifically, in this embodiment, the setting of the first safety state includes: the card sets the safety state to a first numerical value;
step 209: the card judges whether the load instruction is correct, if so, the step 210 is executed, otherwise, an error is reported, and the operation is finished;
in this embodiment, step 209 includes: the card specifically judges whether CLA, P1, P2, Lc and Le in the load instruction accord with a second set value, if so, the load instruction is correct, otherwise, the load instruction is incorrect; preferably, the second set value in this embodiment is 0x8000000b 04;
step 210: the card judges whether the current safety state is a first numerical value, if so, step 211 is executed, otherwise, an error is reported, and the operation is finished;
step 211: the card judges whether the MAC value in the data field of the load instruction is correct, if so, the step 212 is executed, otherwise, an error is reported, and the operation is finished;
step 212: the card judges whether the transaction authentication code key exists, if so, step 213 is executed, otherwise, an error is reported, and the process is ended;
in the embodiment, the transaction authentication code key is written when the card is operated at the personalization station;
step 213: the card updates the balance of the electronic purse by the saved earmark, sets up a change identifier of the balance of the electronic purse, updates the overdrawn amount of the electronic cash by the overdrawn amount of the electronic purse, returns a success response to the upper computer, and returns to the step 204;
specifically, in this embodiment, the card calls the fourth sharing interface with the electronic wallet balance as a parameter, updates the electronic wallet balance with the result of adding the earmark amount to the electronic wallet balance, sets an electronic wallet balance change identifier (the electronic wallet balance change identifier is used to notify that the electronic cash application sharing balance has changed), returns an operation result to the card through a return value of the fourth sharing interface, and the operation result is operation success or operation failure; the card puts the overdrawn amount of the electronic wallet into an APDU object cache region as a parameter to call a fifth sharing interface, and obtains the overdrawn amount of the electronic wallet from the parameter and updates the overdrawn amount of the electronic cash with the overdrawn amount of the electronic wallet;
step 214: the card judges whether the consumption initialization instruction is correct, if so, the step 215 is executed, otherwise, an error is reported, and the process is ended;
specifically, in this embodiment, the card specifically determines whether the length of the CLA and Lc in the consumption initialization instruction and the data in the data field meet a third set value, if so, the consumption initialization instruction is correct, otherwise, the consumption initialization instruction is incorrect; preferably, the third set point is 0x800b 0 f;
step 215: the card judges whether the corresponding consumption key exists according to the consumption key index in the data field of the consumption initialization instruction, if so, the step 216 is executed, otherwise, an error is reported, and the process is finished;
specifically, in this embodiment, the data field of the consumption initialization instruction includes a 6-byte upper computer number, a 1-byte consumption key index, and a 4-byte consumption amount;
step 216: the card judges whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet, if so, an error is reported, and if not, the step 217 is executed;
step 217: the card sets a second safety state, returns a successful response of 15 bytes to the upper computer and returns to the step 204;
specifically, in this embodiment, the card setting the second security state includes: the card sets the current safety state as a second numerical value; specifically, the data returned by the card to the upper computer in the step includes: the stored self balance, the off-line transaction serial number, the pseudo-random number and the like;
step 218: the card judges whether the consumption instruction is correct, if so, step 219 is executed, otherwise, an error is reported, and the process is ended;
in this embodiment, step 218 includes: the card specifically judges whether CLA, P1, P2, Lc and Le in the consumption instruction accord with a fourth set value, if so, the consumption instruction is correct, otherwise, the consumption instruction is incorrect; preferably, the fourth setting value in the present embodiment is 0x 8001000 f 08;
step 219: the card judges whether the current safety state is the second safety state or the third safety state, if so, the step 220 is executed, otherwise, an error is reported, and the operation is finished;
specifically, step 219 includes: the card judges whether the current safety state is a second numerical value or a third numerical value;
step 220: the card judges whether the MAC value in the data field of the consumption instruction is correct, if so, the step 221 is executed, otherwise, an error is reported, and the process is finished;
step 221: the card judges whether the transaction authentication code key exists, if so, step 222 is executed, otherwise, an error is reported, and the process is ended;
in this embodiment, the transaction authentication code key is written in by the card during personalization operation;
step 222: the card updates the stored balance of the electronic wallet according to the stored consumption amount, sets an electronic wallet balance change identifier, and updates the overdrawn amount of the electronic cash with the overdrawn amount of the electronic wallet;
specifically, in this embodiment, the card calls the consumption amount as a parameter to the fourth sharing interface, updates the electronic wallet balance with a result of subtracting the consumption amount from the electronic wallet balance, sets an electronic wallet balance change identifier (the electronic wallet balance change identifier is used to notify that the electronic cash application sharing balance has changed), and returns an operation result to the card through a return value of the fourth sharing interface, where the operation result is operation success or operation failure; the card puts the overdrawn amount of the electronic wallet into an APDU object cache region as a parameter to call a fifth sharing interface, and obtains the overdrawn amount of the electronic wallet from the parameter and updates the overdrawn amount of the electronic cash with the overdrawn amount of the electronic wallet;
step 223: the card judges whether the current safety state is the third safety state, if so, step 224 is executed, otherwise, a successful response is returned to the upper computer, and the step 204 is returned;
specifically, in this embodiment, the card determines whether the current security state is the third numerical value, if so, step 224 is executed, otherwise, a successful response is returned to the upper computer, and the step 204 is returned;
step 224: the card judges whether the electronic cash application has a corresponding extended application file, if so, step 225 is executed, otherwise, step 226 is executed;
specifically, in this embodiment, the card determines whether the electronic cash application has a corresponding extended application file through the first variable of the sixth sharing interface;
step 225: the card updates the data in the composite application record cache to the record file of the extended application of the electronic cash, returns a success response to the upper computer, and returns to the step 204;
specifically, in this embodiment, the card puts the data in the composite application record cache into the APDU object cache region as the first parameter, calls the seventh sharing interface with the short file identifier as the second parameter, and puts the first parameter into the record file of the extended application of the electronic cash according to the second parameter;
step 226: the card updates the data in the composite application record cache to the composite transaction record file of the electronic wallet, returns a success response to the upper computer, and returns to step 204;
step 227: the card determines whether the composite consumption initialization command is correct, if so, step 228 is executed, otherwise, an error is reported, and the process is ended;
specifically, in this embodiment, the composite consumption initialization instruction conforms to the APDU instruction format, and the card specifically determines whether P1, P2, and Le in the APDU instruction conform to the fifth setting value, if so, the composite consumption initialization instruction is correct, otherwise, the composite consumption initialization instruction is incorrect; preferably, the fifth set point is 0x80 b 0 f;
step 228: the card judges whether the corresponding composite consumption key exists according to the composite consumption key index in the data field of the composite consumption initialization instruction, if so, the step 229 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, the data field of the composite consumption initialization instruction includes a 6-byte upper computer number, a 1-byte composite consumption key index, and a 4-byte consumption amount;
step 229: the card judges whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet, if so, an error is reported, and the process is ended, otherwise, the step 230 is executed;
step 230: the card sets a third safety state, returns a successful response of 15 bytes to the upper computer and returns to the step 204;
specifically, in this embodiment, the card setting the third security state includes: the card sets the current safety state as a third numerical value; the data returned to the upper computer comprises: e-wallet balance, offline transaction serial number, pseudo-random number, etc.;
step 231: the card judges whether a preset composite transaction record file of the electronic wallet exists according to the short file identifier in the composite consumption file updating instruction, if so, the step 232 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in the present embodiment, the value at P2 in the compound consumption file update instruction contains a short file identifier;
step 232: judging whether the corresponding record in the composite transaction file of the electronic wallet exists according to the record identifier in the composite consumption file updating instruction by the card, if so, executing the step 233, otherwise, reporting an error, and ending;
specifically, in this embodiment, the value at P1 in the compound consumption file update instruction is a record identifier;
step 233: the card judges whether the record length in the composite consumption file updating instruction is correct, if so, the step 234 is executed, otherwise, an error is reported, and the process is ended;
specifically, in the present embodiment, the value of Lc in the composite consumption file update instruction represents the record length;
step 234: the card judges whether the electronic cash application has the corresponding electronic cash extension application file, if so, the step 235 is executed, otherwise, the step 236 is executed;
specifically, in this embodiment, the card determines whether the electronic cash application has the corresponding electronic cash extended application file through the eighth sharing interface;
step 235: the card updates the electronic cash information by using the recorded content in the data field of the composite consumption file updating instruction, returns a success response to the upper computer, and returns to the step 204;
step 236: the card updates the balance of the electronic wallet by using the recorded content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer, and returns to the step 204;
step 301: the card judges whether the balance of the electronic wallet changes, if so, the step 302 is executed, otherwise, the step 303 is executed;
specifically, in this embodiment, the card obtains, through the shared interface, an electronic wallet balance change identifier in the electronic wallet application, and if the wallet balance change identifier is set, it indicates that the balance of the electronic wallet has been modified, and if the wallet balance change identifier is not set, it indicates that the balance of the electronic wallet has not been modified;
step 302: the card updates the electronic cash balance by the balance of the electronic wallet, and clears the change identifier of the balance of the electronic wallet, and step 303 is executed;
step 303: the card returns file control information to the upper computer, and step 304 is executed;
in this embodiment, step 303 further includes: the card clears the transaction start identifier; the transaction start identifier is set in a GPO instruction (acquisition processing option instruction), and indicates that only one GPO instruction can be sent in one transaction flow, and the transaction flow is restarted by clearing the identifier when an application is selected;
step 304: the card waits for and receives an operation instruction sent by an upper computer, and when the operation instruction is received, the type of the operation instruction is judged, if the operation instruction is a record reading instruction, the step 305 is executed, and if the operation instruction is a data modification instruction, the step 314 is executed;
specifically, in the embodiment, if the value of CLA INS is 0x00 b2, the type of the instruction is a read record instruction, and if the value of INS is 0xda, the type of the instruction is a modify data instruction;
step 305: the card judges whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, step 306 is executed, otherwise, an error is reported, and the operation is finished;
in this embodiment, the read record instruction conforms to the APDU instruction format;
step 306: the card judges whether corresponding data in a corresponding file in the electronic cash application exists according to data on a third byte of the reading record instruction, if so, the corresponding data is taken as current data, and step 307 is executed, otherwise, an error is reported, and the operation is finished;
step 307: the card judges whether the current safety state meets the condition, if so, the step 308 is executed, otherwise, the current data is returned to the upper computer, and the step 304 is returned;
specifically, the conditions satisfied in this embodiment are: the card executes the instruction of acquiring the processing options and returns offline approval information;
step 308: the card judges whether the current data is the last unread data of the file locator, if so, step 310 is executed, otherwise step 309 is executed;
in this embodiment, the file locator (AFL) is written to by the card when personalization is performed;
step 309: returning the current data to the upper computer by the card, and returning to the step 304;
in this embodiment, step 309 further includes: setting a read record mark for the card to indicate that the current data is read;
step 310: the card updates the balance information of the electronic cash according to the balance of the electronic cash and the transaction amount which are actually available at present, and sets an electronic cash information change identifier;
specifically, in this embodiment, if the electronic cash balance is not less than the transaction amount, step 310 includes: new electronic cash balance-old electronic cash balance-transaction amount; if the electronic cash balance is less than the transaction amount, step 310 includes: if the electronic cash balance is equal to 0, the new deducted amount is equal to the old deducted amount + (transaction amount-electronic cash balance);
step 311: the card judges whether an instruction for updating the extended application record cache is received, if so, step 313 is executed, otherwise, step 312 is executed;
specifically, in this embodiment, the card sets the extended application transaction identifier after performing an operation when receiving the instruction to update the extended application record cache, and in step 311, the card determines whether the extended application transaction flag is set, and if so, the extended application transaction flag is received, otherwise, the extended application transaction flag is not received;
step 312: the card clears the flag bit set in the electronic cash application, returns the current data to the upper computer, and returns to step 304;
step 313: the card stores the data in the update extended application record cache instruction into a composite transaction record file of the electronic cash, clears a flag bit set in the electronic cash application, returns the current data to the upper computer, and returns to the step 304;
step 314: the card judges whether the data modification instruction is correct, if so, the step 315 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, the card checks whether the CLA in the modified data instruction meets the first preset value, if so, step 315 is executed, otherwise, an error is reported, and the process is ended; preferably, the first preset value is 0x 04;
step 315: the card judges whether the label code in the data modification instruction is legal or not, if so, step 316 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, step 315 specifically includes: the card judges whether the code of the label in the data modification instruction accords with the preset regulation, if so, the label is legal, otherwise, the label is illegal;
step 316: the card judges whether the length of the label value in the data modification instruction is correct, if so, the step 317 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, the card determines whether the Lc value in the modified data instruction is the same as a preset value, if so, step 317 is executed, otherwise, an error is reported, and the process is ended; preferably, the preset value is 0x 06;
step 317: the card judges whether the MAC in the data field of the data modification instruction is correct, if so, step 318 is executed, otherwise, an error is reported, and the operation is finished;
step 318: the card judges whether the label is preset data, if so, the step 319 is executed, otherwise, the step 304 is returned to;
specifically, in this embodiment, the preset data is 9F79 (representing the electronic cash amount) or DF62 (representing the electronic cash sectional deduction and deduction limit);
step 319: the card updates the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change identifier, returns a success response to the upper computer, and returns to the step 304.
In the embodiment, the card is internally provided with an electronic wallet application, a smart card virtual machine and an electronic cash application; before calling the shared interface, the shared interface needs to be acquired, and the implementation process of acquiring the shared interface comprises the following steps:
step A1: the electronic wallet application acquires the stored shared object application AID and service application parameters;
in this embodiment, the service application parameters are preset, and each parameter corresponds to a different shared object; if the service application has special requirements for the service application parameters, then data meeting the requirements may be specified, such as: service application designation 3 represents the shared object of service a, so it is sufficient to write 3 directly when calling the shared object of service a here;
step A2: the electronic wallet application calls an API of the card according to the acquired shared object application AID and the service application parameters to acquire a shared object of the service application;
step A3: the smart card virtual machine searches a corresponding service application index in an application list in the card according to the acquired shared object application AID;
step A4: the smart card virtual machine judges whether the corresponding service application exists according to the service application index, if so, the step A5 is executed, otherwise, the smart card virtual machine organizes a return result and executes the step A9;
step A5: the smart card virtual machine acquires a corresponding context application AID according to the current context, and acquires an object reference of the service application according to the application index;
step A6: the smart card virtual machine calls and acquires a shared object function according to the context application AID and the service application parameters;
step A7: the electronic cash application checks the authority of the corresponding application according to the context application AID and returns a corresponding shared object to the smart card virtual machine according to the service application parameters;
specifically, in this embodiment, the corresponding application authority includes: the service application may have special requirements for its client application, for example, the a service can only use the application with AID B, and at this time, it needs to check whether the AID of the client application is B;
step A8: the smart card virtual machine organizes a return result according to the received shared object;
step A9: the smart card virtual machine returns a return result to the electronic wallet application;
step A10: and the electronic wallet application receives the return result and judges whether the return result contains the shared object, if so, the shared object is obtained, and if not, the operation is finished.
EXAMPLE III
A third embodiment of the present invention provides a method for implementing information sharing among different applications, as shown in fig. 5, 6, and 7, including:
step 501: the card waits for and receives an application selection instruction issued by an upper computer, and when the application selection instruction is received, the card judges the application needing to be selected, if the application is an electronic wallet application, the step 502 is executed, and if the application is an electronic cash application, the step 529 is executed;
step 502: the card waits for and receives an operation instruction sent by an upper computer, judges the type of the operation instruction when the operation instruction is received, and executes step 503 if the operation instruction is a load instruction; if the command is a consume command, go to step 507; if the command is a load initialization command, step 511 is executed, if the command is a consume initialization command, step 515 is executed, if the command is a compound consume initialization command, step 519 is executed, if the command is a compound consume file update command, step 523 is executed;
step 503: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, the step 504 is executed, otherwise, the step 505 is executed;
step 504: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information and executes the step 505;
step 505: the card judges whether the load operation condition meets the first requirement, if so, the step 506 is executed, otherwise, an error is reported, and the operation is finished;
in this embodiment, step 505 includes: the card judges whether the loading instruction is correct or not, whether the current security state is the first security state or not, whether the MAC value in the data field of the loading instruction is correct or not is judged by the card, whether the transaction authentication code key exists or not is judged by the card, the four judgments are not in sequence, if the four judgment results are yes, the loading operation condition meets a first requirement, and otherwise, the loading operation condition does not meet the first requirement.
Step 506: the card updates the balance of the electronic purse by the saved earmark amount, updates the overdrawn amount of the electronic cash by the overdrawn amount of the electronic purse, sets a change identifier of the balance of the electronic purse, returns a success response to the upper computer, and returns to the step 502;
step 507: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, step 508 is executed, otherwise, step 509 is executed;
step 508: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information, and executes step 509;
step 509: the card judges whether the consumption operation condition meets the second requirement, if so, the step 510 is executed, otherwise, an error is reported, and the process is ended;
in this embodiment, step 509 includes: the card judges whether the consumption instruction is correct or not, the card judges whether the current safety state is the second safety state or the third safety state or not, the card judges whether the MAC value in the data field of the consumption instruction is correct or not, the card judges whether the transaction authentication code key exists or not, the four judgments are not in sequence, if the four judgments are yes, the consumption operation condition meets the second requirement, and if the consumption operation condition does not meet the second requirement.
Step 510: the card updates the balance of the electronic purse according to the saved consumption amount, updates the overdrawn amount of the electronic cash by the overdrawn amount of the electronic purse, sets a change identifier of the balance of the electronic purse, returns a success response to the upper computer, and returns to the step 502;
specifically, in this embodiment, before returning a successful response in step 510, the method further includes:
step H1: the card judges whether the current safety state is the third safety state, if yes, step H2 is executed, otherwise, step 502 is returned to;
step H2: the card judges whether the electronic cash application has a corresponding extended application record file, if so, the step H3 is executed, otherwise, the step H4 is executed;
step H3: the card updates the data in the composite application record cache to an extended application record file of the electronic cash, then continues to return a successful response to the upper computer, and returns to the step 502;
step H4: the card updates the data in the composite application record cache to the composite transaction record file of the electronic wallet, then continues to return a success response to the upper computer, and returns to step 502.
Step 511: the card judges whether the electronic cash information changes according to the electronic cash information change identification, if so, the step 512 is executed, otherwise, the step 513 is executed;
step 512: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information, and executes step 513;
step 513: the card judges whether the load initialization operation condition meets the fifth requirement, if so, step 514 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, step 513 includes: the card judges whether the load initialization instruction is correct or not, whether the corresponding load key exists or not is judged by the card according to the load key index in the data field of the load initialization instruction, whether the load amount in the data field of the load initialization instruction plus the current balance of the electronic wallet exceeds the upper limit value of the balance of the electronic cash or not is judged by the card, the three judgments have no three back sequences, if the three judgments are yes, the load initialization operation condition meets the fifth requirement, and otherwise, the load initialization operation condition does not meet the fifth requirement.
Step 514: the card saves the earmark amount in the data field of the earmark initialization instruction, sets a first safety state, returns a success response to the upper computer, and returns to the step 502.
Step 515: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, step 516 is executed, otherwise, step 517 is executed;
step 516: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information and executes the step 517;
517: the card judges whether the consumption initialization operation condition meets the sixth requirement, if so, the step 518 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, step 517 includes: the card judges whether the consumption initialization instruction is correct or not, the card judges whether the corresponding consumption key exists or not according to the consumption key index in the data field of the consumption initialization instruction, the card judges whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet or not, the three judgments are not in sequence, if the three judgments are yes, the consumption initialization operation condition meets the sixth requirement, and otherwise, the consumption initialization operation condition does not meet the sixth requirement.
Step 518: the card sets a second security state and returns a successful response to the upper computer, and the step 502 is returned.
Step 519: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, step 520 is executed, otherwise, step 521 is executed;
step 520: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information and executes the step 521;
step 521: the card judges whether the composite consumption initialization operation condition meets the seventh requirement, if so, the step 522 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, step 521 includes: the card judges whether the composite consumption initialization instruction is correct or not, the card judges whether the corresponding composite consumption key exists or not according to the composite consumption key index in the data field of the composite consumption initialization instruction, the card judges whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet or not, the three judgments are not in sequence, if the three judgments are yes, the composite consumption initialization operation condition meets a seventh requirement, and otherwise, the composite consumption initialization operation condition does not meet the seventh requirement.
Step 522: the card sets a third security state and returns a successful response to the upper computer, and the step 502 is returned.
Step 523: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, the step 524 is executed, and if not, the step 525 is executed;
step 524: the card acquires the balance and overdrawn amount of the electronic cash in the electronic cash information, updates the balance and overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information and executes step 525;
step 525: the card judges whether the updating operation condition of the composite consumption file meets the eighth requirement, if so, step 526 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, step 525 includes: and judging whether a preset composite transaction record file of the electronic wallet exists or not by the card according to the short file identifier in the composite consumption file updating instruction, judging whether a corresponding record in the composite transaction file of the electronic wallet exists or not by the card according to the record identifier in the composite consumption file updating instruction, judging whether the record length in the composite consumption file updating instruction is correct or not by the card, if the three judgment results are yes, the composite consumption file updating operation condition meets the eighth requirement, and otherwise, the composite consumption file updating operation condition does not meet the eighth requirement.
Step 526: the card judges whether the corresponding expansion application file of the electronic cash exists according to the composite consumption file updating instruction, if so, the step 527 is executed, and if not, the step 528 is executed;
step 527: the card updates the electronic cash information by using the recorded content in the data field of the composite consumption file updating instruction, returns a success response to the upper computer and returns to the step 502;
step 528: the card updates the balance of the electronic purse by using the recorded content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and returns to the step 502.
Step 529: the card waits for and receives an operation instruction sent by an upper computer, judges the type of the operation instruction when the operation instruction is received, if the operation instruction is a read record instruction, the step 530 is executed, and if the operation instruction is a data modification instruction, the step 534 is executed;
step 530: the card judges whether the balance of the electronic wallet changes according to the change identification of the balance of the electronic wallet, if so, step 531 is executed, otherwise, step 532 is executed;
step 531: updating the electronic cash balance of the card by using the balance of the electronic wallet, clearing the change identifier of the balance of the electronic wallet, and executing the step 532;
step 532: the card judges whether the read record operation condition meets the third requirement, if so, step 533 is executed, otherwise, an error is reported, and the operation is finished;
specifically, in this embodiment, step 532 includes:
step 532-1: the card judges whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the step 532-2 is executed, otherwise, an error is reported, and the operation is finished;
step 532-2: the card judges whether corresponding data in a corresponding file in the electronic cash application exists according to data on a third byte of the reading record instruction, if so, the corresponding data is taken as current data, and the step 532-3 is executed, otherwise, an error is reported, and the operation is finished;
step 532-3: the card judges whether the current safety state meets the condition, if so, the step 532-4 is executed, otherwise, the current data is returned to the upper computer, and the step 529 is returned;
step 532-4: the card judges whether the current data is the last unread data of the file locator, if so, the step 533 is executed, otherwise, the step 532-5 is executed;
step 532-5: the card returns the current data to the upper computer, and the step 529 is returned.
Wherein, the judgment of the step 532-1, the step 532-2, the step 532-3 and the step 532-4 has no sequence and can be changed randomly;
step 533: the card updates the electronic cash balance information according to the current actually available electronic cash balance and the transaction amount, sets an electronic cash information change mark, returns a successful response to the upper computer, and returns to the step 529;
in this embodiment, before returning a successful response to the upper computer in step 533, the method further includes:
step L1: the card judges whether an instruction for updating the extended application record cache is received, if so, the step L3 is executed, otherwise, the step L2 is executed;
step L2: the card clears the flag bit set in the electronic cash application, returns the current data to the upper computer, and returns to the step 529;
step L3: and the card stores the data in the update extended application record cache instruction into the composite transaction record file of the electronic cash, clears the flag bit arranged in the electronic cash application, then continues to return the current data to the upper computer, and returns to the step 529.
Step 534: the card judges whether the balance of the electronic wallet changes according to the change identification of the balance of the electronic wallet, if so, step 535 is executed, otherwise, step 536 is executed;
step 535: the card updates the electronic cash balance with the electronic wallet balance, clears the electronic wallet balance change identifier, and executes step 536;
step 536: the card judges whether the operation condition for modifying the data meets the fourth requirement, if so, step 537 is executed, otherwise, an error is reported, and the process is ended;
in this embodiment, step 537 comprises: the card judges whether the data modification instruction is correct or not, whether the label code in the data modification instruction is legal or not, whether the length of the label value in the data modification instruction is correct or not is judged by the card, whether the MAC value in the data domain of the data modification instruction is correct or not is judged by the card, the four judgments are not in sequence, if the four judgment results are yes, the data modification operation condition meets the fourth requirement, and otherwise, the data modification operation condition does not meet the fourth requirement.
Step 537: and the card updates the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change mark, returns a success response to the upper computer and returns to the step 529.
Specifically, in this embodiment, step 537 includes:
step 537-1: the card judges whether the label in the data modification instruction is preset data, if so, the step 537-2 is executed, otherwise, the step 529 is returned to;
step 537-2: the card updates the balance of the electronic cash by using the amount in the data field of the modification data instruction, sets an electronic cash information change identifier, returns a success response to the upper computer, and returns to the step P29.
In this embodiment, after the card receives each instruction, the operation of determining whether the electronic cash information changes may be performed at any step before updating the balance of the electronic wallet, and the operation of determining whether the amount of money of the electronic wallet changes may be performed at any step before updating the balance of the electronic cash in the same manner, which is not described herein again.
Example four
An embodiment of the present invention provides an apparatus for implementing information sharing between different applications, as shown in fig. 8, including:
a receiving module 801, configured to wait for and receive an instruction sent by an upper computer;
a first determining module 802, configured to determine, when the receiving module receives an application selection instruction, an application that needs to be selected, if the application is an electronic wallet application, trigger the first synchronizing module 803 to operate, and if the application is an electronic cash application, trigger the second synchronizing module 805 to operate;
a first synchronization module 803 for synchronizing the current electronic wallet application current electronic wallet data with the current electronic cash information under the electronic cash application;
in this embodiment, the first synchronization module 803 includes:
the first judging unit is used for judging whether the electronic cash information changes according to the electronic cash information change identifier, if so, the first updating and clearing unit is triggered to work, and if not, the first processing module 804 is triggered to work;
and the first updating and clearing unit is used for acquiring the balance and the overdrawn amount of the electronic cash in the electronic cash information, updating the balance and the overdrawn amount of the electronic wallet, clearing the change mark of the electronic cash information and triggering the first processing module 804 to work.
The first processing module 804 is used for processing the current electronic wallet data according to the received instruction for accessing the electronic wallet data when the condition for accessing the electronic wallet data meets the requirement;
a second synchronization module 805 configured to synchronize an electronic cash balance in the current electronic cash information under the electronic cash application with an electronic wallet balance in the current electronic wallet data under the electronic wallet application;
specifically, in this embodiment, the second synchronization module 805 includes:
an eleventh judging unit, configured to judge, according to the electronic wallet balance change identifier, whether the electronic wallet balance has changed, if yes, trigger the second update clearing unit to operate, and otherwise trigger the second processing module 806 to operate;
and a second updating and clearing unit, configured to update the electronic cash balance with the electronic wallet balance, clear the electronic wallet balance change identifier, and trigger the second processing module 806 to work.
The second processing module 806 is configured to, when a condition for accessing the electronic cash data meets a requirement, process the current electronic cash information according to the received instruction for accessing the electronic cash data;
a returning module 807, configured to return the processing result of the first processing module 804 or the second processing module 806 to the upper computer.
In this embodiment, the instruction to access the data of the electronic wallet includes: if the load instruction, the consume instruction, the load initialization instruction, the consume initialization instruction, the compound consume initialization instruction, and the compound consume file update instruction are loaded, the corresponding first processing module 804 includes different units to process, which is specifically as follows:
(1) a first processing module 804, comprising:
the second judgment unit is used for judging whether the load operation condition meets the first requirement or not when the receiving module receives the load instruction, if so, the first updating setting unit is triggered to work, and otherwise, the error reporting unit is triggered to work;
in this embodiment, the second determining unit is specifically configured to determine whether the load instruction is correct, determine whether the current security state is the first security state, determine whether the MAC value in the data field of the load instruction is correct, and determine whether the transaction authentication code key exists, where the load operation condition satisfies the first requirement if all the four determination results are yes, and otherwise, the load operation condition does not satisfy the first requirement.
The first updating and setting unit is used for updating the balance of the electronic purse by using the saved earmark amount, updating the overdrawn amount of electronic cash by using the overdrawn amount of the electronic purse and setting a balance change identifier of the electronic purse;
the returning module 807 is further configured to return a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
(2) A first processing module 804, comprising:
the third judging unit is used for judging whether the consumption operating condition meets a second requirement or not when the receiving module receives the consumption instruction, if so, the second updating setting unit is triggered to work, and otherwise, the error reporting unit is triggered to work;
in this embodiment, the third determining unit is specifically configured to determine whether the consumption instruction is correct, determine whether the current security state is the second security state or the third security state, determine whether the MAC value in the data field of the consumption instruction is correct, and determine whether the transaction authentication code key exists, where if all of the four values are determined to be yes, the consumption operating condition satisfies the second requirement, and otherwise, the consumption operating condition does not satisfy the second requirement.
The second updating and setting unit is used for updating the balance of the electronic purse according to the saved consumption amount, updating the overdrawn amount of electronic cash by the overdrawn amount of the electronic purse and setting a balance change identifier of the electronic purse;
the returning module 807 is further configured to return a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
In this embodiment, the first processing module 804 further includes:
the fourth judging unit is used for judging whether the current safety state is the third safety state, if so, the fifth judging unit is triggered to work, and otherwise, the receiving module 801 is triggered to work;
the fifth judging unit is used for judging whether the corresponding extended application record file exists in the electronic cash application, if so, the first updating unit is triggered to work, and otherwise, the second updating unit is triggered to work;
the first updating unit is used for updating the data in the composite application record cache into an extended application record file of the electronic cash;
and the second updating unit is used for updating the data in the composite application record cache into the composite transaction record file of the electronic wallet.
(3) A first processing module 804, comprising:
the sixth judging unit is used for judging whether the load initialization operating condition meets the fifth requirement or not when the receiving module receives the load initialization instruction, if so, triggering the first storage setting unit to work, and otherwise, triggering the error reporting unit to work;
in this embodiment, the sixth determining unit is specifically configured to determine whether the load initialization instruction is correct, determine whether a corresponding load key exists according to a load key index in a data field of the load initialization instruction, determine whether a result of adding the load amount in the data field of the load initialization instruction to the current balance of the electronic wallet exceeds an upper limit value of the balance of the electronic cash, if all the three determination results are yes, the load initialization operating condition satisfies a fifth requirement, and otherwise, the load initialization operating condition does not satisfy the fifth requirement.
The first saving setting unit is used for saving the load amount in the data field of the load initialization instruction and setting a first safety state;
the returning module 807 is further configured to return a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
(4) A first processing module 804, comprising:
the seventh judging unit is used for judging whether the consumption initialization operating condition meets the sixth requirement or not when the receiving module receives the consumption initialization instruction, if so, triggering the first setting unit to work, and otherwise, triggering the error reporting unit to work;
in this embodiment, the seventh determining unit is specifically configured to determine whether the consumption initialization instruction is correct, determine whether the corresponding consumption key exists according to the consumption key index in the data field of the consumption initialization instruction, and determine whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet, where if all of the three determination results are yes, the consumption initialization operating condition satisfies the sixth requirement, and otherwise, the consumption initialization operating condition does not satisfy the sixth requirement.
A first setting unit for setting a second safety state;
the returning module 807 is further configured to return a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
(5) A first processing module 804, comprising:
the eighth judging unit is used for judging whether the composite consumption initialization operating condition meets a seventh requirement or not when the receiving module receives the composite consumption initialization instruction, if so, triggering the second setting unit to work, and otherwise, triggering the error reporting unit to work;
in this embodiment, the eighth determining unit is specifically configured to determine whether the composite consumption initialization instruction is correct, determine whether the corresponding composite consumption key exists according to the composite consumption key index in the data field of the composite consumption initialization instruction, and determine whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet, where if all of the three determination results are yes, the composite consumption initialization operating condition satisfies the seventh requirement, and otherwise, the composite consumption initialization operating condition does not satisfy the seventh requirement.
A second setting unit for setting a third safety state;
the returning module 807 is further configured to return a successful response to the upper computer;
the error reporting unit is also used for reporting errors.
(6) A first processing module 804, comprising:
the ninth judging unit is used for judging whether the updating operation condition of the compound consumption file meets the eighth requirement or not when the receiving module receives the updating instruction of the compound consumption file, if so, triggering the tenth judging unit to work, and otherwise, triggering the error reporting unit to work;
in this embodiment, the ninth determining unit is specifically configured to determine whether a preset composite transaction record file of the electronic wallet exists according to the short file identifier in the composite consumption file update instruction, determine whether a corresponding record in the composite transaction file of the electronic wallet exists according to the record identifier in the composite consumption file update instruction, and determine whether the record length in the composite consumption file update instruction is correct, where if all of the three determination results are yes, the composite consumption file update operation condition satisfies the eighth requirement, and otherwise, the composite consumption file update operation condition does not satisfy the eighth requirement.
An error reporting unit for reporting an error;
a tenth judging unit, configured to judge whether the corresponding extended application file of the electronic cash exists according to the composite consumption file update instruction, if yes, trigger a third updating unit to operate, and otherwise trigger a fourth updating unit to operate;
a third updating unit for updating the electronic cash information with the record content in the data field of the compound consumption file updating instruction;
a fourth updating unit for updating the balance of the electronic wallet with the record content in the data field of the compound consumption file updating instruction;
the returning module 807 is also used for returning a success response to the upper computer.
In this embodiment, the instructions to access electronic cash data comprise: when the record command and the data modification command are read, the corresponding second processing module 806 includes different units to process, which is as follows:
the (first) second processing module 806 includes:
a twelfth judging unit, configured to, when the receiving module receives the read record instruction, judge whether the read record operation condition meets a third requirement, if yes, trigger the third update setting unit to operate, and otherwise trigger the error reporting unit to operate;
specifically, in this embodiment, the twelfth judging unit includes:
the first judging subunit is used for judging whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the second judging subunit is triggered to work, and otherwise, the error reporting unit is triggered to work;
the second judging subunit is used for judging whether corresponding data in a corresponding file in the electronic cash application exists according to data on a third byte of the reading record instruction, if so, the corresponding data is taken as current data, and the third judging subunit is triggered to work, otherwise, the error reporting unit is triggered to work;
a third judging subunit, configured to judge whether the current security state meets the condition, if yes, trigger the fourth judging subunit to operate, and otherwise trigger the returning module 807 to operate;
the returning module 807 is used for returning the current data to the upper computer;
and a fourth judging subunit, configured to judge whether the current data is the last unread data of the file locator, if so, trigger the third update setting unit to operate, and otherwise trigger the returning module 807 to operate.
The third updating and setting unit is used for updating the electronic cash balance information according to the currently and actually available electronic cash balance and the transaction amount and setting an electronic cash information change mark;
the return module is also used for returning a successful response to the upper computer;
the error reporting unit is used for reporting errors.
In this embodiment, the second processing module 806 further includes:
a thirteenth judging unit, configured to judge whether an update extended application record caching instruction is received, if yes, trigger a third update clearing unit to work, and otherwise, trigger the first clearing module unit;
the first clearing unit is used for clearing a flag bit arranged inside the electronic cash application;
the returning module 807 is further configured to return the current data to the upper computer;
and the third updating and clearing unit is used for saving the data in the updating and expanding application record caching instruction into the composite transaction record file of the electronic cash and clearing the flag bit set inside the electronic cash application.
(ii) a second processing module 806 comprising:
a fourteenth judging unit, configured to, when the receiving module receives the data modification instruction, judge whether the data modification operation condition meets a fourth requirement, if yes, trigger the fourth update setting unit to operate, and otherwise trigger the error reporting unit to operate;
specifically, in this embodiment, the fourteenth determining unit is specifically configured to determine whether the modified data instruction is correct, determine whether a tag code in the modified data instruction is legal, determine whether a length of a tag value in the modified data instruction is correct, and determine whether a MAC value in a data field of the modified data instruction is correct, where if all the four determination results are yes, the modified data operation condition satisfies the fourth requirement, and otherwise, the modified data operation condition does not satisfy the fourth requirement.
A fourth updating setting unit, configured to update the balance of the electronic cash using the amount of money in the data field of the modified data instruction, set an electronic cash information change flag, and trigger the returning module 807 to operate;
in this embodiment, the fourth update setting unit includes:
a fifteenth judging subunit, configured to judge whether a tag in the modified data instruction is preset data, if so, trigger the fifth update setting unit to operate, and otherwise trigger the receiving module 801 to operate;
and a fifth update setting subunit for updating the electronic cash balance using the amount of money in the data field of the modification data instruction and setting the electronic cash information change flag.
The returning module 807 is further configured to return a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (38)
1. A method for realizing information sharing among different applications is characterized by comprising the following steps:
step S1: the card waits for receiving an application selection instruction sent by an upper computer, judges an application needing to be selected when the application selection instruction is received, and executes the step S2 if the application is an electronic wallet application, and executes the step S3 if the application is an electronic cash application;
step S2: the current electronic cash information under the electronic cash application for the card synchronizes the current electronic wallet data of the electronic wallet application, and when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data and returns the processing result to the upper computer;
step S3: the electronic wallet balance in the current electronic wallet data applied to the card is synchronous with the electronic cash balance in the current electronic cash information applied to the card, and when the card judges that the condition for accessing the electronic cash data meets the requirement, the card processes the current electronic cash information according to the received instruction for accessing the electronic cash data and returns the processing result to the upper computer;
synchronizing, by the card, the electronic wallet application current electronic wallet data with current electronic cash information under an electronic cash application, comprising:
step A1: the card judges whether the electronic cash information changes according to the electronic cash information change identifier, if so, the step A2 is executed, otherwise, the step is continued;
step A2: the card acquires the balance and the overdrawn amount of the electronic cash in the electronic cash information, updates the balance and the overdrawn amount of the electronic wallet, clears the change mark of the electronic cash information and continues;
synchronizing the electronic wallet balance in the current electronic wallet data under the card-in-electronic wallet application with the electronic cash balance in the current electronic cash information under the electronic cash application, comprising:
step P1: the card judges whether the balance of the electronic wallet changes according to the change identification of the balance of the electronic wallet, if so, the step P2 is executed, otherwise, the step is continued;
step P2: the card updates the balance of the electronic cash by using the balance of the electronic wallet, and clears the change identifier of the balance of the electronic wallet;
when the card judges that the condition for accessing the electronic wallet data meets the requirement, the card processes the current electronic wallet data according to the received instruction for accessing the electronic wallet data, and the method comprises the following steps:
when the command for accessing the electronic wallet data received by the card is a compound consumption file updating command, executing step F1;
step F1: the card judges whether the updating operation condition of the compound consumption file meets the eighth requirement, if so, the step F2 is executed, otherwise, an error is reported, and the operation is finished;
step F2: the card judges whether the corresponding electronic cash expansion application file exists according to the composite consumption file updating instruction, if so, the step F3 is executed, otherwise, the step F4 is executed;
step F3: the card updates electronic cash information by using the recorded content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and waits for receiving an instruction sent by the upper computer;
step F4: and the card updates the balance of the electronic wallet by using the record content in the data field of the composite consumption file updating instruction, returns a successful response to the upper computer and waits for receiving the instruction sent by the upper computer.
2. The method of claim 1, wherein when the card determines that the conditions for accessing the electronic wallet data satisfy the requirements, the card processes the current electronic wallet data according to the received access electronic wallet data instructions, comprising:
when the data instruction for accessing the electronic wallet received by the card is a load instruction, the card judges whether a load operation condition meets a first requirement, if so, the card updates the balance of the electronic wallet by using the saved load amount, updates the overdrawn amount of electronic cash by using the overdrawn amount of the electronic wallet, sets an electronic wallet balance change identifier, returns a successful response to the upper computer, and waits for receiving an instruction sent by the upper computer; otherwise, error is reported and the process is finished.
3. The method of claim 2, wherein the card determining whether the load operation condition satisfies a first requirement comprises:
the card judges whether the loading instruction is correct or not, the card judges whether the current security state is the first security state or not, the card judges whether the MAC value in the data field of the loading instruction is correct or not, the card judges whether the transaction authentication code key exists or not, if the four judgment results are yes, the loading operation condition meets a first requirement, and if not, the loading operation condition does not meet the first requirement.
4. The method of claim 1, wherein when the card determines that the conditions for accessing the electronic wallet data satisfy the requirements, the card processes the current electronic wallet data according to the received access electronic wallet data instructions, comprising:
when the data command for accessing the electronic wallet received by the card is a consumption command, the card judges whether consumption operation conditions meet second requirements, if so, the card updates the balance of the electronic wallet according to the saved consumption amount, updates the overdrawn amount of electronic cash by the overdrawn amount of the electronic wallet, sets an electronic wallet balance change identifier, returns a successful response to the upper computer, and waits for receiving the command sent by the upper computer; otherwise, error is reported and the process is finished.
5. The method of claim 4, wherein the card determining whether the consuming operating condition satisfies a second requirement comprises:
the card judges whether the consumption instruction is correct, the card judges whether the current safety state is the second safety state or the third safety state, the card judges whether the MAC value in the data field of the consumption instruction is correct, the card judges whether the transaction authentication code key exists, if the four conditions are judged to be yes, the consumption operation condition meets the second requirement, otherwise, the consumption operation condition does not meet the second requirement.
6. The method of claim 4, wherein the setting of the wallet balance change identifier and the return of a successful response to the host computer comprises:
step B1: the card judges whether the current safety state is a third safety state, if so, the step B2 is executed, otherwise, the card waits for receiving an instruction sent by the upper computer;
step B2: the card judges whether the electronic cash application has a corresponding extended application record file, if so, the step B3 is executed, otherwise, the step B4 is executed;
step B3: the card updates the data in the composite application record cache to an extended application record file of the electronic cash and continues;
step B4: and the card updates the data in the composite application record cache to the composite transaction record file of the electronic wallet and continues.
7. The method of claim 1, wherein when the card determines that the conditions for accessing the electronic wallet data satisfy the requirements, the card processes the current electronic wallet data according to the received access electronic wallet data instructions, comprising:
when the data instruction for accessing the electronic wallet received by the card is a load initialization instruction, the card judges whether a load initialization operation condition meets a fifth requirement, if so, the card stores the load amount in a data field of the load initialization instruction, sets a first safety state, returns a successful response to the upper computer, waits for receiving the instruction sent by the upper computer, otherwise, reports an error, and ends.
8. The method of claim 7, wherein the card determining whether the load initialization operating condition meets a fifth requirement comprises:
the card judges whether the earmark initialization instruction is correct or not, the card judges whether a corresponding earmark key exists or not according to an earmark key index in a data field of the earmark initialization instruction, the card judges whether the earmark amount in the data field of the earmark initialization instruction plus the balance of the current electronic wallet exceeds the upper limit value of the balance of the electronic cash, if the three judgment results are yes, the earmark initialization operation condition meets a fifth requirement, otherwise, the earmark initialization operation condition does not meet the fifth requirement.
9. The method of claim 1, wherein when the card determines that the conditions for accessing the electronic wallet data satisfy the requirements, the card processes the current electronic wallet data according to the received access electronic wallet data instructions, comprising:
when the data access instruction received by the card is a consumption initialization instruction, the card judges whether consumption initialization operation conditions meet sixth requirements, if so, the card sets a second safety state, returns a successful response to the upper computer, and waits for receiving an instruction issued by the upper computer; otherwise, error is reported and the process is finished.
10. The method of claim 9, wherein the card determining whether the consumption initiation operating condition meets a sixth requirement comprises:
the card judges whether the consumption initialization instruction is correct or not, the card judges whether a corresponding consumption key exists or not according to the consumption key index in the data field of the consumption initialization instruction, the card judges whether the consumption amount in the data field of the consumption initialization instruction exceeds the balance of the electronic wallet, if yes, the consumption initialization operation condition meets a sixth requirement, and if not, the consumption initialization operation condition does not meet the sixth requirement.
11. The method of claim 1, wherein when the card determines that the conditions for accessing the electronic wallet data satisfy the requirements, the card processes the current electronic wallet data according to the received access electronic wallet data instructions, comprising:
when the data command for accessing the electronic wallet received by the card is a composite consumption initialization command, the card judges whether the composite consumption initialization operation condition meets a seventh requirement, if so, the card sets a third safety state, returns a successful response to the upper computer, and waits for receiving a command issued by the upper computer; otherwise, error is reported and the process is finished.
12. The method of claim 11, wherein the card determining whether the composite-consume initialization operating condition meets a seventh requirement comprises:
the card judges whether the composite consumption initialization instruction is correct or not, the card judges whether the corresponding composite consumption key exists or not according to the composite consumption key index in the data field of the composite consumption initialization instruction, the card judges whether the consumption amount in the data field of the composite consumption initialization instruction exceeds the balance of the electronic wallet or not, if the three judgment results are yes, the composite consumption initialization operation condition meets a seventh requirement, and if not, the composite consumption initialization operation condition does not meet the seventh requirement.
13. The method of claim 1, wherein the card determining whether the compound consumption file update operation condition satisfies an eighth requirement comprises:
the card judges whether a preset composite transaction record file of the electronic wallet exists according to the short file identifier in the composite consumption file updating instruction, judges whether a corresponding record in the composite transaction file of the electronic wallet exists according to the record identifier in the composite consumption file updating instruction, judges whether the record length in the composite consumption file updating instruction is correct or not, if the three judgment results are yes, the composite consumption file updating operation condition meets an eighth requirement, and otherwise, the composite consumption file updating operation condition does not meet the eighth requirement.
14. The method of claim 1, wherein the processing of the current electronic cash information by the card in accordance with the received instruction to access electronic cash data when the card determines that the condition for accessing electronic cash data satisfies the requirement comprises:
and when the electronic cash data access instruction received by the card is a reading record instruction, the card judges whether the reading record operation condition meets a third requirement, if so, the card updates the electronic cash balance information according to the current actually available electronic cash balance and the transaction amount, sets an electronic cash information change mark, returns a successful response to the upper computer, waits for receiving the instruction sent by the upper computer, otherwise, reports an error, and ends.
15. The method of claim 14, wherein the card determining whether the read record operation condition satisfies a third requirement comprises:
step X1: the card judges whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the step X2 is executed, otherwise, an error is reported, and the operation is finished;
step X2: the card judges whether corresponding data in a corresponding file in the electronic cash application exists according to the data on the third byte of the reading record instruction, if so, the corresponding data is taken as current data, and the step X3 is executed, otherwise, an error is reported, and the operation is finished;
step X3: the card judges whether the current safety state meets the condition, if so, the step X4 is executed, otherwise, the current data are returned to the upper computer, and the card waits for receiving the instruction sent by the upper computer;
step X4: the card judges whether the current data is the last unread data of the file locator, if so, the read record operation condition meets the third requirement, otherwise, the step X5 is executed;
step X5: and the card returns current data to the upper computer and waits for receiving an instruction sent by the upper computer.
16. The method of claim 14, wherein the step of setting an electronic cash information change flag and returning a successful response to the host computer further comprises:
step W1: the card judges whether an instruction for updating the extended application record cache is received, if so, the step W3 is executed, otherwise, the step W2 is executed;
step W2: the card clears a flag bit arranged in the electronic cash application, returns current data to the upper computer and waits for receiving an instruction sent by the upper computer;
step W3: and the card stores the data in the update extended application record caching instruction into a composite transaction record file of the electronic cash, clears a flag bit arranged in the electronic cash application, returns the current data to the upper computer and waits for receiving the instruction sent by the upper computer.
17. The method of claim 1, wherein the processing of the current electronic cash information by the card in accordance with the received instruction to access electronic cash data when the card determines that the condition for accessing electronic cash data satisfies the requirement comprises:
when the electronic cash data access instruction received by the card is a data modification instruction, the card judges whether a data modification operation condition meets a fourth requirement, if so, the card updates the electronic cash balance by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change mark, returns a success response to the upper computer, and waits for receiving an instruction sent by the upper computer; otherwise, error is reported and the process is finished.
18. The method of claim 17, wherein the card determining whether the modified data operating condition satisfies a fourth requirement comprises:
the card judges whether the data modification instruction is correct or not, the card judges whether the label code in the data modification instruction is legal or not, the card judges whether the length of the label value in the data modification instruction is correct or not, the card judges whether the MAC value in the data domain of the data modification instruction is correct or not, if the four judgment results are yes, the data modification operation condition meets a fourth requirement, and if not, the data modification operation condition does not meet the fourth requirement.
19. The method of claim 17, wherein the card updates the electronic cash balance using the amount of money in the data field of the modified data instruction, sets an electronic cash information change flag, returns a success response to the host computer, and waits to receive an instruction issued by the host computer, including:
step D1: the card judges whether the label in the data modification instruction is preset data, if so, the step D2 is executed, otherwise, the card waits for receiving an instruction issued by the upper computer;
step D2: and the card updates the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, sets an electronic cash information change identifier, returns a successful response to the upper computer and waits for receiving the instruction sent by the upper computer.
20. An apparatus for implementing information sharing between different applications, comprising:
the receiving module is used for waiting and receiving the instruction sent by the upper computer;
the first judgment module is used for judging the application needing to be selected when the receiving module receives an application selection instruction, triggering the first synchronization module to work if the application is an electronic wallet application, and triggering the second synchronization module to work if the application is an electronic cash application;
the first synchronization module is used for synchronizing the current electronic wallet data of the electronic wallet application by using the current electronic cash information of the electronic cash application;
the first processing module is used for processing the current electronic wallet data according to the received instruction for accessing the electronic wallet data when the condition for accessing the electronic wallet data meets the requirement;
the second synchronization module is used for synchronizing the electronic cash balance in the current electronic cash information under the electronic cash application by using the electronic wallet balance in the current electronic wallet data under the electronic wallet application;
the second processing module is used for processing the current electronic cash information according to the received electronic cash data access instruction when the condition for accessing the electronic cash data meets the requirement;
the return module is used for returning the processing result of the first processing module or the second processing module to the upper computer;
the first synchronization module includes:
the first judgment unit is used for judging whether the electronic cash information changes according to the electronic cash information change identifier, if so, the first updating and clearing unit is triggered to work, and if not, the first processing module is triggered to work;
the first updating and clearing unit is used for acquiring the balance and the overdrawn amount of the electronic cash in the electronic cash information, updating the balance and the overdrawn amount of the electronic wallet, clearing the change mark of the electronic cash information and triggering the first processing module to work;
the second synchronization module includes:
the eleventh judging unit is used for judging whether the balance of the electronic wallet changes according to the balance change identifier of the electronic wallet, if so, the second updating and clearing unit is triggered to work, and if not, the second processing module is triggered to work;
the second updating and clearing unit is used for updating the electronic cash balance by using the balance of the electronic wallet, clearing the change identifier of the balance of the electronic wallet and triggering the second processing module to work;
the first processing module comprises:
a ninth judging unit, configured to, when the receiving module receives a compound consumption file update instruction, judge whether the compound consumption file update operation condition meets an eighth requirement, if yes, trigger a tenth judging unit to operate, and otherwise trigger an error reporting unit to operate;
the error reporting unit is used for reporting errors;
the tenth judging unit is used for judging whether the corresponding electronic cash extended application file exists according to the composite consumption file updating instruction, if so, triggering a third updating unit to work, and otherwise, triggering a fourth updating unit to work;
the third updating unit is used for updating the electronic cash information by using the record content in the data field of the compound consumption file updating instruction;
the fourth updating unit is used for updating the balance of the electronic wallet by using the record content in the data field of the compound consumption file updating instruction;
the return module is also used for returning a successful response to the upper computer.
21. The apparatus of claim 20, wherein the first processing module comprises:
the second judging unit is used for judging whether the load operation condition meets a first requirement or not when the receiving module receives the load instruction, if so, the first updating setting unit is triggered to work, and otherwise, the error reporting unit is triggered to work;
the first updating setting unit is used for updating the balance of the electronic purse by using the saved earmark amount, updating the overdrawn amount of electronic cash by using the overdrawn amount of the electronic purse, and setting a balance change identifier of the electronic purse;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
22. The apparatus according to claim 21, wherein the second determining unit is specifically configured to determine whether the load instruction is correct, determine whether a current security state is a first security state, determine whether a MAC value in a data field of the load instruction is correct, and determine whether a transaction authentication code key exists, where if all of the four determination results are yes, the load operation condition satisfies the first requirement, and otherwise, the load operation condition does not satisfy the first requirement.
23. The apparatus of claim 20, wherein the first processing module comprises:
the third judging unit is used for judging whether the consumption operating condition meets a second requirement or not when the receiving module receives the consumption instruction, if so, the second updating setting unit is triggered to work, and otherwise, the error reporting unit is triggered to work;
the second updating and setting unit is used for updating the balance of the electronic purse according to the saved consumption amount, updating the overdrawn amount of electronic cash by the overdrawn amount of the electronic purse and setting a balance change identifier of the electronic purse;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
24. The apparatus according to claim 23, wherein the third determining unit is specifically configured to determine whether the consuming instruction is correct, determine whether a current security state is a second security state or a third security state, determine whether a MAC value in a data field of the consuming instruction is correct, and determine whether a transaction authentication code key exists, where if all the four are determined to be yes, the consuming operation condition satisfies the second requirement, and otherwise, the consuming operation condition does not satisfy the second requirement.
25. The apparatus of claim 23, wherein the first processing module further comprises:
the fourth judging unit is used for judging whether the current safety state is the third safety state, if so, the fifth judging unit is triggered to work, and otherwise, the receiving module is triggered to work;
the fifth judging unit is used for judging whether the electronic cash application has a corresponding extended application record file, if so, the first updating unit is triggered to work, and if not, the second updating unit is triggered to work;
the first updating unit is used for updating the data in the composite application record cache into an extended application record file of the electronic cash;
and the second updating unit is used for updating the data in the composite application record cache into the composite transaction record file of the electronic wallet.
26. The apparatus of claim 20, wherein the first processing module comprises:
the sixth judging unit is used for judging whether the load initialization operating condition meets a fifth requirement or not when the receiving module receives the load initialization instruction, if so, triggering the first storage setting unit to work, and otherwise, triggering the error reporting unit to work;
the first saving setting unit is used for saving the load amount in the data field of the load initialization instruction and setting a first safety state;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
27. The apparatus according to claim 26, wherein the sixth determining unit is specifically configured to determine whether the load initialization instruction is correct, determine whether a corresponding load key exists according to a load key index in a data field of the load initialization instruction, determine whether a result of adding a balance of the current electronic wallet to a load amount in the data field of the load initialization instruction exceeds an upper limit value of an electronic cash balance, and if all the three determination results are yes, the load initialization operating condition satisfies a fifth requirement, otherwise, the load initialization operating condition does not satisfy the fifth requirement.
28. The apparatus of claim 20, wherein the first processing module comprises:
the seventh judging unit is used for judging whether the consumption initialization operating condition meets the sixth requirement or not when the receiving module receives the consumption initialization instruction, if so, triggering the first setting unit to work, and otherwise, triggering the error reporting unit to work;
the first setting unit is used for setting a second safety state;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
29. The apparatus according to claim 28, wherein the seventh determining unit is specifically configured to determine whether the consumption initialization instruction is correct, determine whether a corresponding consumption key exists according to a consumption key index in a data field of the consumption initialization instruction, determine whether a consumption amount in the data field of the consumption initialization instruction exceeds an electronic wallet balance, and if yes, satisfy the sixth requirement for the consumption initialization operating condition, otherwise do not satisfy the sixth requirement for the consumption initialization operating condition.
30. The apparatus of claim 20, wherein the first processing module comprises:
the eighth judging unit is used for judging whether the composite consumption initialization operating condition meets a seventh requirement or not when the receiving module receives the composite consumption initialization instruction, if so, triggering the second setting unit to work, and otherwise, triggering the error reporting unit to work;
the second setting unit is used for setting a third safety state;
the return module is also used for returning a successful response to the upper computer;
the error reporting unit is also used for reporting errors.
31. The apparatus according to claim 30, wherein the eighth determining unit is specifically configured to determine whether the composite consumption initialization instruction is correct, determine whether a corresponding composite consumption key exists according to a composite consumption key index in a data field of the composite consumption initialization instruction, determine whether a consumption amount in the data field of the composite consumption initialization instruction exceeds an electronic wallet balance, and if all three determination results are yes, the composite consumption initialization operating condition satisfies a seventh requirement, otherwise the composite consumption initialization operating condition does not satisfy the seventh requirement.
32. The apparatus according to claim 20, wherein the ninth determining unit is specifically configured to determine whether a preset composite transaction record file of the e-wallet exists according to the short file identifier in the composite consumption file update instruction, determine whether a corresponding record in the composite transaction file of the e-wallet exists according to the record identifier in the composite consumption file update instruction, and determine whether the length of the record in the composite consumption file update instruction is correct, where if all three of the above determination results are yes, the composite consumption file update operation condition satisfies the eighth requirement, and otherwise, the composite consumption file update operation condition does not satisfy the eighth requirement.
33. The apparatus of claim 20, wherein the second processing module comprises:
a twelfth judging unit, configured to, when the receiving module receives the read record instruction, judge whether the read record operation condition meets a third requirement, if yes, trigger a third update setting unit to operate, and otherwise trigger an error reporting unit to operate;
the third updating and setting unit is used for updating the electronic cash balance information according to the current actually available electronic cash balance and the transaction amount and setting an electronic cash information change mark;
the return module is also used for returning a successful response to the upper computer;
the error reporting unit is used for reporting errors.
34. The apparatus as claimed in claim 33, wherein the twelfth judging unit comprises:
the first judging subunit is used for judging whether a corresponding file exists in the electronic cash application according to the data on the fourth byte of the reading record instruction, if so, the second judging subunit is triggered to work, and if not, the error reporting unit is triggered to work;
the second judging subunit is used for judging whether corresponding data in a corresponding file in the electronic cash application exists according to the data on the third byte of the reading record instruction, if so, the corresponding data is used as current data, and the third judging subunit is triggered to work, otherwise, the error reporting unit is triggered to work;
the third judging subunit is used for judging whether the current safety state meets the condition, if so, the fourth judging subunit is triggered to work, and if not, the return module is triggered to work;
the return module is used for returning the current data to the upper computer;
and the fourth judging subunit is configured to judge whether the current data is the last unread data of the file locator, if so, trigger the third update setting unit to operate, and otherwise, trigger the return module to operate.
35. The apparatus of claim 33, wherein the second processing module further comprises:
a thirteenth judging unit, configured to judge whether an update extended application record caching instruction is received, if yes, trigger a third update clearing unit to work, and otherwise, trigger the first clearing module unit;
the first clearing unit is used for clearing a flag bit arranged in the electronic cash application;
the return module is also used for returning the current data to the upper computer;
and the third updating and clearing unit is used for saving the data in the updating and expanding application record caching instruction into a composite transaction record file of the electronic cash and clearing a flag bit arranged in the electronic cash application.
36. The apparatus of claim 20, wherein the second processing module comprises:
a fourteenth judging unit, configured to, when the receiving module receives the data modification instruction, judge whether the data modification operation condition meets a fourth requirement, if yes, trigger a fourth update setting unit to operate, and otherwise trigger an error reporting unit to operate;
the fourth updating and setting unit is used for updating the balance of the electronic cash by using the amount of money in the data field of the data modification instruction, setting an electronic cash information change mark and triggering a return module to work;
the return module is also used for returning a successful response to the upper computer;
and the error reporting unit is used for reporting errors.
37. The apparatus according to claim 36, wherein the fourteenth determining unit is specifically configured to determine whether the modified data instruction is correct, determine whether a tag code in the modified data instruction is legal, determine whether a length of a tag value in the modified data instruction is correct, and determine whether a MAC value in a data field of the modified data instruction is correct, where if all the four determination results are yes, the modified data operating condition satisfies a fourth requirement, and otherwise, the modified data operating condition does not satisfy the fourth requirement.
38. The apparatus of claim 36, wherein the fourth update setting unit comprises:
a fifteenth judging subunit, configured to judge whether a tag in the modified data instruction is preset data, if so, trigger a fifth update setting unit to operate, and otherwise trigger the receiving module to operate;
and the fifth updating setting subunit is used for updating the balance of the electronic cash by using the amount of money in the data field of the modification data instruction and setting an electronic cash information change identifier.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510733498.7A CN105427098B (en) | 2015-11-02 | 2015-11-02 | Method and device for realizing information sharing among different applications |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510733498.7A CN105427098B (en) | 2015-11-02 | 2015-11-02 | Method and device for realizing information sharing among different applications |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105427098A CN105427098A (en) | 2016-03-23 |
CN105427098B true CN105427098B (en) | 2020-02-11 |
Family
ID=55505288
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510733498.7A Active CN105427098B (en) | 2015-11-02 | 2015-11-02 | Method and device for realizing information sharing among different applications |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105427098B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106779635B (en) * | 2016-11-22 | 2020-10-13 | 飞天诚信科技股份有限公司 | Smart card and method for sharing balance of multiple accounts in smart card |
CN106779694B (en) * | 2016-12-19 | 2023-02-28 | 飞天诚信科技股份有限公司 | Method for inquiring information in visual smart card and visual smart card |
CN107315944B (en) * | 2017-06-20 | 2019-10-08 | 飞天诚信科技股份有限公司 | A kind of intelligent cipher key equipment and its working method |
CN110166452B (en) * | 2019-05-21 | 2022-03-04 | 东信和平科技股份有限公司 | Access control method and system based on JavaCard shared interface |
WO2021163232A1 (en) * | 2020-02-10 | 2021-08-19 | Sweet Lawrence Mark | System and method for implementing a payment architecture that provides instant, risk-free payment in digital cash |
CN113191765B (en) * | 2021-04-22 | 2022-11-18 | 武汉天喻信息产业股份有限公司 | Method, device and equipment for sharing balance of multiple wallets and readable storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101799954A (en) * | 2009-11-20 | 2010-08-11 | 北京飞天诚信科技有限公司 | Method for loading double electronic purses |
CN103236003A (en) * | 2013-04-09 | 2013-08-07 | 深圳市雄帝科技股份有限公司 | E-wallet payment method and device |
CN104572721A (en) * | 2013-10-21 | 2015-04-29 | 上海华虹集成电路有限责任公司 | Shared module of E-wallet |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103473850B (en) * | 2012-06-06 | 2016-09-28 | 中国银联股份有限公司 | A kind of off line circle deposit method and system |
-
2015
- 2015-11-02 CN CN201510733498.7A patent/CN105427098B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101799954A (en) * | 2009-11-20 | 2010-08-11 | 北京飞天诚信科技有限公司 | Method for loading double electronic purses |
CN103236003A (en) * | 2013-04-09 | 2013-08-07 | 深圳市雄帝科技股份有限公司 | E-wallet payment method and device |
CN104572721A (en) * | 2013-10-21 | 2015-04-29 | 上海华虹集成电路有限责任公司 | Shared module of E-wallet |
Also Published As
Publication number | Publication date |
---|---|
CN105427098A (en) | 2016-03-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105427098B (en) | Method and device for realizing information sharing among different applications | |
US11119791B2 (en) | Information processing apparatus, IC chip, information processing method, program, and information processing system | |
CN109313545B (en) | Resource-limited Java card device | |
US20110016275A1 (en) | Mobile communication device and method for implementing mifare memory multiple sectors mechanisms | |
WO1998030958A1 (en) | Secure multiple application ic card system | |
US20110138390A1 (en) | Information processing device, information processing method and program | |
US9978056B2 (en) | Smart card having multiple payment instruments | |
WO2023285399A1 (en) | Replacement of executable load files in secure elements | |
CN102541639B (en) | CPU (Central Processing Unit) card data processing method, CPU card data processing system and CPU card | |
EP3286682B1 (en) | Method of managing applications in a secure element when updating the operating system | |
EP3507690B1 (en) | Java card application memory footprint optimization | |
CN102984330A (en) | Contact person data management method of communication device | |
CN109165712A (en) | Distributed generation method, device and computer storage medium by stages number | |
EP1573517B1 (en) | Method and apparatus for processing transactions in a data processing system | |
WO2008065524A2 (en) | Secure mmc standard smartcard with multi-application operation capability, process of operation | |
EP3507689A1 (en) | Java card application package used as a library package | |
JP2002279371A (en) | Application start control system of ic card | |
EP2898413A2 (en) | A security module and a method for optimum memory utilization | |
CN110704157A (en) | Application starting method, related device and medium | |
CN106502686B (en) | specification adaptation method and device | |
KR100678609B1 (en) | System and method for calling command function in smartcard, and patch system and method therefor | |
US20230236815A1 (en) | Hiding and unhiding java card applet instances | |
CN116700835A (en) | Java object creation method, chip and device | |
CN114726407B (en) | Method, device, controller and storage medium for acquiring abnormal information | |
CN116775383B (en) | Method and device for restoring factory settings, SE chip and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |