Disclosure of Invention
In view of the defects of the prior art, the invention aims to provide a smart card recharging method, a smart card recharging system, a smart card recharging terminal device and a storage medium based on Bluetooth.
In order to achieve the purpose, the invention adopts the following technical scheme:
a smart card recharging method based on Bluetooth comprises the following steps:
scanning the two-dimensional code or scanning a Bluetooth broadcast to send a Bluetooth connection request to the recharging terminal, and establishing a Bluetooth connection of a plaintext with the recharging terminal; after the Bluetooth connection is successful, an encryption authentication request is sent to the recharging terminal, and encryption authentication is carried out with the recharging terminal; after the first authentication response message is successfully encrypted and authenticated, sending a card information acquisition instruction to the recharging terminal, and receiving card reading feedback information sent by the recharging terminal; adding recharging information in front of the card reading feedback information to obtain a key acquisition instruction, and sending the key acquisition instruction to a server; and receiving a recharging request key fed back by the server, forwarding the recharging key to the recharging terminal for verification, and recharging the smart card after the verification is successful.
After the Bluetooth connection is successful, an encryption authentication request is sent to the recharging terminal, and the step of carrying out encryption authentication with the recharging terminal specifically comprises the following steps: after the Bluetooth connection is successful, sending an encryption authentication request to the recharging terminal, and receiving authentication information returned by the recharging terminal, wherein the authentication information is obtained by encrypting a first random number by the recharging terminal through a user master key; and sending the authentication information to an encryptor, receiving a first authentication response message returned by the encryptor, and transmitting the first authentication response message to a recharging terminal for encryption authentication.
The generation process of the first authentication response message comprises the following steps: the encryptor decrypts the authentication information through the user master key to obtain a first random number; and filling a second random number in the first random number to obtain a third random number, and encrypting the third random number through the user master key to obtain a first authentication response message.
The step of receiving the first authentication response message returned by the encryptor and transmitting the first authentication response message to the recharging terminal for encryption authentication specifically comprises the following steps: after receiving a first authentication response message returned by an encryptor, sending the first authentication response message to the recharging terminal; and after the recharging terminal verifies that the first authentication response message is correct, establishing encryption authentication connection with the recharging terminal.
The verification process of the first authentication response message comprises the following steps: the recharging terminal encrypts the first authentication response message through a user master key to obtain a third random number;
when the first random number is identified to exist in the third random number, encrypting the second random number to obtain a fourth random number, and intercepting a section of data of the fourth random number and a section of data of the first random number according to an intercepting rule to combine to obtain a fifth random number;
encrypting the fifth random number to obtain an encryption authentication key, and sending the encryption authentication key back to the mobile terminal, wherein the verification is successful;
and when the verification is successful, establishing encryption authentication connection using the encryption authentication key with the recharging terminal.
The generation process of the card reading feedback information comprises the following steps:
after receiving the card information acquisition instruction, the recharging terminal sends a card reading instruction to the intelligent card;
after receiving the card reading instruction, the intelligent card calculates first verification data according to card data stored in the intelligent card, and sends the card data and the first verification data to the recharging terminal;
and after the recharging terminal receives the card data and the first verification data, generating the card reading feedback information according to the card data and the first verification data.
The step of packaging the card reading feedback information into a key acquisition instruction and sending the key acquisition instruction to a server specifically comprises the following steps:
and obtaining a key acquisition instruction in the card reading feedback information.
The generation process of the recharge request key comprises the following steps:
after receiving a key acquisition instruction, the server extracts card data in the key acquisition instruction;
calculating second verification data according to the card data, and comparing the second verification data with the first verification data;
and when the second verification data is consistent with the first verification data, calculating a recharging request key according to recharging information in the key acquisition instruction.
The utility model provides a smart card system of recharging based on bluetooth, smart card system of recharging based on bluetooth includes mobile terminal, recharges terminal, server and smart card:
the mobile terminal is used for scanning the two-dimensional code or scanning the Bluetooth broadcast to send a Bluetooth connection request to the recharging terminal and establish clear Bluetooth connection with the recharging terminal; after the Bluetooth connection is successful, an encryption authentication request is sent to the recharging terminal, and encryption authentication is carried out with the recharging terminal; after the encryption authentication is successful, sending a card information acquisition instruction to the recharging terminal, and receiving card reading feedback information sent by the recharging terminal; adding recharging information in front of the card reading feedback information to obtain a key acquisition instruction, and sending the key acquisition instruction to a server; receiving a recharging request key fed back by the server, forwarding the recharging key to a recharging terminal for verification, and recharging the smart card after the verification is successful;
the recharging terminal is used for carrying out Bluetooth connection with the mobile terminal according to the Bluetooth connection request, receiving an encryption authentication request sent by the mobile terminal after the Bluetooth connection is successful, and carrying out encryption authentication connection with the mobile terminal; after the encryption authentication connection is successful, reading card data of the smart card according to a card information acquisition instruction sent by the mobile terminal, generating card reading feedback information and feeding the card reading feedback information back to the mobile terminal; recharging the smart card according to the recharging request key;
the server is used for generating a recharging request key according to the key acquisition instruction and returning the recharging request key to the mobile terminal;
the intelligent card is used for sending card data to the recharging terminal according to the card reading instruction and receiving recharging information writing of the recharging terminal.
A terminal device, comprising: a processor and a memory; the memory has stored thereon a computer readable program executable by the processor; the processor, when executing the computer readable program, implements the steps in the bluetooth-based smartcard recharging method as described above.
A computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to perform the steps in a bluetooth based smartcard recharging method as described above.
Compared with the prior art, the intelligent card recharging method, the intelligent card recharging system, the terminal device and the storage medium based on the Bluetooth comprise the following steps: scanning the two-dimensional code or scanning a Bluetooth broadcast to send a Bluetooth connection request to the recharging terminal, and establishing a Bluetooth connection of a plaintext with the recharging terminal; after the Bluetooth connection is successful, an encryption authentication request is sent to the recharging terminal, and encryption authentication is carried out with the recharging terminal; after the encryption authentication is successful, sending a card information acquisition instruction to the recharging terminal, and receiving card reading feedback information sent by the recharging terminal; adding recharging information in front of the card reading feedback information to obtain a key acquisition instruction, and sending the key acquisition instruction to a server; and receiving a recharging request key fed back by the server, forwarding the recharging key to the recharging terminal for verification, and recharging the smart card after the verification is successful. The invention realizes the acquisition of the recharging request key by establishing Bluetooth connection with the recharging terminal and connecting the mobile terminal with the server, and then realizes the recharging of the intelligent card by transmitting the recharging request key to the recharging terminal through Bluetooth.
Detailed Description
In view of the problems in the prior art, the invention provides a smart card recharging method, a smart card recharging system, a terminal device and a storage medium based on Bluetooth.
The embodiments of the present invention are intended to explain technical concepts of the present invention, technical problems to be solved, technical features constituting technical solutions, and technical effects to be brought about in more detail. The embodiments are explained below, but the scope of the present invention is not limited thereto. Further, the technical features of the embodiments described below may be combined with each other as long as they do not conflict with each other.
For the convenience of understanding the embodiments of the present application, relevant elements related to the embodiments of the present application will be described first:
contactless smart card: the contactless smart card refers to an intelligent ticket card containing a microprocessor, such as a campus card, a car card, an employee card, and the like. When the rechargeable smart card is used, the fee is automatically deducted only by approaching the smart card to the card reading device without direct contact.
And a recharging terminal: the terminal equipment which is arranged at a fixed position and used for self-service recharging of the non-contact intelligent card has a large volume; for example, a bus card recharging terminal installed at a subway station, an ATM machine installed at a bank, a PC or a terminal installed at a campus recharging place, and the like.
The inventor researches and discovers that the recharging terminal of the existing non-contact intelligent card is very inconvenient, has larger volume, generally occupies more space positions, has higher manufacturing cost and more power consumption; and the user needs to connect the Internet, and once the network is disconnected, recharging can not be carried out.
In view of the above problems in the prior art, the invention provides a smart card recharging method based on Bluetooth, which is implemented by connecting a mobile terminal with a server to obtain a recharging request key and sending the recharging request key to a recharging terminal through Bluetooth to recharge a smart card; the recharging terminal only needs a Bluetooth function and does not need to be connected with the Internet, so that the situation that the network is disconnected and cannot work can be avoided; the set position can be flexibly changed without being limited by a network cable because the internet does not need to be connected; compared with the Internet module, the Bluetooth module has low price, so that the manufacturing cost is reduced; because the setting position can change in a flexible way, therefore can set up to miniaturized or portable equipment, reduced the volume, also can set up on the ground clearance position such as on the wall, post, do not occupy the ground space.
For example, the method for recharging the contactlesssmart card 13 based on bluetooth in the present invention can be applied to the scenario shown in fig. 1, where themobile terminal 10 is connected to therecharging terminal 11 via bluetooth, themobile terminal 10 and theserver 12 communicate via app, a website, or a wechat applet, and thesmart card 13 is placed in a sensing area of therecharging terminal 11. Specifically, a bluetooth connection is established between themobile terminal 10 and the rechargingterminal 11, a recharging request key is acquired from theserver 12 through an APP, a website or a wechat applet in themobile terminal 10, the recharging request key is sent to the rechargingterminal 11 through bluetooth by themobile terminal 10, and thesmart card 13 is recharged after the rechargingterminal 11 passes verification.
Various non-limiting embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Referring to fig. 2, a method for recharging a bluetooth-based smart card in the present embodiment is shown. In this embodiment, the method may include, for example, the steps of:
s100, scanning the two-dimensional code or scanning the Bluetooth broadcast to send a Bluetooth connection request to the recharging terminal, and establishing clear Bluetooth connection with the recharging terminal.
In specific implementation, in this embodiment, the mobile terminal scans the two-dimensional code or directly scans the bluetooth broadcast, and sends a bluetooth connection request to the recharge terminal, and the recharge terminal performs bluetooth connection in plaintext with the mobile terminal after receiving the bluetooth connection request.
For example, in one mode of this embodiment, a two-dimensional code is set on the recharge terminal, where the two-dimensional code includes a website of the wechat applet or website and bluetooth information of the recharge terminal; optionally, the two-dimensional code may be attached to the recharging terminal in a form of a map, and further, a transparent cover plate such as an acrylic plate or a glass plate may be covered on the two-dimensional code; the recharging terminal can be further provided with a display screen, and the two-dimensional code can be displayed on an interface of the display screen.
When recharging is needed, the user can scan the two-dimensional code through the mobile terminal to obtain the website and the Bluetooth information, is connected to a recharging website of the server through the website, and sends a Bluetooth connection request to the recharging terminal according to the Bluetooth information. Particularly, when sweeping the sign indicating number through APP, can directly acquire bluetooth information, connect the request according to bluetooth information transmission bluetooth. The Bluetooth information is a Bluetooth device broadcast name, and the mobile terminal searches the Bluetooth device broadcast name through an APP, a website or a WeChat applet and can send a Bluetooth connection request.
In another optional embodiment, the recharge terminal may also directly provide the bluetooth information (i.e., the bluetooth device broadcast name), and the user may directly scan the bluetooth device broadcast name through the mobile terminal and send a bluetooth connection request to the recharge device.
Further, after receiving the bluetooth connection request, the recharging terminal detects whether bluetooth connection is established with other equipment currently; if not, establishing Bluetooth connection with the mobile terminal, if so, failing the Bluetooth connection, and sending a connection failure signal to the mobile terminal.
And S200, after the Bluetooth connection is successful, sending an encryption authentication request to the recharging terminal, and carrying out encryption authentication with the recharging terminal.
In specific implementation, in this embodiment, after the mobile terminal establishes a bluetooth connection with the recharging device, an encryption authentication request is sent to the recharging device through the mobile terminal, and encryption authentication is performed with the recharging terminal, so as to avoid the problems of fund loss and the like caused by data stealing by hackers in the subsequent recharging process.
For example, in one mode of this embodiment, referring to fig. 3, the step S200 specifically includes:
s210, after the Bluetooth connection is successful, sending an encryption authentication request to the recharging terminal, and receiving authentication information returned by the recharging terminal, wherein the authentication information is obtained by encrypting a first random number by the recharging terminal through a user master key;
s220, the authentication information is sent to the encryptor, and a first authentication response message returned by the encryptor is received and is transmitted to the recharging terminal for encryption authentication.
In specific implementation, in this embodiment, the encryptor may be disposed in the mobile terminal or in the server; the encryptor is provided with a decryption algorithm, and the recharge terminal is provided with an encryption algorithm.
Illustratively, when the encryptor is provided in a mobile terminal:
after the mobile terminal and the recharging terminal are connected through bluetooth, an encryption authentication request is sent through the mobile terminal, and after the recharging terminal receives the encryption authentication request, a first random number is generated, wherein the first random number is a group of random number sequences with preset lengths, the lengths of the random number sequences can be selected according to needs, the length of the random number sequence in the embodiment is RND _ A [0:15], namely a 16-bit random number sequence, and of course, the random number sequence can also be set to be 8 bits, 4 bits, 32 bits and the like, which is not limited herein.
The recharging terminal is also stored with a user master key, the user master key is set when the recharging terminal leaves a factory, and the same user master key is also set in the encryptor. After the recharging terminal generates the first random number, the first random number is encrypted through the user main key to obtain authentication information, the authentication information is sent back to the mobile terminal, and the authentication information is forwarded to an encryptor in the mobile terminal by the mobile terminal. Specifically, the encryption process is performed by the AES-128CBC encryption mode. And after receiving the authentication information, the encryptor generates the first authentication response message, and forwards the first authentication response message to the recharging terminal through the mobile terminal for encryption and authentication.
Illustratively, when the encryptor is provided in a server:
after the mobile terminal is connected with a recharging terminal through Bluetooth, an encryption authentication request is sent through the mobile terminal, and a first random number is generated after the recharging terminal receives the encryption connection request; and carrying out AES-128CBC encryption (calculation through an encryption algorithm) on the first random number by using the user master key to obtain authentication information, and sending the authentication information back to the mobile terminal. And the mobile terminal uploads the authentication information to an encryptor in the server. And after receiving the authentication information, the encryptor generates a first authentication response message, then the first authentication response message is sent to the mobile terminal through the server, and the mobile terminal forwards the first authentication response message to the recharging terminal for encryption and authentication.
It should be noted that, the encryptor may also set an encryption algorithm, and the recharge terminal sets a decryption algorithm; the specific steps are the same as above, only different in algorithm.
Specifically, referring to fig. 4, the step S220 specifically includes:
s221, after receiving a first authentication response message returned by an encryptor, sending the first authentication response message to the recharging terminal;
s222, after the recharging terminal verifies that the first authentication response message is correct, an encryption authentication connection is established with the recharging terminal.
After receiving a first authentication message sent by an encryptor, the mobile terminal forwards the first authentication message to the recharging terminal, the recharging terminal verifies the first authentication response message after receiving the first authentication response message, and after the first authentication response message is verified correctly, encryption authentication connection between the mobile terminal and the recharging terminal is established.
Referring to fig. 5, the process of generating the first authentication response packet includes the following steps:
m10, decrypting the authentication information by the encryptor through the user master key to obtain a first random number;
m11, filling a second random number in the first random number to obtain a third random number, and encrypting the third random number through the user master key to obtain a first authentication response message.
In a specific implementation, in this embodiment, after the encryptor receives the authentication information, the encryptor performs calculation of a decryption algorithm on the authentication information through the user master key to restore a first random number, and fills a second random number on the basis of the first random number to obtain a third random number. Specifically, the length of the second random number is the same as the length of the first random number, which is RND _ B [0:15] in this embodiment; the second random number may be padded before the first random number or may be padded after the first random number. And the server decrypts and calculates the third random number through the user master key to obtain a first authentication response message.
For example, referring to fig. 6, the verification process of the first authentication response message includes the steps of:
m20, encrypting the first authentication response message by the recharging terminal through a user master key to obtain a third random number;
m21, when the first random number is identified to exist in the third random number, encrypting the second random number to obtain a fourth random number, and intercepting a section of data of the fourth random number and a section of data of the first random number according to an interception rule to obtain a fifth random number;
m22, encrypting the fifth random number to obtain an encryption authentication key, and sending the encryption authentication key back to the mobile phone, wherein the verification is successful;
and M23, when the verification is successful, establishing an encryption authentication connection with the recharging terminal by using the encryption authentication key.
In specific implementation, in this embodiment, after receiving the first authentication response packet, the recharging terminal encrypts the first authentication response packet through the user master key (calculates through an encryption algorithm), so as to obtain the third random number. And extracting the first random number according to a rule preset by the encryptor and the recharging terminal. For example, if the encryptor fills the second random number in front of the first random number to obtain a third random number, then the random number of the second half of the third random number is extracted, that is, the first random number; otherwise, extracting the random number of the first half section to obtain a first random number; the rule for filling the second random number may be set at the time of shipment. And after the first random number is extracted, comparing the extracted first random number with the first random number generated by the recharging terminal, if the first random number is consistent with the first random number, the first authentication response message passes the verification of the recharging terminal, and if the first random number is inconsistent with the first random number, the verification fails.
Further, when the recharging terminal successfully verifies the first authentication response message, the recharging terminal encrypts a second random number RAN _ B [0:15] through a user master key to obtain a fourth random number, and intercepts a section of data in the fourth random number and a section of data in the second random number according to a preset intercepting rule to generate a fifth random number. Illustratively, the intercepting rule is to intercept a combination of the first 8 bytes or the last 8 bytes of the fourth random number and the second random number, which may be bytes extracted from the middle, and the length of the intercepted data may also be set as required, for example, 4 bytes, 10 bytes, and the like; the interception rule may be set when the device leaves a factory, and is not limited herein. And encrypting the fifth random number to obtain an encryption authentication key, wherein the encryption authentication key is recorded as SK [0:15 ]. And sending the encrypted authentication key back to the mobile terminal, wherein the authentication is successful.
After the verification is successful, sensitive data sent from the encryptor are encrypted by using the encryption authentication key in an AES-128CBC encryption mode, and then the sensitive data are verified by the recharging terminal and can be transmitted to the recharging terminal, namely after the encryption authentication is successful, the sensitive data (such as recharging, inquiry and other instructions) sent to the recharging device subsequently need to be decrypted by the encryption authentication key and then sent to the recharging terminal for encryption and then authentication, and then the corresponding sensitive data can be written in so as to execute corresponding operations of recharging, inquiry and the like.
The encryption authentication connection has stronger security, the double encryption of the user master key and the encryption authentication key reduces the possibility that the hacker equipment acquires the encrypted data, and in addition, the existence of the user master key ensures that the encrypted data cannot pass verification under the condition of not knowing the user master key even if the encrypted data is acquired, thereby further improving the security. In particular, the encryption process is performed by the AES-128CBC encryption mode, or may be performed by other encryption methods, which is not limited herein.
S300, after the encryption authentication is successful, sending a card information acquisition instruction to the recharging terminal, and receiving card reading feedback information sent by the recharging terminal.
In specific implementation, in this embodiment, after the encryption authentication is successful, the smart card can be recharged or queried. The intelligent card is placed in a card induction area of a recharging terminal, the mobile terminal sends a card data acquisition instruction to the recharging terminal through an APP, a website or a WeChat applet, and the recharging terminal receives the card information acquisition instruction, reads card data of the intelligent card and generates card reading feedback information to feed back the card reading feedback information to the mobile terminal.
Specifically, the card information acquisition instruction is as follows:
TABLE 1 get card information Command
| CLA | INS | P1 | P2 | LC | Type of transaction | Amount of transaction | Recharge terminal number |
| 80 | 50 | 00 | 01 | 0B | 01 | 00001000 | 001122334455 |
As shown in table 1, the card information acquisition command is 32 bytes of data, and the data are combined into an acquisition card command according to the sequence in the table and sent to the recharge terminal. CLA is instruction type, INS is instruction code, P1 and P2 are parameters, and LC is data length; the above-mentioned command is the APDU command specification, and the APDU is the prior art and will not be described in detail herein. Because the demand of each person is different, the transaction amount can be set according to the actual demand, taking 1000rmb as an example in the embodiment; the number of the recharging terminal is stored when the recharging terminal leaves a factory according to actual conditions.
Illustratively, referring to fig. 7, the process of generating the card reading feedback information includes the steps of:
m30, after receiving the card information acquisition instruction, the recharging terminal sends a card reading instruction to the smart card;
after receiving the card reading instruction, the M31 smart card calculates first verification data according to card data stored in the smart card, and sends the card data and the first verification data to the recharging terminal;
m32, after the recharging terminal receives the card data and the first verification data, generating the card reading feedback information according to the card data and the first verification data.
In a specific implementation, in this embodiment, the recharging terminal generates a card reading instruction to send to the smart card after receiving the card obtaining information, and the microprocessor in the smart card generates first verification data according to the card data stored in the memory and sends the first verification data to the recharging terminal after receiving the card reading instruction. And after receiving the card data and the first verification data, the recharging terminal generates card reading feedback information according to the card data and the first verification data and sends the card reading feedback information to the mobile terminal. Specifically, the smart card and the server are further provided with a common key Ekey, which is 11223344556677888877665544332211 in this embodiment.
Specifically, table 2 shows the card data and the first verification data:
TABLE 2 card data and first verification data
As shown in table 2, the card balance, the transaction serial number, the key version number, the algorithm identifier, and the random number are card data, and the MAC1 is first verification data. After the smart card receives a card reading instruction, a microprocessor in the smart card extracts the random number and the transaction serial number, and adds a first filling number to obtain InData, wherein the random number is 11223344, the transaction serial number is 0000, and the first filling number is 0000, namely the InData is 1122334400000000. Then the intelligent card carries out 3DES encryption on InData through the common secret key to calculate a second process secret key Skey; namely: skey 3DES _ encrypt (InData, Ekey) 9B1D924E 05595603.
And then extracting the card balance, the transaction amount, the transaction type and the recharging terminal number to calculate the InData1, namely the InData1 is 000000000000100001001122334455. And then, performing MAC operation on the InData1 through the second process key to obtain first verification data: MAC1 ═ MAC (InData1, SKey) ═ 2988AE 5A.
And S400, adding recharging information before the card reading feedback information to obtain a key acquisition instruction, and sending the key acquisition instruction to a server.
In specific implementation, in this embodiment, the recharging information includes a transaction amount, a recharging terminal number, a transaction type, a transaction date, and a transaction time; the card reading feedback information comprises card data and first verification data. And filling the recharging information into the card reading feedback information to form a key acquisition instruction shown in a table 3. And the mobile terminal generates the key acquisition instruction and then sends the key acquisition instruction to a server.
TABLE 3 Key acquisition Instructions
Specifically, the data of the transaction amount is 00001000, the data of the terminal number is 001122334455, the data of the transaction type is 01, the data of the transaction date is 20191221, the data of the transaction time is 214822, the data of the card balance is 00000000, the data of the transaction serial number is 0000, the data of the key version number is 02 (the version number is increased by 1 when the key is changed), the data of the algorithm identifier is 00, the data of the random number is 11223344, and the data of the MAC1 is 2988AE 5A.
S500, receiving a recharging request key fed back by the server, forwarding the recharging key to a recharging terminal for verification, and recharging the smart card after the verification is successful.
In a specific implementation, in this embodiment, after receiving the key obtaining instruction, the server performs key verification to generate a recharge request key, and sends the recharge request key back to the mobile terminal. The mobile terminal receives the recharging request key, assembles the recharging request key into a recharging instruction and sends the recharging instruction to the recharging terminal, the recharging terminal verifies the recharging request key in the recharging instruction, and writes the recharging amount into the smart card after the verification is passed, namely, the recharging amount is increased on the basis of the balance of the original card, so that the smart card is recharged. And finally, adding 1 to the transaction serial number, returning data 9000 to the recharging terminal to show that recharging is successful, and sending the data to the mobile phone after the data is received by the recharging terminal to represent that recharging is successful. If the verification is unsuccessful, i.e., the recharge fails, it returns to 6985.
Specifically, the recharge instruction is shown in table 4:
TABLE 4 recharge instruction
| CLA | INS | P1 | P2 | LC | Date of transaction | Transaction time | MAC2 |
| 80 | 52 | 00 | 00 | 0B | 20191221 | 214822 | 3A845BF0 |
For example, referring to fig. 8, the process of generating the recharge request key includes the steps of:
m40, after receiving a key acquisition instruction, the server extracts card data in the key acquisition instruction;
m41, calculating second verification data according to the card data, and comparing the second verification data with the first verification data;
and M42, when the second verification data is consistent with the first verification data, calculating a recharging request key according to the recharging information in the key acquisition instruction.
In specific implementation, in this embodiment, after receiving the key obtaining instruction, the server extracts the random number and the transaction sequence number in the key obtaining instruction, adds first padding data to obtain the InData2, and performs 3DES encryption on the InData2 according to the shared key Ekey1 to obtain the Skey 1. And extracting the card balance, the transaction amount, the transaction type and the terminal number in the key acquisition command to obtain InData3, and finally performing MAC operation according to Skey1 and InData3 to obtain second verification data MAC 0. MAC0 is compared with MAC1, and if they match, the verification is successful, and if they do not match, the verification fails.
Further, when the verification is successful, continuously extracting the transaction amount, the transaction type, the terminal number, the transaction date and the transaction time in the key acquisition command to obtain the InData4, then directly acquiring the Skey according to the second process key Skey (when the verification is successful, the Skey is proved to be the same as the Skey1, so that the Skey can be directly acquired, or the Skey1 can be used) and the InData4 to perform MAC operation to obtain a recharge request key MAC2, and sending the recharge request key to the mobile terminal.
Based on the above smart card recharging method based on bluetooth, please continue to refer to fig. 1, the present invention further provides a smart card recharging system based on bluetooth, which includes amobile terminal 10, a rechargingterminal 11, aserver 12 and asmart card 13;
themobile terminal 10 is used for scanning the two-dimensional code or scanning the Bluetooth broadcast to send a Bluetooth connection request to the rechargingterminal 11, and establishing a clear Bluetooth connection with the rechargingterminal 11; after the Bluetooth connection is successful, an encryption authentication request is sent to the rechargingterminal 11, and encryption authentication is carried out with the rechargingterminal 11; after the encryption authentication is successful, sending a card information obtaining instruction to the rechargingterminal 11, and receiving card reading feedback information sent by the rechargingterminal 11; adding recharging information in front of the card reading feedback information to obtain a key acquisition instruction, and sending the key acquisition instruction to theserver 12; receiving a recharging request key fed back by theserver 12, forwarding the recharging key to the rechargingterminal 11 for verification, and recharging thesmart card 13 after the verification is successful;
the rechargingterminal 11 is used for performing bluetooth connection with themobile terminal 10 according to the bluetooth connection request, receiving an encryption authentication request sent by themobile terminal 10 after the bluetooth connection is successful, and performing encryption authentication connection with themobile terminal 10; after the encryption authentication connection is successful, reading card data of thesmart card 13 according to a card information acquisition instruction sent by themobile terminal 10, generating card reading feedback information and feeding the card reading feedback information back to themobile terminal 10; recharging theintelligent card 13 according to the recharging request key;
theserver 12 is configured to generate a recharge request key according to the key acquisition instruction and return the recharge request key to themobile terminal 10;
thesmart card 13 is used for sending card data to the rechargingterminal 11 according to the card reading instruction, and receiving recharging information written in by the rechargingterminal 11. Since the recharging method of the contactlesssmart card 13 based on bluetooth is described in detail above, it will not be described in detail here.
The present invention also provides a computer readable storage medium storing one or more programs, which are executable by one or more processors to implement the steps in a bluetooth-based smart card recharging method as described in the above embodiments.
The present invention also provides a terminal device, as shown in fig. 9, which includes at least one processor (processor)20, and a memory (memory) 22; adisplay screen 21, aCommunications Interface 23 and/or abus 24 may also be included. Theprocessor 20, thedisplay 21, thememory 22 and thecommunication interface 23 can communicate with each other through thebus 24. Thedisplay screen 21 is configured to display a user guidance interface preset in the initial setting mode. Thecommunication interface 23 may transmit information. Theprocessor 20 may call logic instructions in thememory 22 to perform the methods in the embodiments described above.
Furthermore, the logic instructions in thememory 22 may be implemented in software functional units and stored in a computer readable storage medium when sold or used as a stand-alone product.
Thememory 22, which is a computer-readable storage medium, may be configured to store a software program, a computer-executable program, such as program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 30 executes the functional application and data processing, i.e. implements the method in the above-described embodiments, by executing the software program, instructions or modules stored in thememory 22.
Thememory 22 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, thememory 22 may include a high speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, may also be transient storage media.
In addition, the specific processes loaded and executed by the storage medium and the instruction processors in the mobile terminal are described in detail in the method, and are not stated herein.
The intelligent card recharging method, system, terminal equipment and storage medium based on Bluetooth comprise the following steps: scanning the two-dimensional code or scanning a Bluetooth broadcast to send a Bluetooth connection request to the recharging terminal, and establishing a Bluetooth connection of a plaintext with the recharging terminal; after the Bluetooth connection is successful, an encryption authentication request is sent to the recharging terminal, and encryption authentication is carried out with the recharging terminal; after the encryption authentication is successful, sending a card information acquisition instruction to the recharging terminal, and receiving card reading feedback information sent by the recharging terminal; adding recharging information in front of the card reading feedback information to obtain a key acquisition instruction, and sending the key acquisition instruction to a server; and receiving a recharging request key fed back by the server, forwarding the recharging key to the recharging terminal for verification, and recharging the smart card after the verification is successful. The invention realizes the acquisition of the recharging request key by establishing Bluetooth connection with the recharging terminal and connecting the mobile terminal with the server, and then realizes the recharging of the intelligent card by transmitting the recharging request key to the recharging terminal through Bluetooth.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.