WO2018024250A1 - 一种数据通讯方法及数据通讯系统 - Google Patents

一种数据通讯方法及数据通讯系统 Download PDF

Info

Publication number
WO2018024250A1
WO2018024250A1 PCT/CN2017/096025 CN2017096025W WO2018024250A1 WO 2018024250 A1 WO2018024250 A1 WO 2018024250A1 CN 2017096025 W CN2017096025 W CN 2017096025W WO 2018024250 A1 WO2018024250 A1 WO 2018024250A1
Authority
WO
WIPO (PCT)
Prior art keywords
terminal
data
preset value
preset
value
Prior art date
Application number
PCT/CN2017/096025
Other languages
English (en)
French (fr)
Inventor
李明
Original Assignee
李明
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN201610640015.3A external-priority patent/CN107688760B/zh
Priority claimed from CN201610639441.5A external-priority patent/CN107689946B/zh
Application filed by 李明 filed Critical 李明
Priority to US16/314,007 priority Critical patent/US10609552B2/en
Priority to EP17836431.1A priority patent/EP3495985A4/en
Priority to KR1020187034251A priority patent/KR101998543B1/ko
Publication of WO2018024250A1 publication Critical patent/WO2018024250A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/50Secure pairing of devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/01Details
    • G06K7/016Synchronisation of sensing process
    • G06K7/0163Synchronisation of sensing process by means of additional timing marks on the record-carrier
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/44Program or device authentication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/10009Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation sensing by radiation using wavelengths larger than 0.1 mm, e.g. radio-waves or microwaves
    • G06K7/10366Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation sensing by radiation using wavelengths larger than 0.1 mm, e.g. radio-waves or microwaves the interrogation device being adapted for miscellaneous applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/28Flow control; Congestion control in relation to timing considerations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/06Network architectures or network communication protocols for network security for supporting key management in a packet data network
    • H04L63/061Network architectures or network communication protocols for network security for supporting key management in a packet data network for key exchange, e.g. in peer-to-peer networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0869Network architectures or network communication protocols for network security for authentication of entities for achieving mutual authentication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/04Key management, e.g. using generic bootstrapping architecture [GBA]
    • H04W12/041Key generation or derivation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3271Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using challenge-response

Definitions

  • the present invention relates to the field of electronic technologies, and in particular, to a data communication method and a data communication system.
  • the terminals adopting the non-contact card reading method are all based on the protocols such as ISO14443 and ISO15693, and the card reading process between the card reader and the smart card is taken as an example, and the card is read based on the above protocol.
  • FWT frame waiting time
  • the merchant card reader sends data to the user's smart card under normal conditions, and the user's smart card starts to respond after receiving the data.
  • Processing data processing data time is t1
  • the response data is sent to the merchant card reader immediately, ignoring the small time on the line transmission (the order of magnitude is small, which is convenient for simplifying the calculation), and therefore, the merchant card reader sends the data.
  • the time T1 t1 required to complete the data received by the user's smart card feedback. If a hacker conducts a man-in-the-middle attack, as shown in FIG.
  • the middleman's smart card hijacks the request data of the merchant card reader, and forwards the data sent by the merchant card reader to the middleman's card reader, and the middleman's card reader.
  • the device may tamper with the request data and send the falsified data to the user's smart card (the time from the middleman's smart card hijacking the merchant's card reader's request data to the middleman's card reader sending the falsified data to the user's card reader For tw1), after receiving the falsified data, the user's smart card processes the data (processing data time is t1), and sends the processed data to the middleman's card reader.
  • the middleman's card reader may tamper with the user's smart card return.
  • the merchant card reader will receive the data sent by the intermediary's smart card and perform subsequent operations (such as the transaction process), so that there is a middleman hijacking and the merchant card reader has The danger of uninformed, resulting in the economic loss of the merchant.
  • the present invention is directed to solving one of the above problems.
  • the main object of the present invention is to provide a data communication method.
  • Another object of the present invention is to provide a data communication system.
  • An aspect of the present invention provides a data communication method, including: a first terminal sends first data to a second terminal, and starts timing from a time point when the first data is completed, where the first data includes at least Data to be processed; the second terminal receives the first data, and starts counting from a time point when the first data is received; when the value obtained by the second terminal reaches a preset value, the The second terminal sends the second data to the first terminal, where the second data is data obtained by the second terminal performing data processing on the to-be-processed data; Within the valid range of the preset value, the first terminal is allowed to start receiving the second data.
  • a data communication system including: a first terminal, configured to send first data to a second terminal, and start timing from a time point when the first data is completed, where the The second terminal is configured to receive the first data, and the timing is started from a point of time when the first data is completed; the second terminal is further configured to: When the value obtained by the second terminal reaches a preset value, the second data is sent to the first terminal, where the second data is obtained after the second terminal performs data processing on the to-be-processed data.
  • the first terminal is further configured to allow to start receiving the second data if the value obtained by the first terminal is within a valid range of the preset value.
  • Another aspect of the present invention provides a data communication method, including: a first terminal transmitting first data to a second terminal, and starting timing from a time point when the first data is completed, where the first data is At least the data to be processed is included; the second terminal receives the first data, and starts counting from a time point when the first data is received; when the value obtained by the second terminal reaches a preset value, Transmitting, by the second terminal, the second data to the first terminal, where the second data is data obtained by performing data processing on the to-be-processed data by the second terminal; timing in the first terminal When the obtained value reaches the preset value, the first terminal is allowed to start receiving the second data.
  • a data communication system including: a first terminal, configured to send first data to a second terminal, and start timing from a time point when the first data is completed, where The first data includes at least data to be processed; the second terminal is configured to receive the first data, and start timing from a time point when the first data is received; the second terminal is further used to When the value obtained by the second terminal reaches a preset value, the second data is sent to the first terminal, where the second data is obtained by the second terminal after performing data processing on the to-be-processed data.
  • the first terminal is further configured to allow to start receiving the second data when the timed value reaches the preset value.
  • the data communication method and system provided by the present invention transmit data through the timing of the second terminal (the value obtained by the timing reaches the preset value S), and the first terminal timing (the number obtained by timing)
  • the strategy of receiving the data returned by the second terminal within a valid range [S, S+2 ⁇ S] of the preset value avoids the problems in the prior art, since the first terminal only obtains the value obtained in the timing.
  • the preset value or the data returned by the second terminal is allowed to be received within the valid range [S, S+2 ⁇ S] of the preset value, and the reception is not allowed outside the preset value or outside the valid range of the preset value.
  • the data returned by the second terminal is allowed to be received within the valid range [S, S+2 ⁇ S] of the preset value, and the reception is not allowed outside the preset value or outside the valid range of the preset value.
  • the first terminal obtains the preset value when the timed value reaches the preset value, or if the second data is allowed to be received and the second data is received within the valid range of the preset value, it means that there is no hijacking of the middleman.
  • the first terminal obtains the preset value when the timed value reaches the preset value, or if the second data is allowed to be received within the valid range of the preset value, the middleman hijacking occurs, so that the situation occurs. Even when the first terminal receives T2 ⁇ FWT of the second data, the first terminal can still recognize whether there is a middleman hijacking, and avoid the user from causing economic loss without knowing.
  • FIG. 1 is a schematic diagram of time required for a merchant card reader to transmit data to receive data received by a user's smart card under normal circumstances in the background art of the present invention
  • FIG. 2 is a schematic diagram of time required for a merchant card reader to transmit data to receive data fed back by a user's smart card in the case of a hijacking in the background of the present invention
  • FIG. 3 is a flowchart of a data communication method according to Embodiment 1 of the present invention.
  • FIG. 4 is a flowchart of a specific first terminal and a second terminal negotiating a preset value according to Embodiment 1 of the present invention
  • FIG. 5 is a flowchart of a specific first terminal and a second terminal negotiating a preset value according to Embodiment 1 of the present invention
  • FIG. 6 is a schematic structural diagram of a data communication system according to Embodiment 2 of the present invention.
  • FIG. 7 is a flowchart of a data communication method according to Embodiment 3 of the present invention.
  • FIG. 3 is a flow chart of a data communication method according to Embodiment 1 of the present invention. Referring to FIG. 3, the method includes at least steps S11 to S14.
  • Step S11 The first terminal sends the first data to the second terminal, and starts counting from a time point when the first data is completed, where the first data includes at least data to be processed.
  • the communication manner between the first terminal and the second terminal includes: a short-range wireless communication mode, and specifically, the short-range wireless communication mode includes at least: NFC (Near Field Communication), Wi-Fi (Wireless Fidelity), UWB (UltraWideband), Zigbee, RFID (Radio Frequency Identification), infrared transmission, and Bluetooth. Therefore, the communication distance between the first terminal and the second terminal can be as short as several centimeters to several hundred meters. Based on the short-range wireless communication method described above, corresponding to different communication modes, communication between the first terminal and the second terminal also adopts a corresponding communication protocol to implement wireless data transmission between the two.
  • NFC Near Field Communication
  • Wi-Fi Wireless Fidelity
  • UWB UltraWideband
  • Zigbee Zigbee
  • RFID Radio Frequency Identification
  • infrared transmission and Bluetooth. Therefore, the communication distance between the first terminal and the second terminal can be as short as several centimeters to several hundred meters.
  • the first terminal includes a reading device
  • the second terminal includes a response device
  • the reading device and the response device may be terminals supporting a contactless card reading mode, for example, a reading device. It can be a reader of a POS machine, an ATM machine, an ID card reader, etc.
  • the response device can be a smart key device (such as ICBC U-Shield, Agricultural Bank Key), smart card, ID card, etc., using the above non-contact.
  • Terminals of the card reader type such as between the card reader and the smart card, between the card reader and the ID card, can use the protocols ISO14443 and ISO15693 for data transmission.
  • the short-range wireless communication methods can include: ISO14443 and ISO15693 protocols.
  • the communication method; in addition, the reading device and the response device may also be terminals supporting short-range wireless communication methods such as a mobile terminal, a PC, a palmtop computer, and a smart device.
  • the first terminal is a card reader
  • the second terminal is a smart card.
  • the data to be processed in the first data may be a card reading request data.
  • the data to be processed in the data is not limited to this.
  • the first terminal and the second terminal are both mobile terminals.
  • the data to be processed in the first data may also be request data for requesting the second terminal to return a picture, etc.
  • the embodiment does not impose excessive restrictions on the data to be processed in the first data, as long as it is the request data initiated by the first terminal to the second terminal.
  • the first terminal in order to be able to recognize the hijacking of the middleman when T2 ⁇ FWT, the first terminal periodically receives the policy of the second terminal timing transmission, so in this step, the first The terminal starts counting from the time when the first data is sent.
  • the timed value is within the valid range of the preset value, if the data returned by the second terminal is received, it indicates that there is no hijacking of the intermediary, if not received , you can identify the hijacking of the middleman.
  • step S12 the second terminal receives the first data and starts timing from the time when the first data is completed.
  • the processed data is not sent to the first terminal immediately after the first data processing is completed, as in the prior art, but the timing is started.
  • the first terminal periodically receives the second terminal periodically transmitting the policy, and when the timed value reaches a preset value, the second terminal sends the second data obtained by processing the to-be-processed data in the first data, that is, periodically sending. (Refer to step S13), so that when the first terminal receives T2 ⁇ FWT of the second data, it can still recognize whether there is a case of hijacking.
  • step S13 when the value obtained by the second terminal reaches a preset value, the second terminal sends the second data to the first terminal, where the second data is the second terminal performs data on the to-be-processed data in the first data.
  • the second data is not limited, and the second data is data obtained by processing the data to be processed in the first data.
  • the second terminal as a smart card
  • the first terminal as a card reader
  • the second data may be the data content of the smart card requested by the first terminal
  • the first terminal and the second terminal are both mobile terminals, for example.
  • the data to be processed in one data is the data of the requested picture
  • the second data is the picture data.
  • the second terminal When the time when the first data is received is started, in this step, when the value obtained by the timing reaches the preset value S, the second terminal sends the second data to the first terminal to ensure the timing is transmitted.
  • Step S14 The value obtained by the first terminal is within the valid range of the preset value, and the first terminal is allowed to start receiving the second data.
  • the effective range of the preset value is [S, S+2 ⁇ S], wherein S is a preset value, and ⁇ S is used by a communication mode between the first terminal and the second terminal.
  • the maximum supported communication distance is determined.
  • the communication mode adopted between the first terminal and the second terminal may be short-range wireless communication, and may include multiple communication modes, and the maximum communication distance supported by each communication mode is different.
  • NFC operates at 13.56 MHz, supports communication distances of less than 20 cm
  • Bluetooth operates at 2.4 GHz.
  • the supported communication distance can reach 20 m and WiFi can reach 100 m.
  • ⁇ S can be understood as a value required for the maximum communication distance supported by the communication mode adopted between the first terminal and the second terminal, for example, the length of time required to transmit the first data through the maximum communication distance, etc., due to each type of communication
  • the maximum communication distance supported by the mode is different.
  • the value of ⁇ S may also be different.
  • ⁇ S may also include other meanings, as described in detail below.
  • the first data is continuously sent to the second terminal in a byte manner, and the first terminal continuously sends the first byte, the second byte, the last byte of the first data, and the second terminal.
  • the first byte, the second byte, ... the last byte of the first data are continuously received.
  • the first terminal starts to receive each byte of the first data, and the terminal receives the individual bytes of the first data, considering that the terminal receives a single The length of the byte is small and can be ignored. Therefore, when the first byte of the first data arrives at the second terminal, the last byte of the first data has not been sent yet, that is, the first terminal has not been sent yet.
  • step S11 the timing is started when the first terminal transmits the completion of the first data, and in step S12, at the second terminal.
  • the first terminal When the time when the first data is completed is started, without the middle of the transmission time, the first terminal should be able to receive the second data when the timed value reaches S, considering the transmission time on the road. In the case of no hijacking by the middleman, the first terminal should be able to obtain a value greater than S and less than or equal to S+2 ⁇ . When S starts to receive the second data.
  • the present embodiment provides a data communication method.
  • the data communication method transmits data by the second terminal timing (the value obtained by timing reaches the preset value S), and the first terminal timing (the value obtained by timing is within the effective range of the preset value [S, S+2 ⁇ S]) is received.
  • the strategy of the data returned by the terminal avoids the problems in the prior art.
  • the first terminal can be understood as a merchant card reader in the background art
  • the second terminal can be understood as a user smart card in the background art, because the first terminal only
  • the value obtained in the timing is allowed to receive the data returned by the second terminal within the valid range [S, S+2 ⁇ S] of the preset value, at the preset value It is not allowed to receive data returned by the second terminal outside the valid range. Therefore, if the receiving of the second data is allowed within the valid range of the preset value, it indicates that there is no hijacking of the intermediary, but if the receiving is allowed within the valid range of the preset value, but no Receiving the second data indicates that a middleman hijacking has occurred.
  • FWT is a frame waiting time specified by a communication protocol adopted by the first terminal and the second terminal, for example, a frame waiting time FWT specified by protocols ISO14443 and ISO15693, such that the first terminal ( For example, the card reader can wait for the smart card to return data during the FWT time, and implement the timing receiving solution provided by the embodiment. Therefore, the method provided in this embodiment can identify the middleman while being compatible with the existing protocol. Hijacking.
  • the second terminal timing is taken as an example of the preset time of S.
  • S and ⁇ S may include various forms in addition to the representative duration.
  • S and ⁇ S are mentioned below. Various forms are included, as described in detail below.
  • the preset value S may be pre-made in the fixed area of the terminal before the terminal leaves the factory, without negotiation, or may be negotiated between the first terminal and the second terminal, or may be generated by one party and sent to the other party.
  • the first terminal may be written in a data packet specified by the protocol, and sent to the second terminal together when the first terminal sends data to the second terminal.
  • the preset value of the factory prefabrication does not need to be negotiated or generated, but the data output of the first terminal and the second terminal are periodically sent and received according to the preset value.
  • the disadvantage is that the preset value cannot be changed, and is not flexible enough. Random, less secure.
  • the latter methods for obtaining the preset value S can randomly generate preset values, which are more flexible, random, and safer than the factory preset preset values.
  • the preset value S is crucial for recognizing the hijacking of the middleman. Therefore, in order to prevent the preset value S from being tampered with, the present embodiment proposes several ways of obtaining the preset value S, the following The manner in which the preset value S is obtained is described in detail.
  • the following steps may be implemented to obtain a preset value by using the following steps, and may be negotiated at any timing before the first terminal sends the first data to the second terminal.
  • Pre-made preset values are more flexible, random and safer.
  • the method provided in this embodiment further includes:
  • the first terminal and the second terminal perform two-way identity authentication, and after the two-way identity authentication is passed, the first terminal negotiates with the second terminal to obtain a transmission key;
  • the second terminal generates the preset value, and encrypts the preset value by using the transmission key, and sends the encrypted preset value to the first terminal; the first terminal uses the transmission key pair to encrypt the pre- Setting the value to obtain the preset value, and saving; or, the first terminal generates the preset value, and encrypts the preset value by using the transmission key, and sends the encrypted preset value to the second terminal; The second terminal uses the transmission key pair to solve the encrypted preset numerical solution Get the preset value and save it.
  • the two-way identity authentication of the first terminal and the second terminal can ensure the legal identity of the first terminal and the second terminal, further negotiate a transmission key, and use the transmission key to encrypt and decrypt the preset value.
  • the preset value can be used in the next data communication, and the two terminals need not perform the negotiation again by saving the preset value.
  • the interactive flow of preset values greatly improves the efficiency of data transmission.
  • the manner in which the preset value is negotiated in the optional implementation manner may be implemented in multiple manners.
  • This embodiment is only an example, so as to clearly understand the manner in which the preset value is negotiated in the optional implementation manner.
  • the embodiment provides a specific process for the first terminal to negotiate a preset value with the second terminal, which specifically includes the following steps:
  • the first terminal initiates an authentication request to the second terminal, where the authentication request carries a random number R1 and a digital certificate of the first terminal.
  • the random number R1 is a single authentication data generated by the first terminal, which can prevent replay attacks of the first terminal by other illegal devices.
  • the second terminal receives the authentication request, and verifies the digital certificate of the first terminal. After the verification is passed, the random number R1 is signed by the private key of the second terminal to generate signature data S1, and a random number R2 is generated. The public key in the digital certificate of the first terminal encrypts R2 to obtain the ciphertext E1.
  • the random number R2 is a single authentication data generated by the second terminal, which can prevent replay attacks of the second terminal by other illegal devices.
  • the second terminal sends the digital certificate of the second terminal, the signature data S1, and the ciphertext E1 to the first terminal.
  • the first terminal verifies the digital certificate of the second terminal. After the verification is passed, the signature data S1 is checked by using the public key in the digital certificate. After the verification is passed, the ciphertext E1 is decrypted to obtain the R2.
  • the private key of a terminal generates signature data S2 for R2 signature, generates a random number R3, encrypts R3 with the public key of the second terminal to obtain ciphertext E2, and generates a transmission key K based on R2R3.
  • the validity of the identity of the second terminal can be ensured by the verification of the signature data S1 of the second terminal by the first terminal.
  • the random number generated by each party to generate a transmission key, it can be ensured that even if a hacker intercepts a random number of a certain party, the transmission key cannot be generated because there is no random number of the other party, thereby ensuring that the transmission key will not be Easy to get.
  • the first terminal sends the signature data S2 and the ciphertext E2 to the second terminal.
  • the second terminal authenticates the signature data S2 by using the public key in the digital certificate of the first terminal. After the verification is passed, the ciphertext E2 is decrypted to obtain R3, and the transport key K is generated based on the R2R3.
  • the validity of the first terminal identity can be ensured by the verification of the signature data S2 of the first terminal by the second terminal.
  • the first terminal generates a preset value S, and encrypts the ciphertext E3 by using the transmission key K.
  • the first terminal sends the E3 to the second terminal.
  • the second terminal receives the ciphertext E3, and decrypts the E3 by using the transmission key K to obtain a preset value S, and saves the preset value S.
  • the two-way authentication of the first terminal and the second terminal and the negotiation of the transmission key are completed from steps S110 to S115.
  • steps S116-S118 the operations performed by the first terminal and the second terminal may be performed.
  • the preset value S can be generated by the second terminal, and the ciphertext E3 is obtained by using the K encryption S, and sent to the first terminal.
  • the first terminal decrypts the preset value S by using the transmission key K and saves it.
  • the method may be implemented in the following steps to obtain a preset value by one party, and before the first terminal sends the first data to the second terminal. Any time to negotiate, more flexible, random, and more secure than the pre-made preset values. Specifically, before the first terminal starts timing from the time when the first data is sent, the method provided in this embodiment further includes:
  • the first terminal and the second terminal perform two-way identity authentication
  • the second terminal After the two-way identity authentication is passed, the second terminal generates the preset value, and encrypts the preset value by using the public key of the first terminal, and sends the encrypted preset value to the first terminal; the first terminal Decrypting the encrypted preset value with the private key to obtain the preset value, and saving; or, after the two-way identity authentication is passed, the first terminal generates the preset value, and uses the public key of the second terminal.
  • the preset value is encrypted, and the encrypted preset value is sent to the second terminal; the second terminal decrypts the encrypted preset value by using the private key to obtain the preset value, and saves the preset value.
  • the two-way identity authentication of the first terminal and the second terminal can ensure the legal identity of the first terminal and the second terminal, and further use the public-private key to encrypt and decrypt the preset value to ensure the security of the transmission process. Therefore, it is possible to prevent the preset value generated by one party from being illegally falsified, and to ensure the security of the preset value.
  • the optional implementation uses the public-private key pair of the first terminal and the second terminal itself to implement encryption and decryption of the preset value, and does not need to generate a transmission key, thereby reducing the interaction step and shortening. The time to get the preset value increases the efficiency.
  • the preset value can be used in the next data communication, and the two terminals need not perform the negotiation again by saving the preset value.
  • the interactive flow of preset values greatly improves the efficiency of data transmission.
  • this embodiment provides a specific process for the first terminal to negotiate a preset value with the second terminal, which specifically includes the following steps:
  • the first terminal initiates an authentication request to the second terminal, where the authentication request carries a random number R1;
  • the random number R1 is a single authentication data generated by the first terminal, which can prevent replay attacks of the first terminal by other illegal devices.
  • the second terminal receives the authentication request, and uses the private key to sign the random number R1 to generate signature data S1, and generate a random number R2;
  • the random number R2 is a single authentication data generated by the second terminal, which can prevent replay attacks of the second terminal by other illegal devices.
  • the second terminal sends the digital certificate, the signature data S1, and the random number R2 of the second terminal to the first terminal.
  • the first terminal verifies the digital certificate of the second terminal. After the verification is passed, the signature data S1 is checked by using the public key in the digital certificate. After the verification is passed, the private key of the first terminal is used to sign the R2. Generating signature data S2;
  • the validity of the identity of the second terminal can be ensured by the verification of the signature data S1 of the second terminal by the first terminal.
  • the first terminal sends its digital certificate and signature data S2 to the second terminal.
  • the second terminal verifies the digital certificate of the first terminal. After the verification is passed, the signature data S2 is checked by using the public key in the digital certificate.
  • the validity of the first terminal identity can be ensured by the verification of the signature data S2 of the first terminal by the second terminal.
  • the second terminal randomly generates a preset value S, and uses the public key of the first terminal to encrypt the preset value S to generate the ciphertext E;
  • the second terminal sends the E to the first terminal.
  • the first terminal receives the ciphertext E, and decrypts the E with the private key to obtain the preset value S, and saves the preset value S.
  • the two-way authentication between the first terminal and the second terminal is implemented from step S120 to step S125, and after the two-way identity authentication is passed, the second terminal generates a preset value, in step S126 ⁇
  • the operations performed by the first terminal and the second terminal may be interchanged, that is, the preset value S may be generated by the first terminal, and the ciphertext E is obtained by encrypting the preset value S by using the public key of the second terminal, and sending The second terminal, the second terminal decrypts the E with its private key to obtain a preset value S, and saves it.
  • the optional implementation does not need to negotiate the transmission key, but directly uses the public key of the first terminal and the second terminal to perform encryption and decryption, thereby reducing the negotiation transmission density.
  • the key interaction process can improve the efficiency of obtaining preset values.
  • the following steps may be implemented in the following steps: the first terminal writes the preset value into the data packet specified by the protocol, and the first terminal sends the data to the second terminal. And sending the second terminal to the second terminal to obtain the preset value.
  • the method provided in this embodiment further includes: generating, by the first terminal Setting a value; the first data sent by the first terminal to the second terminal further includes: the preset value and the tamper-proof check value calculated based on the preset value; and in step S12, the second terminal receives the first
  • the method provided by the embodiment further includes: the second terminal acquiring the preset value and the tamper-proof check value from the first data, and verifying the tamper-proof check value, after the verification is passed, Save the preset value.
  • the first terminal may randomly generate a preset value, and write the preset value and the tamper-proof check value into the predetermined field according to the format of the data packet specified by the protocol, or may also increase a new field, the preset value and the tamper-proof check value are written into the newly added field, and when the first terminal sends the first data to the second terminal, the data carried in the first data is sent to the first Two terminals.
  • the tamper-proof check value is calculated based on a preset value.
  • the tamper-proof check value may be signature data calculated based on the preset value, that is, a summary is generated for the preset value calculation, and the first terminal is utilized.
  • the private key encrypts the digest to generate the signature data
  • the second terminal checks the tamper-proof If the value is verified, the signature data may be checked by the public key of the first terminal. If the verification is passed, the verification is passed, indicating that the preset value has not been tampered with.
  • the tamper-proof check value may be a MAC value calculated by using a MAC algorithm based on a preset value, and the second terminal may also calculate a MAC value by using the same MAC algorithm when verifying the tamper-proof check value. Check whether the two MAC values are consistent. If they are consistent, the check is passed, indicating that the preset value has not been tampered with.
  • the second terminal After receiving the first data, the second terminal starts timing, and obtains a preset value from the first data. If the tamper-proof check value is verified, the second terminal is timed. After the value reaches the preset value, the second data is sent to the first terminal, and if the first terminal does not receive the second data returned by the second terminal within the valid range of the preset value, the middleman hijacking occurs; The verification of the tamper-proof check value does not pass, and the second terminal stops the timing. At this time, it indicates that there is a possibility that the middleman hijacks the data.
  • the identification of the hijacker can also be realized by the tamper-proof check value, and once the preset value is tampered, the verification cannot pass, thereby ensuring that the preset value is not illegal. Tampering to ensure the safety of preset values.
  • the preset value may include at least: a preset duration, a preset number of cycles, a preset number of pulses, or a preset phase difference
  • the first terminal and the second terminal also have different timing statistics manners, and the manner of determining whether the timed value reaches a preset value or within a valid range of the preset value, respectively A preset value is described in detail.
  • the preset value may include: a preset duration, where the preset duration is greater than the second terminal performs data processing on the to-be-processed data in the received first data. Duration (since the second terminal needs to send the second data after reaching the timed value after processing the data), in addition, optionally, S+2 ⁇ S ⁇ FWT; ⁇ S is the distance between the first terminal and the second terminal is When the maximum communication distance supported by the communication mode is adopted, the time required for the first terminal to transmit data to the second terminal, in step S14, the value obtained by the first terminal is within a valid range of the preset value, including The time length obtained by the first terminal from the completion of the sending of the first data is in the range of [S, S+2 ⁇ S]; in the step S13, the value obtained by the second terminal is up to a preset value, including: receiving from the second terminal The time period obtained after the completion of the first data reaches the preset duration.
  • the first terminal and the second terminal both have a timer, and the precise timing function is supported.
  • the duration of the timer can be used to determine whether the preset duration or the effective range of the preset duration is reached.
  • the first terminal is allowed to start receiving the second data only when [5 ⁇ 10 -3 s, (5 ⁇ 10 -3 + 1.2 ⁇ 10 -7 ) s], and only receives within the valid range of the preset value. It is only after the second data that there is no hijacking of the middleman, and thus the hijacking of the middleman can be identified.
  • the optional implementation is exemplified only by Bluetooth communication, other short-range communication methods are within the scope of protection of the present invention.
  • the terminal has no timing function, and in this embodiment, the first terminal always generates a carrier signal during the entire process of communicating between the first terminal and the second terminal. Therefore, this is The timing statistics method of the clock timing is proposed in the embodiment.
  • the number of the carrier signal, the number of pulses, and the phase difference can be calculated to calculate the timed value.
  • the preset value may include: The number of cycles of the carrier signal, the number of pulses of the preset carrier signal, and the phase difference of the preset carrier signal, ⁇ S may specifically indicate that the carrier signal is supported by the communication mode adopted between the first terminal and the second terminal.
  • the number of cycles, the number of pulses, and the phase change value generated by the maximum communication distance wherein, regardless of which of the above-mentioned timing statistics methods, the sum of the sums of S+2 ⁇ S is greater than that of the second terminal.
  • the duration of data processing of the data to be processed in a data, and optionally, the sum of the sums of S+2 ⁇ S may be less than or equal to FWT.
  • the preset value may include: a preset number of periods; and ⁇ S is a period generated by a maximum communication distance supported by a carrier signal by using a communication mode between the first terminal and the second terminal.
  • step S14 the value obtained by the first terminal is within a valid range of the preset value, and includes: the number of cycles of the carrier signal continuously transmitted by the first terminal to the second terminal after the first data is transmitted is In the range of [S, S+2 ⁇ S]; in step S13, the value obtained by the second terminal reaches a preset value, including: the number of cycles of the carrier signal continuously received by the second terminal after receiving the completion of the first data. The preset number of cycles is reached.
  • the first terminal is always generating a carrier signal.
  • the first terminal needs to send data, for example, the first terminal sends the first data, and the first data is modulated on the carrier signal and sent to the second terminal.
  • the first terminal does not need to send data, the first terminal sends the carrier signal to the second terminal, and the carrier signal does not carry data.
  • the first terminal and the second terminal both have a counter, and the number of periods of the download wave in the foregoing situation may be calculated.
  • the optional implementation manner provides an optional method for counting the time obtained by the statistical timing. The terminal and the second terminal do not need to use the clock timing, and can also achieve the purpose of accurate timing.
  • the obtained value can be accurate to ns, so that accurate statistical results can be achieved, and the alternative embodiment can be applied to a passive crystal card without a crystal.
  • the alternative embodiment is exemplified only by the NFC communication method, other short-range communication methods are all within the scope of protection of the present invention.
  • the preset value may include: a preset number of pulses; ⁇ S is a maximum supported by a carrier signal through a communication mode between the first terminal and the second terminal.
  • the number of pulses generated by the communication distance; in step S14, the value obtained by the first terminal is within the effective range of the preset value, and includes: the carrier that the first terminal continues to send to the second terminal after transmitting the first data.
  • the number of pulses of the signal is in the range of [S, S+2 ⁇ S]; in step S13, the value obtained by the second terminal reaches a preset value, including: the carrier continuously received by the second terminal after receiving the first data.
  • the number of pulses of the signal reaches the preset number of pulses.
  • the number of statistical pulses of the carrier signal that is, the number of peaks of the statistical carrier signal, compared with the number of periods of the statistical carrier signal, the number of statistical pulses can achieve further accurate statistics, and the optional embodiment Can be applied to passive smart cards without crystals.
  • the preset value may include: a preset phase difference; ⁇ S a phase change value generated by the maximum communication distance supported by the carrier signal through the communication mode adopted between the first terminal and the second terminal; in step S14, the value obtained by the first terminal is within a valid range of the preset value
  • the method includes: a phase difference between the first phase and the second phase of the carrier signal is in a range of [S, S+2 ⁇ S], wherein the first phase is a phase at which the carrier signal transmits the first data at the first terminal, The second phase is a phase at which the carrier signal is allowed to start receiving the second data at the first terminal; in step S13, the value obtained by the second terminal reaches a preset value, including: the carrier signal is in the third phase and the fourth phase.
  • the phase difference of the phase reaches a preset phase difference, wherein the third phase is a phase of a carrier signal at a time point at which the second terminal receives the first data, and the fourth phase is a carrier signal that is transmitted at the second terminal.
  • the phase of the time point of the two data is a preset phase difference, wherein the third phase is a phase of a carrier signal at a time point at which the second terminal receives the first data, and the fourth phase is a carrier signal that is transmitted at the second terminal.
  • the first terminal and the second terminal may use a previously obtained method for obtaining a preset value, and negotiate or one party generates a preset phase difference.
  • the communication waveform between the two is a standard sine. Wave carrier, recording the phase at this moment is 0 (ie, the first phase and the third phase are 0), when the carrier phase difference (ie, the phase difference between the third phase and the fourth phase) reaches (1/2+40) ⁇ ,
  • the smart card sends the second data.
  • the card reader can confirm the absence of the middleman's hijacking by allowing the phase difference obtained by timing to start receiving and receiving the second data within the valid range of the preset value.
  • the carrier signal carrying the first data has a phase change value generated by a maximum transmission distance of 20 cm supported by NFC. Then, the first terminal only allows to start receiving the second data in [(1/2+40) ⁇ , 41 ⁇ ], and only if the second data is received within the valid range of the preset value indicates that there is no hijacking of the middleman. Thus, the hijacking of the middleman can be identified.
  • the terminal that supports the NFC communication mode is taken as an example.
  • the working frequency of the first terminal and the second terminal is 13.56 MHz.
  • the first terminal (for example, reading)
  • the card carrier always generates a carrier of 13.56MHz.
  • the phase can be divided into a period of 2 ⁇ , and the timing can be counted by phase. Accurate to 74/2 ⁇ ns, compared to the above-mentioned statistical carrier signal number of cycles and the number of pulses, the statistical phase difference can achieve further accurate statistics, and the optional implementation can be applied to passive crystalless smart card.
  • the alternative embodiment is exemplified only by the NFC communication method, other short-range communication methods are all within the scope of protection of the present invention.
  • the first terminal periodically receives the policy of the second terminal timing transmission, so that the first terminal can still identify whether there is a middleman hijacking even when receiving the second data T2 ⁇ FWT. The situation, to avoid the user's economic loss without knowing it.
  • an embodiment of the present invention further provides a data communication system.
  • the data communication system includes: a first terminal and a second terminal, where the first terminal and the second terminal perform the data communication method as in Embodiment 1. among them:
  • the first terminal is configured to send the first data to the second terminal, and start timing from the time when the first data is completed, where the first data includes at least data to be processed, and the second terminal is configured to receive the first data. And the timing is started from the time when the first data is received; the second terminal is further configured to: when the value obtained by the second terminal reaches a preset value, send the second data to the first terminal, where the second data is The second terminal is configured to perform data processing on the data to be processed; and the first terminal is further configured to start to receive the second data if the value obtained by the first terminal is within a valid range of the preset value.
  • the effective range of the preset value is [S, S+2 ⁇ S], where S is a preset value, and ⁇ S is supported by a communication mode adopted between the first terminal and the second terminal.
  • the maximum communication distance is determined, wherein the duration corresponding to S+2 ⁇ S is less than or equal to the frame waiting time FWT specified by the communication protocol adopted by the first terminal and the second terminal.
  • the communication manner between the first terminal and the second terminal includes: a short-range wireless communication mode.
  • the first terminal is further configured to perform two-way identity authentication with the second terminal before the first terminal starts timing from the time when the first data is sent, after the two-way identity authentication is passed. And negotiating with the second terminal to obtain a transmission key;
  • the second terminal is further configured to generate a preset value, and encrypt the preset value by using the transmission key, and send the encrypted preset value to the first terminal; the first terminal is further configured to use the transmission key pair to encrypt The preset value is decrypted to get the preset value and saved; or,
  • the first terminal is further configured to generate a preset value, and encrypt the preset value by using the transmission key, and send the encrypted preset value to the second terminal; the second terminal is further configured to use the transmission key pair to encrypt The preset value is decrypted to get the preset value and saved.
  • the first terminal is further configured to perform two-way identity authentication with the second terminal before the first terminal starts timing from the time when the first data is sent.
  • the second terminal is further configured to: after the two-way identity authentication is passed, generate a preset value, and encrypt the preset value by using the public key of the first terminal, and send the encrypted preset value to the first terminal; the first terminal And is further configured to decrypt the encrypted preset value by using the private key of the first terminal to obtain a preset value, and save the data;
  • the first terminal is further configured to: after the two-way identity authentication is passed, generate a preset value, and encrypt the preset value by using the public key of the second terminal, and send the encrypted preset value to the second terminal; the second terminal It is also used to decrypt the encrypted preset value by using the private key of the second terminal to obtain a preset value, and save it.
  • the first terminal is further configured to generate a preset value before the first terminal sends the first data to the second terminal, where the first data further includes: a preset value and a preset value Calculating the tamper-proof check value; the second terminal is further configured to: after receiving the first data, obtain a preset value and a tamper-proof check value from the first data, and check the tamper-proof check value , after the verification is passed, save the preset value.
  • the preset value includes: a preset duration; ⁇ S is when the distance between the first terminal and the second terminal is the maximum communication distance supported by the communication mode adopted by the two, first The terminal transmits data to the second end The length of time required by the terminal; the value obtained by the first terminal is within the valid range of the preset value, and includes: the duration obtained by the first terminal from the time when the first data is transmitted is in the range of [S, S+2 ⁇ S]; The value obtained by the timing of the second terminal reaches a preset value, including: the duration obtained by the second terminal after receiving the completion of the first data reaches a preset duration; or
  • the preset value includes: a preset number of cycles; the first terminal is further configured to: when the first terminal communicates with the second terminal, the carrier signal is always generated; ⁇ S is the carrier signal passes through the first terminal and the second terminal.
  • the number of cycles generated by the maximum communication distance supported by the communication mode wherein: the value obtained by the first terminal is within a valid range of the preset value, including: the first terminal continues after transmitting the first data
  • the number of cycles of the carrier signal sent to the second terminal is in the range of [S, S+2 ⁇ S]; the value obtained by the second terminal reaches a preset value, including: the second terminal continues to receive after receiving the first data.
  • the number of cycles of the carrier signal reaches the preset number of cycles; or,
  • the preset value includes: a preset number of pulses; the first terminal is further configured to: when the first terminal communicates with the second terminal, the carrier signal is always generated; ⁇ S is the carrier signal passes through the first terminal and the second terminal; The number of pulses generated by the maximum communication distance supported by the communication mode; wherein: the value obtained by the first terminal is within the valid range of the preset value, including: the first terminal continues after transmitting the first data.
  • the number of pulses of the carrier signal sent to the second terminal is in the range of [S, S+2 ⁇ S]; the value obtained by the second terminal reaches a preset value, including: the second terminal continues to receive after receiving the first data.
  • the number of pulses of the carrier signal reaches the preset number of pulses; or,
  • the preset value includes: a preset phase difference; the first terminal is further configured to: when the first terminal communicates with the second terminal, always generate a carrier signal; ⁇ S is a carrier signal that passes through the first terminal and the second terminal The phase change value generated by the maximum communication distance supported by the communication mode; wherein: the value obtained by the first terminal timing is within the effective range of the preset value, including: the phase of the carrier signal in the first phase and the second phase The difference is in the range of [S, S+2 ⁇ S], wherein the first phase is a phase at which the carrier signal transmits the first data at the first terminal, and the second phase is a carrier signal allowed to start receiving the second at the first terminal.
  • the second terminal receives the phase at the time point when the first data is completed, and the fourth phase is the phase of the carrier signal at the time point when the second terminal starts transmitting the second data.
  • the first terminal periodically receives the policy of timing transmission by the second terminal, so that the first terminal can recognize whether there is a middleman hijacking even when receiving the T2 ⁇ FWT of the second data. The situation, to avoid the user's economic loss without knowing it.
  • FIG. 7 is a flow chart of a data communication method according to Embodiment 3 of the present invention. Referring to FIG. 7, the method includes at least steps S31 to S34.
  • Step S31 The first terminal sends the first data to the second terminal, and starts counting from a time point when the first data is completed, where the first data includes at least data to be processed.
  • the communication manner between the first terminal and the second terminal includes: short-range wireless communication mode, and specific For the ground, refer to the corresponding description in step S11 in Embodiment 1.
  • the first terminal is a card reader
  • the second terminal is a smart card.
  • the data to be processed in the first data may be a card reading request data.
  • the data to be processed in the data is not limited to this.
  • the first terminal and the second terminal are both mobile terminals.
  • the data to be processed in the first data may also be request data for requesting the second terminal to return a picture, etc.
  • the embodiment does not impose excessive restrictions on the data to be processed in the first data, as long as it is the request data initiated by the first terminal to the second terminal.
  • the first terminal in order to be able to recognize the hijacking of the middleman when T2 ⁇ FWT, the first terminal periodically receives the policy of the second terminal timing transmission, so in this step, the first The terminal starts counting from the time when the first data is completed, and when the value obtained by the first terminal reaches the preset value, if the data returned by the second terminal is received, it indicates that there is no hijacking of the middleman, if If it is not received, it can be identified that there is a middleman's hijacking.
  • Step S32 the second terminal receives the first data, and starts timing from the time when the first data is completed.
  • the processed data is not sent to the first terminal immediately after the first data processing is completed, as in the prior art, but the timing is started.
  • the first terminal periodically receives the second terminal periodically transmitting the policy, and when the timed value reaches a preset value, the second terminal sends the second data obtained by processing the to-be-processed data in the first data, that is, periodically sending. (Refer to step S33), so that when the first terminal receives T2 ⁇ FWT of the second data, it can still recognize whether there is a case of hijacking.
  • step S33 when the value obtained by the second terminal reaches a preset value, the second terminal sends the second data to the first terminal, where the second data is the second terminal performs data on the to-be-processed data in the first data.
  • the second data is not limited.
  • the second data is not limited.
  • Step S34 When the value obtained by the first terminal reaches a preset value, the first terminal is allowed to start receiving the second data.
  • the communication mode adopted between the first terminal and the second terminal may be short-range wireless communication, and may include multiple communication modes, and the maximum communication distance supported by each communication mode is different.
  • NFC operates at 13.56 MHz, supports communication distances of less than 20 cm, and Bluetooth operates at 2.4 GHz.
  • the supported communication distance can reach 20 m and WiFi can reach 100 m.
  • the maximum communication distance supported by short-range wireless communication is within a few hundred meters, and the transmission time of data between the two terminals is ns, and the preset value is at least greater than the time for data processing of the data to be processed by the second terminal ( Ms level), therefore, since the data transmission time between the two terminals is very small compared to the preset value, in the present embodiment, the data transmission time is negligible.
  • the first data is continuously sent to the second terminal in a byte manner, and the first terminal continuously sends the first byte, the second byte, the last byte of the first data, and the second terminal.
  • the first byte, the second byte, ... the last byte of the first data are continuously received.
  • the first terminal and the second terminal use short-distance communication, the first In a process in which a terminal starts to send each byte of the first data, the second terminal has begun to receive each byte of the first data, and considering that the terminal receives a single byte in a small order of magnitude, it can be ignored, and thus, the first data
  • the first byte arrives at the second terminal, the last byte of the first data has not been sent yet, that is, the first terminal has not sent the completion of the first data.
  • the first terminal sends the first data and the second terminal receives the first data simultaneously, that is, the time at which the first terminal sends the first data is received by the second terminal. The time at which the first data is completed.
  • step S31 the timing is started when the first terminal transmits the completion of the first data.
  • step S32 the timing is started when the second terminal receives the completion of the first data. Considering the transmission time on the road, without the hijacking of the middleman, the first terminal should be able to receive the second data when the timed value reaches the preset value.
  • the present embodiment provides a data communication method.
  • the data communication method sends data through the second terminal timing (the value obtained by the timing reaches a preset value), and the strategy of receiving the data returned by the second terminal by the first terminal timing (the value obtained by the timing reaches a preset value) avoids the prior art.
  • the first terminal can be understood as a merchant card reader in the background art
  • the second terminal can be understood as a user smart card in the background art, since the first terminal only allows receiving when the timed value reaches a preset value.
  • the data returned by the second terminal any value other than the preset value (for example, the preset value is not reached or exceeded) is not allowed to receive the data returned by the second terminal.
  • the first terminal allows the start of reception and receives the second data when the value obtained by the timing reaches a preset value, it indicates that there is no hijacking of the middleman, but if the value obtained at the first terminal is reached, When the preset value is allowed to start receiving but the second data is not received, it indicates that a middleman hijacking has occurred.
  • the preset value S corresponds to a duration less than or equal to a frame waiting time FWT specified by a communication protocol used by the first terminal and the second terminal, for example, a frame waiting time FWT specified by protocols ISO 14443 and ISO 15693, such that the first terminal ( For example, the card reader can wait for the smart card to return data during the FWT time, and implement the timing receiving solution provided by the embodiment. Therefore, the method provided in this embodiment can identify the middleman while being compatible with the existing protocol. Hijacking.
  • T2 s1+s2+S
  • T2 is the time required for the first terminal to send the completed data to the data received by the second terminal
  • s1+s2 is tampering for the middleman.
  • the preset value S may include multiple forms in addition to the representative duration.
  • the duration is used as an example.
  • the numerical values include various forms, as described in detail below.
  • the preset value may be pre-made in the fixed area of the terminal before the terminal leaves the factory, without negotiation, or may be negotiated between the first terminal and the second terminal, or may be generated by one party and sent to the other party. Alternatively, it may be written by the first terminal in a data packet specified by the protocol, and sent to the second terminal together when the first terminal sends data to the second terminal.
  • This preset value is crucial for recognizing the hijacking of the middleman, so to prevent the preset The value is falsified.
  • This embodiment provides several methods for obtaining preset values. For details, refer to the detailed description of several ways for obtaining preset values in Embodiment 1.
  • the preset value may include at least: a preset duration, a preset number of cycles, a preset number of pulses, or a preset phase difference
  • the first terminal and the second terminal also have different timing statistics manners, and a manner of determining whether the value obtained by the timing reaches a preset value, and detailed descriptions are respectively made for various preset values.
  • the preset value may include: a preset duration, where the preset duration is greater than the second terminal performs data processing on the to-be-processed data in the received first data.
  • the duration since the second terminal needs to send the second data after the data is processed), and optionally, the preset duration may be less than or equal to the FWT; in step S34, the first terminal is timed.
  • the value reaches a preset value, including: the duration obtained by the first terminal after the completion of the sending of the first data reaches a preset duration; in step S33, the value obtained by the second terminal reaches a preset value, including: the second terminal The time period obtained after receiving the completion of the first data reaches a preset length of time.
  • the first terminal and the second terminal each have a timer, and the precise timing function is supported.
  • the duration obtained by the timer can be used to determine whether the preset duration or the preset duration is within the preset duration.
  • the second data is received only when the timing reaches 5 ⁇ 10 -3 s, indicating that there is no hijacking of the middleman, and thus the hijacking of the middleman can be identified.
  • the optional implementation is exemplified only by Bluetooth communication, other short-range communication methods are within the scope of protection of the present invention.
  • the terminal has no timing function, and in this embodiment, the first terminal always generates a carrier signal during the entire process of communicating between the first terminal and the second terminal. Therefore, in this embodiment, a timing statistical method different from the clock timing is proposed. In this embodiment, the number of the carrier signal, the number of pulses, and the phase difference can be calculated to count the timed value.
  • the method may include: a preset number of cycles of the carrier signal, a preset number of pulses of the carrier signal, and a phase difference of the preset carrier signal, wherein the preset number of cycles of the carrier signal and the preset carrier signal The number of pulses and the phase difference of the preset carrier signal are respectively longer than the duration of the data processing by the second terminal for the data to be processed in the received first data, and, optionally, the preset The duration corresponding to the number of cycles, the duration corresponding to the number of preset pulses, and the duration of the preset phase difference may be less than or equal to FWT.
  • the preset value may include: a preset number of periods; in step S34, the value obtained by the first terminal reaches a preset value, including: the first terminal sends the first data from the transmission. Then, the number of cycles of the carrier signal that is continuously sent to the second terminal reaches a preset number of cycles; in step S33, the value obtained by the second terminal reaches a preset value, including: after the second terminal receives the first data from receiving The number of cycles of the continuously received carrier signal reaches a preset number of cycles.
  • the first terminal always generates a carrier signal, and when the first terminal needs to send data, for example, The first terminal sends the first data to transmit the first data to the second terminal, and when the first terminal does not need to send the data, the first terminal sends the carrier signal to the second terminal, where the carrier signal is No data is carried.
  • the first terminal and the second terminal both have a counter, and the number of periods of the download wave in the foregoing situation may be calculated.
  • the optional implementation manner provides an optional method for counting the time obtained by the statistical timing. The terminal and the second terminal do not need to use the clock timing, and can also achieve the purpose of accurate timing.
  • the obtained value can be accurate to ns, so that accurate statistical results can be achieved, and the alternative embodiment can be applied to a passive crystal card without a crystal.
  • the alternative embodiment is exemplified only by the NFC communication method, other short-range communication methods are all within the scope of protection of the present invention.
  • the preset value may include: a preset number of pulses; in step S34, the value obtained by the first terminal reaches a preset value, including: the first terminal The number of pulses of the carrier signal that is continuously sent to the second terminal after the completion of the first data is up to a preset number of pulses; in step S33, the value obtained by the second terminal reaches a preset value, including: the second terminal The number of pulses of the carrier signal continuously received after receiving the completion of the first data reaches a preset number of pulses.
  • the number of statistical pulses of the carrier signal that is, the number of peaks of the statistical carrier signal, compared with the number of periods of the statistical carrier signal, the number of statistical pulses can achieve further accurate statistics, and the optional embodiment Can be applied to passive smart cards without crystals.
  • the preset value may include: a preset phase difference; in step S34, the value obtained by the first terminal reaches a preset value, including: the carrier signal is in the first The phase difference between a phase and a second phase reaches a preset phase difference, wherein the first phase is a phase of a carrier signal at a time point at which the first terminal transmits the first data, and the second phase is a carrier signal allowed at the first terminal The phase of the time point at which the second data is started to be received; in step S33, the value obtained by the second terminal reaches a preset value, including: the phase difference between the third phase and the fourth phase of the carrier signal reaches a preset phase difference, The third phase is the phase of the carrier signal at the time point when the second terminal receives the first data, and the fourth phase is the phase of the carrier signal at the time point when the second terminal starts transmitting the second data.
  • the second terminal is a smart card.
  • the communication waveform between the two is a standard sine wave carrier, and the phase at the moment is recorded. 0 (ie, the first phase and the third phase are 0), when the carrier phase difference (ie, the phase difference between the third phase and the fourth phase) reaches (1/2+40) ⁇ , the smart card transmits the second data.
  • the card reader only allows the start of reception when the phase difference obtained by the timing reaches (1/2+40) ⁇ , and only the second data is received, indicating that there is no hijacking of the middleman, thereby recognizing the hijacking of the middleman. .
  • the terminal that supports the NFC communication mode is taken as an example.
  • the working frequency of the first terminal and the second terminal is 13.56 MHz.
  • the first terminal (for example, reading)
  • the card carrier always generates a carrier of 13.56MHz.
  • the phase can be divided into a period of 2 ⁇ , and the timing can be counted by phase. Accurate to 74/2 ⁇ ns, compared to the above-mentioned statistical carrier signal number of cycles and the number of pulses, the statistical phase difference can achieve further accurate statistics, and the optional implementation can be applied to passive crystalless smart card.
  • the alternative embodiment is exemplified only by the NFC communication method, other short-range communication methods are all within the scope of protection of the present invention.
  • the second terminal periodically sends the policy that the first terminal periodically receives, so that the first terminal can recognize whether there is a middleman hijacking even when receiving the T2 ⁇ FWT of the second data. The situation, to avoid the user's economic loss without knowing it.
  • an embodiment of the present invention further provides a data communication system.
  • the data communication system includes: a first terminal and a second terminal, and the first terminal and the second terminal perform the data communication method as in Embodiment 3. among them:
  • the first terminal is configured to send the first data to the second terminal, and start timing from the time when the first data is completed, where the first data includes at least data to be processed, and the second terminal is configured to receive the first data.
  • the second terminal is further configured to send the second data to the first terminal, where the second data is The data obtained after the second terminal processes the data to be processed; the first terminal is further configured to allow the second data to be received when the timed value reaches a preset value.
  • the communication manner between the first terminal and the second terminal includes: short-range wireless communication.
  • the first terminal is further configured to perform two-way identity authentication with the second terminal before the first terminal starts timing from the time when the first data is sent, after the two-way identity authentication is passed, Negotiating with the second terminal to obtain a transmission key;
  • the second terminal is further configured to generate a preset value, and encrypt the preset value by using the transmission key, and send the encrypted preset value to the first terminal; the first terminal is further configured to use the transmission key pair to encrypt The preset value is decrypted to get the preset value and saved; or,
  • the first terminal is further configured to generate a preset value, and encrypt the preset value by using the transmission key, and send the encrypted preset value to the second terminal; the second terminal is further configured to use the transmission key pair to encrypt The preset value is decrypted to get the preset value and saved.
  • the first terminal is further configured to perform two-way identity authentication with the second terminal before the first terminal starts timing from the time when the first data is sent.
  • the second terminal is further configured to: after the two-way identity authentication is passed, generate a preset value, and encrypt the preset value by using the public key of the first terminal, and send the encrypted preset value to the first terminal; the first terminal Also used to utilize the first terminal The private key decrypts the encrypted preset value to obtain a preset value and saves it;
  • the first terminal is further configured to: after the two-way identity authentication is passed, generate a preset value, and encrypt the preset value by using the public key of the second terminal, and send the encrypted preset value to the second terminal; the second terminal It is also used to decrypt the encrypted preset value by using the private key of the second terminal to obtain a preset value, and save it.
  • the first terminal is further configured to generate a preset value before the first terminal sends the first data to the second terminal, where the first data further includes: a preset value and a preset value Obtained tamper-proof check value;
  • the second terminal is further configured to: after receiving the first data, obtain a preset value and a tamper-proof check value from the first data, and perform verification on the tamper-proof check value, and save the pre-check after the verification is passed Set the value.
  • the preset value includes: a preset duration, the preset duration is less than or equal to a frame waiting time FWT specified by a communication protocol used by the first terminal and the second terminal;
  • the value obtained by the first terminal reaches a preset value, and the time length obtained by the first terminal after the completion of the first data is up to a preset duration;
  • the value obtained by the second terminal reaches a preset value, and the time length obtained by the second terminal after receiving the completion of the first data reaches a preset duration.
  • the first terminal is further configured to: when the first terminal communicates with the second terminal, always generate a carrier signal;
  • the preset value includes: a preset number of periods, and the preset period of the number of periods is less than or equal to the FWT specified by the communication protocol used by the first terminal and the second terminal; the value obtained by the first terminal reaches a preset value.
  • the method includes: the number of cycles of the carrier signal that is sent by the first terminal to the second terminal after the first data is sent reaches a preset number of cycles; and the value obtained by the second terminal reaches a preset value, including: Receiving, by the terminal, the number of cycles of the carrier signal continuously received after receiving the first data reaches a preset number of cycles; or
  • the preset value includes: a preset number of pulses, and the preset pulse number corresponds to a time length less than or equal to a FWT specified by a communication protocol used by the first terminal and the second terminal; wherein: the first terminal obtains a value that is pre- The value includes: the number of pulses of the carrier signal that is sent by the first terminal to the second terminal after the first data is transmitted reaches a preset number of pulses; and the value obtained by the second terminal reaches a preset value, including: Receiving, by the second terminal, the number of pulses of the carrier signal continuously received after receiving the first data reaches a preset number of pulses; or
  • the preset value includes: a preset phase difference, and the preset phase difference corresponds to a duration less than or equal to the FWT specified by the communication protocol used by the first terminal and the second terminal; wherein: the value obtained by the first terminal reaches a preset value
  • the method includes: the phase difference between the first phase and the second phase of the carrier signal reaches a preset phase difference, wherein the first phase is a phase at which the carrier signal transmits the first data at the first terminal, and the second phase is The phase of the carrier signal at the time point at which the first terminal is allowed to start receiving the second data; the value obtained by the second terminal timing reaches a preset value, including: the phase difference between the third phase and the fourth phase of the carrier signal reaches a preset phase a difference, wherein the third phase is a phase of a carrier signal at a time point at which the second terminal receives the first data, and the fourth phase is a carrier signal, and the second terminal starts transmitting the second number According to the phase of the time point.
  • the second terminal periodically sends the policy that the first terminal periodically receives, so that the first terminal can recognize whether there is a middleman hijacking even when receiving the second data T2 ⁇ FWT. The situation, to avoid the user's economic loss without knowing it.
  • portions of the invention may be implemented in hardware, software, firmware or a combination thereof.
  • multiple steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system.
  • a suitable instruction execution system For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or combination of the following techniques well known in the art: having logic gates for implementing logic functions on data signals. Discrete logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
  • each functional unit in each embodiment of the present invention may be integrated into one processing module, or each unit may exist physically separately, or two or more units may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
  • the integrated modules, if implemented in the form of software functional modules and sold or used as stand-alone products, may also be stored in a computer readable storage medium.
  • the above mentioned storage medium may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Toxicology (AREA)
  • Electromagnetism (AREA)
  • General Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

一种数据通讯方法及系统,该方法包括:第一终端向第二终端发送第一数据,并从发送完成第一数据时开始计时(S11),其中,第一数据至少包括待处理数据;第二终端接收第一数据,并从接收完成第一数据时开始计时(S12);当第二终端计时得到的数值达到预设数值时,第二终端将对待处理数据进行数据处理后得到的第二数据发送至第一终端(S13);第一终端计时得到的数值在预设数值的有效范围内,第一终端允许开始接收第二数据(S14)。通过第二终端定时发送第一终端定时接的策略,使得第一终端即使在接收到第二数据的T2<FWT时,仍然可以识别出中间人的劫持。

Description

一种数据通讯方法及数据通讯系统
相关申请的交叉引用
本申请基于申请号为201610640015.3,申请日为2016年8月5日的中国专利申请,以及申请号为201610639441.5,申请日为2016年8月5日的中国专利申请,并要求上述中国专利申请的优先权,上述中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本发明涉及一种电子技术领域,尤其涉及一种数据通讯方法及数据通讯系统。
背景技术
目前现有技术中,采用非接触式的读卡方式的终端都是基于ISO14443、ISO15693等协议进行数据传输的,以读卡器与智能卡之间的读卡过程为例,基于上述协议,在读卡器与智能卡的读卡过程中,在读卡器发送了指令数据以后,会有一个帧等待时间(Frame Waiting Time,FWT),表明了读卡器允许等待接收智能卡响应数据的最大时间范围。也就是说在读卡器向智能卡发送了指令以后,读卡器就在等待接收智能卡的响应数据,只要是在帧等待时间FWT之内返回的数据,读卡器就会接收。
对于现有的智能卡通讯协议,可能会存在以下问题:对于读卡过程,如图1所示,正常情况下商户读卡器将数据发送给用户的智能卡,用户的智能卡接收到数据以后开始响应并处理数据(处理数据时间为t1),处理结束以后,立即将响应数据发送给商户读卡器,忽略线路传输上的微小时间(数量级很小,便于简化计算),因而,商户读卡器发送数据完成到接收到用户的智能卡反馈的数据所需要的时间T1=t1。而如果有黑客进行中间人攻击的情况下,如图2所示,中间人的智能卡劫持商户读卡器的请求数据,将商户读卡器发来的数据转发至中间人的读卡器,中间人的读卡器可能会篡改请求数据,将篡改后的数据发送至用户的智能卡(从中间人的智能卡劫持商户读卡器的请求数据到中间人的读卡器将篡改后的数据发送至用户的读卡器的时间为tw1),用户的智能卡接收到篡改后的数据后,处理数据(处理数据时间为t1),将处理后的数据发送至中间人的读卡器,中间人的读卡器可能会篡改用户的智能卡返回的处理数据,并通过中间人的智能卡将篡改后的数据发送至商户读卡器(从中间人的读卡器接收到用户的智能卡返回的处理数据到通过中间人的智能卡将篡改后的数据发送至商户读卡器的时间为tw2),那么,商户读卡器从发送完成数据到接收到用户智能卡反馈的数据所需要的时间T2=t1+tw1+tw2。
根据现有的智能卡通讯协议,只要是T2<FWT,商户读卡器就会接收中间人的智能卡发来的数据并进行后续的操作(如交易流程),这样就存在中间人劫持而商户读卡器毫不知情的危险,造成商户的经济损失。
发明内容
本发明旨在解决上述问题之一。
本发明的主要目的在于提供一种数据通讯方法。
本发明的另一目的在于提供一种数据通讯系统。
为达到上述目的,本发明的技术方案具体是这样实现的:
本发明一方面提供了一种数据通讯方法,包括:第一终端向第二终端发送第一数据,并从发送完成所述第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据;所述第二终端接收所述第一数据,并从接收完成所述第一数据的时间点开始计时;当所述第二终端计时得到的数值达到预设数值时,所述第二终端将第二数据发送至所述第一终端,其中,所述第二数据为所述第二终端对所述待处理数据进行数据处理后得到的数据;所述第一终端计时得到的数值在所述预设数值的有效范围内,则所述第一终端允许开始接收所述第二数据。
本发明另一方面提供了一种数据通讯系统,包括:第一终端,用于向第二终端发送第一数据,并从发送完成所述第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据;所述第二终端,用于接收所述第一数据,并从接收完成所述第一数据的时间点开始计时;所述第二终端,还用于当所述第二终端计时得到的数值达到预设数值时,将第二数据发送至所述第一终端,其中,所述第二数据为所述第二终端对所述待处理数据进行数据处理后得到的数据;所述第一终端,还用于若所述第一终端计时得到的数值在所述预设数值的有效范围内,则允许开始接收所述第二数据。
本发明另一方面还提供了一种数据通讯方法,包括:第一终端向第二终端发送第一数据,并从发送完成所述第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据;所述第二终端接收所述第一数据,并从接收完成所述第一数据的时间点开始计时;在所述第二终端计时得到的数值达到预设数值时,所述第二终端将第二数据发送至所述第一终端,其中,所述第二数据为所述第二终端对所述待处理数据进行数据处理后得到的数据;在所述第一终端计时得到的数值达到所述预设数值时,所述第一终端允许开始接收所述第二数据。
本发明另一方面还提供了一种数据通讯系统,包括:第一终端,用于向第二终端发送第一数据,并从发送完成所述第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据;所述第二终端,用于接收所述第一数据,并从接收完成所述第一数据的时间点开始计时;所述第二终端,还用于在所述第二终端计时得到的数值达到预设数值时,将第二数据发送至所述第一终端,其中,所述第二数据为所述第二终端对所述待处理数据进行数据处理后得到的数据;所述第一终端,还用于在计时得到的数值达到所述预设数值时,允许开始接收所述第二数据。
由上述本发明提供的技术方案可以看出,本发明提供的数据通讯方法及系统,通过第二终端定时(计时得到的数值达到预设数值S)发送数据,第一终端定时(计时得到的数 值达到预设数值或在预设数值的有效范围[S,S+2ΔS]内)接收第二终端返回的数据的策略避免现有技术中的问题,由于第一终端只在计时得到的数值达到预设数值或在预设数值的有效范围[S,S+2ΔS]内允许接收第二终端返回的数据,在该预设数值之外或在该预设数值的有效范围之外均不允许接收第二终端返回的数据。由此,如果第一终端在计时得到的数值达到预设数值时,或者如果在该预设数值的有效范围内,允许开始接收且接收到所述第二数据,则说明不存在中间人的劫持,但如果第一终端在计时得到的数值达到预设数值时,或者如果在该预设数值的有效范围内允许开始接收但没有接收到所述第二数据,则说明出现了中间人劫持的情况,使得第一终端即使在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况,避免用户在毫不知情的情况下造成经济损失。
根据下文结合附图对本发明具体实施例的详细描述,本领域技术人员将会更加明了本发明的上述以及其他目的、优点和特征。
附图说明
后文将参照附图以示例性而非限制性的方式详细描述本发明的一些具体实施例。附图中相同的附图标记标示了相同或类似的部件或部分。本领域技术人员应该理解,这些附图未必是按比例绘制的。附图中:
图1为本发明背景技术中在正常情况下商户读卡器发送数据完成到接收到用户的智能卡反馈的数据所需要的时间示意图;
图2为本发明背景技术中在发生中间人劫持的情况下商户读卡器发送数据完成到接收到用户的智能卡反馈的数据所需要的时间示意图;
图3为本发明实施例1提供的数据通讯方法的流程图;
图4为本发明实施例1提供的一种具体的第一终端与第二终端协商预设数值的流程图;
图5为本发明实施例1提供的一种具体的第一终端与第二终端协商预设数值的流程图;
图6为本发明实施例2提供的一种数据通讯系统的结构示意图;
图7为本发明实施例3提供的数据通讯方法的流程图。
具体实施方式
实施例1
图3为根据本发明实施例1的一种数据通讯方法的流程图。参见图3,该方法至少包括步骤S11至步骤S14。
步骤S11,第一终端向第二终端发送第一数据,并从发送完成第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据。
本实施例中,第一终端与第二终端之间的通信方式包括:短距离无线通信方式,具体地,短距离无线通信方式至少包括:NFC(Near Field Communication,近场通讯)、 Wi-Fi(Wireless Fidelity,无线高保真)、UWB(UltraWideband,超宽带)、Zigbee、RFID(Radio Frequency Identification,无线射频识别)、红外传输和蓝牙。因此,第一终端与第二终端之间的通信距离可以短至几厘米长至几百米。基于上述短距离无线通信方式,对应于不同的通信方式,第一终端与第二终端之间通信也会采用对应的通讯协议,以实现两者之间的无线数据传输。其中,作为一种可选的实施方式,第一终端包括读取装置,第二终端包括应答装置,读取装置与应答装置可以为支持非接触式的读卡方式的终端,例如,读取装置可以为POS机、ATM机、身份证阅读器等读卡器类的终端,应答装置可以为智能密钥设备(如工行U盾、农行Key宝)、智能卡、身份证等终端,采用上述非接触式的读卡方式的终端,如读卡器与智能卡之间、读卡器与身份证之间都可以采用协议ISO14443和ISO15693进行数据传输,短距离无线通信方式可以包括:ISO14443和ISO15693协议支持的通信方式;此外,读取装置与应答装置也可以为移动终端、PC、掌上电脑、智能设备等支持短距离无线通信方式的终端。
在本步骤中,作为一种可选的实施方式,以第一终端为读卡器,第二终端为智能卡为例,第一数据中的待处理数据可以为读卡请求数据,当然,第一数据中的待处理数据并不限于此,以第一终端与第二终端均为移动终端为例,第一数据中的待处理数据也可以是请求第二终端返回图片的请求数据等等,本实施例并不对第一数据中的待处理数据进行过多限制,只要是第一终端向第二终端发起的请求数据即可。
基于背景技术中提出的问题,本实施例为了能够在T2<FWT时,仍然可以识别出中间人的劫持,采用第一终端定时接收第二终端定时发送的策略,所以,在本步骤中,第一终端从发送完成第一数据的时间点开始计时,在计时得到的数值在预设数值的有效范围内时,如果接收到第二终端返回的数据,则说明不存在中间人的劫持,如果没有接收到,则可以识别出存在中间人的劫持。
步骤S12,第二终端接收第一数据,并从接收完成第一数据的时间点开始计时。
在本实施例中,当第二终端接收到第一数据后,并不会像现有技术那样在对第一数据处理完成后马上将处理后的数据发送至第一终端,而是开始计时,采用第一终端定时接收第二终端定时发送的策略,在计时得到的数值达到预设数值时,第二终端才发送对第一数据中的待处理数据处理后得到的第二数据,即定时发送(参见步骤S13),使得第一终端在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况。
步骤S13,当第二终端计时得到的数值达到预设数值时,第二终端将第二数据发送至第一终端,其中,第二数据为第二终端对第一数据中的待处理数据进行数据处理后得到的数据。
本实施例中,对第二数据并不做限制,第二数据是对第一数据中的待处理数据进行处理后得到的数据。以第二终端为智能卡,第一终端为读卡器为例,第二数据可以为第一终端请求读取的智能卡的数据内容,以第一终端与第二终端均为移动终端为例,第一数据中的待处理数据为请求图片的数据,第二数据即为图片数据。如步骤S12中所述,第二终端 在接收完成第一数据的时间点开始计时,本步骤中,在计时得到的数值达到预设数值S时,第二终端向第一终端发送第二数据,保证定时发送。
步骤S14,第一终端计时得到的数值在所述预设数值的有效范围内,则第一终端允许开始接收所述第二数据。
其中,作为一种可选的实施方式,预设数值的有效范围为[S,S+2ΔS],其中,S为预设数值,ΔS由第一终端与第二终端之间采用的通信方式所支持的最大通信距离确定。
本实施例中,正如前面提到的,第一终端与第二终端之间采用的通信方式可以为短距离无线通信,可以包括多种通信方式,而每种通信方式支持的最大通信距离是不同的,例如,NFC的工作频率为13.56MHz,支持的通信距离在20cm以内,而蓝牙的工作频率为2.4GHz,支持的通信距离可以达到20m,WiFi可以达到100m。ΔS可以理解为经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所需的数值,例如,经过该最大通信距离传输第一数据所需的时长等,由于每种通信方式支持的最大通信距离不同,对应的,ΔS的取值也会不同,当然ΔS还可以包括其他含义,具体参见下文的详细描述。
需要说明的是,第一数据是以字节的方式连续发送给第二终端的,第一终端连续发送第一数据的第一字节、第二字节……最后一个字节,第二终端连续接收第一数据的第一字节、第二字节……最后一个字节。由于第一终端与第二终端之间采用短距离通信方式,第一终端开始发送第一数据各个字节的过程中,第二终端已经开始接收第一数据的各个字节,考虑到终端接收单个字节的时长数量级较小,可以忽略不计,因而,第一数据的第一字节在到达第二终端时,第一数据的最后一个字节还没有发送,即第一终端还没有发送完成第一数据。在不考虑路上传输时间的情况下,我们可以认为第一终端发送第一数据与第二终端接收第一数据是同时进行的,即第一终端发送完成第一数据的时刻即为第二终端接收完成第一数据的时刻,在考虑路上传输时间的情况下,第一终端计时得到的数值的最大值可以达到S+2ΔS,即考虑了第一终端与第二终端之间相互发送的数据在路上传输的时间(根据通信方式支持的最大距离计算得到的最大时长为2ΔS),所以,在步骤S11中在第一终端发送完成第一数据的时间点开始计时,在步骤S12中,在第二终端接收完成第一数据的时间点开始计时,在不考虑路上传输时间的情况下,没有中间人的劫持,第一终端应该能够在计时得到的数值达到S时接收到第二数据,在考虑路上传输时间的情况下,没有中间人的劫持,第一终端应该能够在计时得到的数值大于S且小于或等于S+2ΔS时开始接收第二数据。
基于背景技术中提出的针对现有的智能卡通讯协议存在的问题,本实施例提供了一种数据通讯方法。该数据通讯方法通过第二终端定时(计时得到的数值达到预设数值S)发送数据,第一终端定时(计时得到的数值在预设数值的有效范围[S,S+2ΔS]内)接收第二终端返回的数据的策略避免现有技术中的问题,其中,第一终端可以理解为背景技术中的商户读卡器,第二终端可以理解为背景技术中的用户智能卡,由于第一终端只在计时得到的数值在预设数值的有效范围[S,S+2ΔS]内允许接收第二终端返回的数据,在该预设数值 的有效范围之外均不允许接收第二终端返回的数据。由此,如果在该预设数值的有效范围内,允许开始接收且接收到所述第二数据,则说明不存在中间人的劫持,但如果在该预设数值的有效范围内允许开始接收但没有接收到所述第二数据,则说明出现了中间人劫持的情况。本实施例中,S+2ΔS≤FWT,其中,FWT为第一终端与第二终端采用的通信协议规定的帧等待时间,例如协议ISO14443和ISO15693规定的帧等待时间FWT,这样,第一终端(例如读卡器)会在FWT的时间内等待智能卡返回数据,同时实施本实施例提供的定时接收的方案,由此,本实施例提供的方法可以在兼容现有协议的同时还可以识别出中间人的劫持。在出现被中间人挟持的情况时,即便T2<FWT,但是,在不忽略两个终端之间来回传输数据所需的时长2ΔS的情况下,以S为预设的时长为例,第二终端计时达到S才发送数据,因此,T2=s1+s2+S+2ΔS,其中,T2为第一终端从发送完成数据到接收到第二终端反馈的数据所需要的时间,s1+s2为中间人做篡改处理所需的时间(请参考背景技术中tw1、tw2,tw1对应s1,tw2对应s2),T2超过了预设数值的有效范围的最大值S+2ΔS,所以,第一终端拒绝接收第二终端返回的数据,中断与第二终端的通讯,由此,即便T2<FWT,第一终端也可以识别出中间人的劫持。需要说明的是,本实施例中S与ΔS除了代表时长之外,还可以包括多种形式,此处,为了便于理解,仅以时长为例进行说明,本实施例下文会提到S与ΔS包括的多种形式,具体参见下文描述。
在本实施例中,预设数值S可以在终端出厂之前预制存储在终端的固定区域中,无需协商,也可以由第一终端与第二终端协商得到,或者,也可以由一方生成发给对方,或者,还可以由第一终端写在协议规定的数据包中,在第一终端向第二终端发送数据时一起发送给第二终端。其中,出厂预制的预设数值虽然无需协商、无需生成,但第一终端与第二终端每次的数据输出均按照该预设数值定时收发,其弊端就是该预设数值不能变化,不够灵活、随机,安全性较低。而后面几种获取预设数值S的方式可以随机生成预设数值,相比于出厂预制的预设数值,更灵活,随机,安全性更高。该预设数值S对于能否识别出中间人的劫持至关重要,因此,为了防止该预设数值S被篡改,本实施例提出了几种获取预设数值S的方式,下面便对以下几种获取预设数值S的方式进行详细说明。
作为本实施例中一种可选的实施方式,本实施例可以通过以下步骤来实现协商得到预设数值,可以在第一终端向第二终端发送第一数据之前的任何时机进行协商,相比于出厂预制的预设数值,更灵活,随机,安全性更高。具体地,在第一终端从发送完成第一数据的时间点开始计时之前,本实施例提供的方法还包括:
第一终端与第二终端进行双向的身份认证,在所述双向的身份认证通过后,第一终端与第二终端协商得到传输密钥;
第二终端生成该预设数值,并利用所述传输密钥对该预设数值加密,将加密后的预设数值发送至第一终端;第一终端利用所述传输密钥对加密后的预设数值解密得到该预设数值,并保存;或者,第一终端生成该预设数值,并利用所述传输密钥对该预设数值加密,将加密后的预设数值发送至第二终端;第二终端利用所述传输密钥对加密后的预设数值解 密得到该预设数值,并保存。
由此,本实施例可以通过第一终端与第二终端双向的身份认证保证第一终端以及第二终端的合法身份,进一步地协商得到传输密钥,利用该传输密钥对预设数值加解密以保证传输过程的安全性,从而可以防止协商得到的预设数值被非法篡改,保证预设数值的安全性。此外,无论是第一终端还是第二终端,在接收到对方发送的预设数值后进行保存可以在下次数据通信时继续使用该预设数值,通过保存预设数值,两个终端无需再执行协商预设数值的交互流程,大大提高了数据传输效率。
具体地,该可选实施方式中协商得到预设数值的方式可以通过多种方式来实现,本实施例仅举一例,以便于清楚地理解可选实施方式中协商得到预设数值的方式。如图4所示,本实施例提供了一种具体的第一终端与第二终端协商预设数值的流程,具体包括以下步骤:
S110,第一终端向第二终端发起认证请求,所述认证请求中携带有随机数R1以及第一终端的数字证书。
其中,随机数R1为第一终端生成的单次认证数据,可以防止其他非法设备对第一终端的重放攻击。
S111,第二终端接收该认证请求,对第一终端的数字证书进行验证,在验证通过后,利用第二终端的私钥对随机数R1进行签名生成签名数据S1,并生成随机数R2,利用第一终端的数字证书中的公钥对R2加密得到密文E1。
其中,随机数R2为第二终端生成的单次认证数据,可以防止其他非法设备对第二终端的重放攻击。
S112,第二终端将第二终端的数字证书、签名数据S1以及密文E1发送至第一终端。
S113,第一终端对第二终端的数字证书进行验证,在验证通过后,利用数字证书中的公钥对签名数据S1验签,在验签通过后,对密文E1解密得到R2,利用第一终端的私钥对R2签名生成签名数据S2,并生成随机数R3,利用第二终端的公钥对R3加密得到密文E2,基于R2R3生成传输密钥K。
其中,通过第一终端对第二终端的签名数据S1的验签,可以确保第二终端身份的合法性。此外,利用双方各自生成的随机数生成传输密钥,可以保证即使有黑客截获某一方的随机数,但由于没有对方的随机数也无法生成该传输密钥,进而能保证传输密钥不会被轻易获取。
S114,第一终端将签名数据S2和密文E2发送至第二终端。
S115,第二终端利用第一终端的数字证书中的公钥对签名数据S2验签,在验签通过后,对密文E2解密得到R3,基于R2R3生成传输密钥K。
其中,通过第二终端对第一终端的签名数据S2的验签,可以确保第一终端身份的合法性。
S116,第一终端生成预设数值S,利用传输密钥K加密得到密文E3。
S117,第一终端将E3发送至第二终端。
S118,第二终端接收密文E3,并利用传输密钥K对E3解密得到预设数值S,并保存预设数值S。
在该可选实施方式中,从步骤S110~步骤S115完成了第一终端与第二终端的双向认证以及协商传输密钥,在步骤S116~S118中,第一终端与第二终端执行的操作可以互换,即,可以由第二终端生成预设数值S,利用K加密S得到密文E3,发送至第一终端,第一终端利用传输密钥K解密得到预设数值S,并保存。
作为本实施例中另一种可选的实施方式,本实施例可以通过以下步骤来实现由一方生成发给对方得到预设数值的方式,可以在第一终端向第二终端发送第一数据之前的任何时机进行协商,相比于出厂预制的预设数值,更灵活,随机,安全性更高。具体地,在第一终端从发送完成第一数据的时间点开始计时之前,本实施例提供的方法还包括:
第一终端与第二终端进行双向的身份认证;
在所述双向的身份认证通过后,第二终端生成该预设数值,并利用第一终端的公钥对该预设数值加密,将加密后的预设数值发送至第一终端;第一终端利用其私钥对加密后的预设数值解密得到该预设数值,并保存;或者,在所述双向的身份认证通过后,第一终端生成该预设数值,并利用第二终端的公钥对该预设数值加密,将加密后的预设数值发送至第二终端;第二终端利用其私钥对加密后的预设数值解密得到该预设数值,并保存。
由此,本实施例可以通过第一终端与第二终端双向的身份认证保证第一终端以及第二终端的合法身份,进一步利用公私钥实现对预设数值加解密以保证传输过程的安全性,从而可以防止一方生成的预设数值被非法篡改,保证预设数值的安全性。相比于上面的可选实施方式,该可选实施方式利用第一终端和第二终端本身的公私钥对实现对预设数值的加解密,无需再生成传输密钥,减少了交互步骤,缩短了获得预设数值的时间,提高了效率。此外,无论是第一终端还是第二终端,在接收到对方发送的预设数值后进行保存可以在下次数据通信时继续使用该预设数值,通过保存预设数值,两个终端无需再执行协商预设数值的交互流程,大大提高了数据传输效率。
具体地,该可选实施方式中得到预设数值的方式可以通过多种方式来实现,本实施例仅举一例,以便于清楚地理解可选实施方式中得到预设数值的方式。如图5所示,本实施例提供了一种具体的第一终端与第二终端协商预设数值的流程,具体包括以下步骤:
S120,第一终端向第二终端发起认证请求,所述认证请求中携带有随机数R1;
其中,随机数R1为第一终端生成的单次认证数据,可以防止其他非法设备对第一终端的重放攻击。
S121,第二终端接收该认证请求,并利用其私钥对随机数R1进行签名生成签名数据S1,并生成随机数R2;
其中,随机数R2为第二终端生成的单次认证数据,可以防止其他非法设备对第二终端的重放攻击。
S122,第二终端将第二终端的数字证书、签名数据S1以及随机数R2发送至第一终端;
S123,第一终端对第二终端的数字证书进行验证,在验证通过后,利用数字证书中的公钥对签名数据S1验签,在验签通过后,利用第一终端的私钥对R2签名生成签名数据S2;
其中,通过第一终端对第二终端的签名数据S1的验签,可以确保第二终端身份的合法性。
S124,第一终端将其数字证书和签名数据S2发送至第二终端;
S125,第二终端对第一终端的数字证书进行验证,在验证通过后,利用数字证书中的公钥对签名数据S2验签;
其中,通过第二终端对第一终端的签名数据S2的验签,可以确保第一终端身份的合法性。
S126,在验签通过后,第二终端随机生成预设数值S,利用第一终端的公钥对预设数值S加密生成密文E;
S127,第二终端将E发送至第一终端;
S128,第一终端接收密文E,并利用其私钥对E解密得到预设数值S,并保存预设数值S。
在该可选实施方式中,从步骤S120~步骤S125实现了第一终端与第二终端之间的双向认证,并在双向的身份认证通过后,第二终端生成预设数值,在步骤S126~S128中,第一终端与第二终端执行的操作可以互换,即,可以由第一终端生成预设数值S,利用第二终端的公钥对预设数值S加密得到密文E,发送至第二终端,第二终端利用其私钥对E解密得到预设数值S,并保存。与图4所示的获取预设数值的方式相比,该可选实施方式无需协商传输密钥,而是直接利用第一终端与第二终端本身的公私钥进行加解密,减少了协商传输密钥的交互流程,可以提高获得预设数值的效率。
作为本实施例中第三种可选的实施方式,本实施例可以通过以下步骤来实现由第一终端将预设数值写入协议规定的数据包中,在第一终端向第二终端发送数据时一起发送给第二终端来实现双方得到该预设数值,具体地,在步骤S11中第一终端向第二终端发送第一数据之前,本实施例提供的方法还包括:第一终端生成预设数值;在第一终端发送给第二终端的第一数据中至少还包括:该预设数值以及基于该预设数值计算得到的防篡改校验值;在步骤S12中,第二终端接收第一数据之后,本实施例提供的方法还包括:第二终端从第一数据中获取该预设数值以及防篡改校验值,并对防篡改校验值进行校验,在校验通过后,保存该预设数值。
在该可选实施方式中,第一终端可以随机生成一个预设数值,根据协议规定的数据包的格式,将该预设数值和防篡改校验值写入预定字段中,或者,也可以增加新的字段,将该预设数值和防篡改校验值写入新增的字段中,在第一终端向第二终端发送第一数据时,携带在第一数据中的数据包中发送至第二终端。该防窜改校验值是基于预设数值计算得到的,例如,该防窜改校验值可以为基于该预设数值计算得到的签名数据,即对预设数值计算生成摘要,并利用第一终端的私钥对摘要加密生成签名数据,第二终端在对防窜改校验 值进行校验就可以利用第一终端的公钥对该签名数据进行验签,如果验签通过,则校验通过,说明预设数值没有被篡改。又例如,该防窜改校验值可以为基于预设数值采用MAC算法计算得到的MAC值,第二终端在对防窜改校验值进行校验时也可以采用相同的MAC算法计算得到一个MAC值,比较两个MAC值是否一致,如果一致,则校验通过,说明预设数值没有被篡改。
需要说明的是,第二终端在接收完成第一数据后,开始计时,并从第一数据中获取预设数值,如果对防篡改校验值校验通过,则所述第二终端在计时得到的数值达到预设数值后发送第二数据至第一终端,后续如果第一终端在预设数值的有效范围内接收不到第二终端返回的第二数据,则说明出现了中间人劫持;如果对防窜改校验值的校验不通过,第二终端会停止计时,此时说明已经有可能出现了中间人劫持数据的情况。由此,在该可选实施方式中,通过防窜改校验值也可以实现中间人劫持的识别,而且,一旦预设数值被篡改,校验就不能通过,进而可以保证预设数值不会被非法篡改,保证预设数值的安全。
此外,在本实施例中,作为一种可选的实施方式,预设数值可以至少包括:预设的时长、预设的周期个数、预设的脉冲个数或者预设的相位差,因此,本实施例中,第一终端和第二终端也相应地有不同的计时统计方式,以及判断计时得到的数值是否达到预设数值或在预设数值的有效范围内的方式,下面分别针对各种预设数值进行详细的说明。
作为一种本实施例可选的实施方式,预设数值可以包括:预设的时长,其中,该预设的时长大于第二终端对接收到的第一数据中的待处理数据进行数据处理的时长(由于第二终端需要在处理数据之后达到计时得到的数值才发送第二数据),此外,可选地,S+2ΔS≤FWT;ΔS为在第一终端与第二终端之间的距离为两者采用的通信方式所支持的最大通信距离时,第一终端传输数据至第二终端所需的时长,在步骤S14中,第一终端计时得到的数值在预设数值的有效范围内,包括:第一终端从发送完成第一数据之后计时得到的时长在[S,S+2ΔS]范围内;在步骤S13中,第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后计时得到的时长达到预设的时长。
在该种可选实施方式中,第一终端与第二终端中均具有计时器,支持精确计时功能,可以通过计时器计时得到的时长判断是否达到预设时长或是否在预设时长的有效范围内。例如,第二终端可以为具有晶振的智能卡,该具有晶振的智能卡可以通过其内部时钟计时的时长的方式来统计计时,其计时精确度由智能卡的时钟精确度决定。例如,S=5×10-3s,以蓝牙为例,支持的最大传输距离20m的传输时长ΔS为60×10-9s,则第二终端在计时达到5×10-3s时发送第二数据,第一终端只有在[5×10-3s,(5×10-3+1.2×10-7)s]才允许开始接收第二数据,只有在该预设数值的有效范围内接收到第二数据才说明没有出现中间人的劫持的情况,由此,可以识别出中间人的劫持。虽然,该可选实施方式仅以蓝牙通信方式进行了举例说明,但其他短距离通信方式均属于本发明保护的范围。
对于无源、无晶振的终端(如智能卡)来说,该终端没有计时功能,而在本实施例中,由于在第一终端与第二终端通信的整个过程中,第一终端始终产生载波信号,因此,本实 施例中提出了有别与时钟计时的计时统计方式,本实施例还可以通过计算载波信号的周期个数、脉冲个数以及相位差来统计计时得到的数值,预设数值具体可以包括:预设的载波信号的周期个数、预设的载波信号的脉冲个数以及预设的载波信号的相位差,ΔS具体可以指示载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的周期个数、脉冲个数,以及相位变化值,其中,无论采用上述哪一种计时统计方式,S+2ΔS的和对应的时长均大于第二终端对接收到的第一数据中的待处理数据进行数据处理的时长,此外,可选地,S+2ΔS的和对应的时长均可以小于或等于FWT。作为一种可选的实施方式,预设数值可以包括:预设的周期个数;ΔS为载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的周期个数;在步骤S14中,第一终端计时得到的数值在预设数值的有效范围内,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的周期个数在所述[S,S+2ΔS]范围内;步骤S13中,第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的周期个数达到预设的周期个数。
在本实施例中,第一终端始终在产生载波信号,在第一终端需要发送数据时,例如,第一终端发送第一数据是将第一数据调制在载波信号上发送至第二终端的,在第一终端不需要发送数据时,第一终端发送该载波信号至第二终端,该载波信号上没有携带数据。该可选实施方式中,第一终端与第二终端均具有计数器,可以计算上述情况下载波的周期个数,该可选实施方式提供了一种可选的统计计时得到的数值的方式,第一终端与第二终端无需使用时钟计时,也可以达到精确计时的目的,举例来说,以支持NFC通信方式的终端为例,第一终端与第二终端的工作频率为13.56MHZ,在第一终端与第二终端通信过程中,第一终端(例如读卡器)始终产生13.56MHz的载波,载波的时间周期T是固定的,T=1/13.56MHz,约等于74ns,以周期来统计计时得到的数值,单位可以精确到ns,由此可以达到精确统计的效果,而且,该可选实施方式可以适用于无源无晶振的智能卡。虽然,该可选实施方式仅以NFC通信方式进行了举例说明,但其他短距离通信方式均属于本发明保护的范围。
此外,作为另一种本实施例可选的实施方式,预设数值可以包括:预设的脉冲个数;ΔS为载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的脉冲个数;在步骤S14中,第一终端计时得到的数值在预设数值的有效范围内,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的脉冲个数在[S,S+2ΔS]范围内;在步骤S13中,第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的脉冲个数达到预设的脉冲个数。
统计载波信号的脉冲个数即统计载波信号的峰值的个数,相比于上述统计载波信号的周期个数的方式,统计脉冲个数可以达到进一步精确统计的效果,而且,该可选实施方式可以适用于无源无晶振的智能卡。
此外,作为另一种本实施例可选的实施方式,预设数值可以包括:预设的相位差;ΔS 为载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的相位变化值;在步骤S14中,第一终端计时得到的数值在预设数值的有效范围内,包括:载波信号在第一相位与第二相位的相位差在[S,S+2ΔS]范围内,其中,第一相位为载波信号在第一终端发送完成第一数据的时间点的相位,第二相位为载波信号在第一终端允许开始接收第二数据的时间点的相位;在步骤S13中,第二终端计时得到的数值达到预设数值,包括:载波信号在第三相位与第四相位的相位差达到预设的相位差,其中,第三相位为载波信号在第二终端在接收完成第一数据的时间点的相位,第四相位为载波信号在第二终端开始发送所述第二数据的时间点的相位。
例如,第一终端与第二终端可以采用之前提到的获得预设数值的方式,协商或一方生成预设的相位差
Figure PCTCN2017096025-appb-000001
在以第一终端为读卡器,第二终端为智能卡为例,读卡器在发送完成第一数据后以及智能卡在接收完成该第一数据后,两者之间的通信波形就是标准的正弦波载波,记录此刻的相位为0(即第一相位与第三相位为0),在载波相位差(即第三相位与第四相位的相位差)达到(1/2+40)π时,智能卡发送第二数据,此时,读卡器可以通过计时得到的相位差在预设数值的有效范围内允许开始接收且接收到第二数据,来确认没有中间人的劫持。以NFC为例,假设携带有第一数据的载波信号经过NFC支持的最大传输距离20cm所产生的相位变化值
Figure PCTCN2017096025-appb-000002
则第一终端只有在[(1/2+40)π,41π]才允许开始接收第二数据,只有在该预设数值的有效范围内接收到第二数据才说明没有出现中间人的劫持的情况,由此,可以识别出中间人的劫持。
在该可选实施方式中,以支持NFC通信方式的终端为例,第一终端与第二终端的工作频率为13.56MHz,在第一终端与第二终端通信过程中,第一终端(例如读卡器)始终产生13.56MHz的载波,载波的时间周期是固定的,T=1/13.56MHz,约等于74ns,相位是可以将一个周期在2π的角度来划分,以相位来统计计时,单位可以精确到74/2πns,相比于上述统计载波信号的周期个数以及脉冲个数的方式,统计相位差可以达到进一步精确统计的效果,而且,该可选实施方式可以适用于无源无晶振的智能卡。虽然,该可选实施方式仅以NFC通信方式进行了举例说明,但其他短距离通信方式均属于本发明保护的范围。
通过本发明实施例提供的数据通讯方法,通过第一终端定时接收第二终端定时发送的策略,使得第一终端即使在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况,避免用户在毫不知情的情况下造成经济损失。
实施例2
基于同一发明构思,本发明实施例还提供一种数据通讯系统。如图6所示,该数据通讯系统包括:第一终端和第二终端,第一终端和第二终端执行如实施例1中的数据通讯方法。其中:
第一终端,用于向第二终端发送第一数据,并从发送完成第一数据的时间点开始计时,其中,第一数据至少包括待处理数据;第二终端,用于接收第一数据,并从接收完成第一数据的时间点开始计时;第二终端,还用于当第二终端计时得到的数值达到预设数值时,将第二数据发送至第一终端,其中,第二数据为第二终端对待处理数据进行数据处理后得到的数据;第一终端,还用于若第一终端计时得到的数值在预设数值的有效范围内,则允许开始接收第二数据。
作为一种可选的实施方式,预设数值的有效范围为[S,S+2ΔS],其中,S为预设数值,ΔS由第一终端与第二终端之间采用的通信方式所支持的最大通信距离确定,其中,S+2ΔS对应的时长小于或等于第一终端与第二终端采用的通信协议规定的帧等待时间FWT。
作为一种可选的实施方式,第一终端与第二终端之间的通信方式包括:短距离无线通信方式。
作为一种可选的实施方式,第一终端,还用于在第一终端从发送完成第一数据的时间点开始计时之前,与第二终端进行双向的身份认证,在双向的身份认证通过后,与第二终端协商得到传输密钥;
第二终端,还用于生成预设数值,并利用传输密钥对预设数值加密,将加密后的预设数值发送至第一终端;第一终端,还用于利用传输密钥对加密后的预设数值解密得到预设数值,并保存;或者,
第一终端,还用于生成预设数值,并利用传输密钥对预设数值加密,将加密后的预设数值发送至第二终端;第二终端,还用于利用传输密钥对加密后的预设数值解密得到预设数值,并保存。
作为一种可选的实施方式,第一终端,还用于在第一终端从发送完成第一数据的时间点开始计时之前,与第二终端进行双向的身份认证;
第二终端,还用于在双向的身份认证通过后,生成预设数值,并利用第一终端的公钥对预设数值加密,将加密后的预设数值发送至第一终端;第一终端,还用于利用第一终端的私钥对加密后的预设数值解密得到预设数值,并保存;
或者,
第一终端,还用于在双向的身份认证通过后,生成预设数值,并利用第二终端的公钥对预设数值加密,将加密后的预设数值发送至第二终端;第二终端,还用于利用第二终端的私钥对加密后的预设数值解密得到预设数值,并保存。
作为一种可选的实施方式,第一终端,还用于在第一终端向第二终端发送第一数据之前,生成预设数值;第一数据至少还包括:预设数值以及基于预设数值计算得到的防篡改校验值;第二终端,还用于在接收第一数据之后,还从第一数据中获取预设数值以及防篡改校验值,并对防篡改校验值进行校验,在校验通过后,保存预设数值。
作为一种可选的实施方式,预设数值包括:预设的时长;ΔS为在第一终端与第二终端之间的距离为两者采用的通信方式所支持的最大通信距离时,第一终端传输数据至第二终 端所需的时长;第一终端计时得到的数值在预设数值的有效范围内,包括:第一终端从发送完成第一数据之后计时得到的时长在[S,S+2ΔS]范围内;第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后计时得到的时长达到预设的时长;或者,
预设数值包括:预设的周期个数;第一终端,还用于在第一终端与第二终端通信的整个过程中,始终产生载波信号;ΔS为载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的周期个数;其中:第一终端计时得到的数值在预设数值的有效范围内,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的周期个数在[S,S+2ΔS]范围内;第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的周期个数达到预设的周期个数;或者,
预设数值包括:预设的脉冲个数;第一终端,还用于在第一终端与第二终端通信的整个过程中,始终产生载波信号;ΔS为载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的脉冲个数;其中:第一终端计时得到的数值在预设数值的有效范围内,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的脉冲个数在[S,S+2ΔS]范围内;第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的脉冲个数达到预设的脉冲个数;或者,
预设数值包括:预设的相位差;第一终端,还用于在第一终端与第二终端通信的整个过程中,始终产生载波信号;ΔS为载波信号经过第一终端与第二终端之间采用的通信方式所支持的最大通信距离所产生的相位变化值;其中:第一终端计时得到的数值在预设数值的有效范围内,包括:载波信号在第一相位与第二相位的相位差在[S,S+2ΔS]范围内,其中,第一相位为载波信号在第一终端发送完成第一数据的时间点的相位,第二相位为载波信号在第一终端允许开始接收第二数据的时间点的相位;第二终端计时得到的数值达到预设数值,包括:载波信号在第三相位与第四相位的相位差达到预设的相位差,其中,第三相位为载波信号在第二终端在接收完成第一数据的时间点的相位,第四相位为载波信号在第二终端开始发送第二数据的时间点的相位。
通过本发明实施例提供的数据通讯系统,通过第一终端定时接收第二终端定时发送的策略,使得第一终端即使在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况,避免用户在毫不知情的情况下造成经济损失。
实施例3
图7为根据本发明实施例3的一种数据通讯方法的流程图。参见图7,该方法至少包括步骤S31至步骤S34。
步骤S31,第一终端向第二终端发送第一数据,并从发送完成第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据。
本实施例中,第一终端与第二终端之间的通信方式包括:短距离无线通信方式,具体 地,可参见实施例1中步骤S11中的相应描述。
在本步骤中,作为一种可选的实施方式,以第一终端为读卡器,第二终端为智能卡为例,第一数据中的待处理数据可以为读卡请求数据,当然,第一数据中的待处理数据并不限于此,以第一终端与第二终端均为移动终端为例,第一数据中的待处理数据也可以是请求第二终端返回图片的请求数据等等,本实施例并不对第一数据中的待处理数据进行过多限制,只要是第一终端向第二终端发起的请求数据即可。
基于背景技术中提出的问题,本实施例为了能够在T2<FWT时,仍然可以识别出中间人的劫持,采用第一终端定时接收第二终端定时发送的策略,所以,在本步骤中,第一终端从发送完成第一数据的时间点开始计时,在所述第一终端计时得到的数值达到所述预设数值时,如果接收到第二终端返回的数据,则说明不存在中间人的劫持,如果没有接收到,则可以识别出存在中间人的劫持。
步骤S32,第二终端接收第一数据,并从接收完成第一数据的时间点开始计时。
在本实施例中,当第二终端接收到第一数据后,并不会像现有技术那样在对第一数据处理完成后马上将处理后的数据发送至第一终端,而是开始计时,采用第一终端定时接收第二终端定时发送的策略,在计时得到的数值达到预设数值时,第二终端才发送对第一数据中的待处理数据处理后得到的第二数据,即定时发送(参见步骤S33),使得第一终端在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况。
步骤S33,在第二终端计时得到的数值达到预设数值时,第二终端将第二数据发送至第一终端,其中,第二数据为第二终端对第一数据中的待处理数据进行数据处理后得到的数据。
本实施例中,对第二数据并不做限制,具体地,可参见实施例1中步骤S13中的相应描述。
步骤S34,在第一终端计时得到的数值达到预设数值时,则第一终端允许开始接收所述第二数据。
本实施例中,正如前面提到的,第一终端与第二终端之间采用的通信方式可以为短距离无线通信,可以包括多种通信方式,而每种通信方式支持的最大通信距离是不同的,例如,NFC的工作频率为13.56MHz,支持的通信距离在20cm以内,而蓝牙的工作频率为2.4GHz,支持的通信距离可以达到20m,WiFi可以达到100m。基于短距离无线通信支持的最大通信距离均在几百米以内,数据在两个终端之间的传输时间为ns级,而预设数值至少要大于第二终端对待处理数据进行数据处理的时间(ms级),因此,由于数据在两个终端之间的路上传输时间相比于预设数值非常微小,在本实施例中,数据的传输时间可以忽略不计。
需要说明的是,第一数据是以字节的方式连续发送给第二终端的,第一终端连续发送第一数据的第一字节、第二字节……最后一个字节,第二终端连续接收第一数据的第一字节、第二字节……最后一个字节。由于第一终端与第二终端之间采用短距离通信方式,第 一终端开始发送第一数据各个字节的过程中,第二终端已经开始接收第一数据的各个字节,考虑到终端接收单个字节的时长数量级较小,可以忽略不计,因而,第一数据的第一字节在到达第二终端时,第一数据的最后一个字节还没有发送,即第一终端还没有发送完成第一数据。在不考虑路上传输时间的情况下,我们可以认为第一终端发送第一数据与第二终端接收第一数据是同时进行的,即第一终端发送完成第一数据的时刻即为第二终端接收完成第一数据的时刻,所以,在步骤S31中在第一终端发送完成第一数据的时间点开始计时,在步骤S32中,在第二终端接收完成第一数据的时间点开始计时,在不考虑路上传输时间的情况下,没有中间人的劫持,第一终端应该能够在计时得到的数值达到预设数值时接收到第二数据。
基于背景技术中提出的针对现有的智能卡通讯协议存在的问题,本实施例提供了一种数据通讯方法。该数据通讯方法通过第二终端定时(计时得到的数值达到预设数值)发送数据,第一终端定时(计时得到的数值达到预设数值)接收第二终端返回的数据的策略避免现有技术中的问题,其中,第一终端可以理解为背景技术中的商户读卡器,第二终端可以理解为背景技术中的用户智能卡,由于第一终端只在计时得到的数值达到预设数值时允许接收第二终端返回的数据,在该预设数值之外的任何数值(例如未达到或超过该预设数值)均不允许接收第二终端返回的数据。由此,如果第一终端在计时得到的数值达到预设数值时,允许开始接收且接收到所述第二数据,则说明不存在中间人的劫持,但如果在第一终端在计时得到的数值达到预设数值时允许开始接收但没有接收到所述第二数据,则说明出现了中间人劫持的情况。本实施例中预设数值S对应的时长小于或等于第一终端与第二终端采用的通信协议规定的帧等待时间FWT,例如协议ISO14443和ISO15693规定的帧等待时间FWT,这样,第一终端(例如读卡器)会在FWT的时间内等待智能卡返回数据,同时实施本实施例提供的定时接收的方案,由此,本实施例提供的方法可以在兼容现有协议的同时还可以识别出中间人的劫持。在出现被中间人挟持的情况时,即便T2<FWT,但是,在忽略两个终端之间来回传输数据所需的时长的情况下,以预设数值S为预设的时长为例,第二终端计时达到S才发送数据,因此,T2=s1+s2+S,其中,T2为第一终端从发送完成数据到接收到第二终端反馈的数据所需要的时间,s1+s2为中间人做篡改处理所需的时间(请参考背景技术中tw1、tw2,tw1对应s1,tw2对应s2),T2超过了预设数值S,所以,第一终端拒绝接收第二终端返回的数据,中断与第二终端的通讯,由此,即便T2<FWT,第一终端也可以识别出中间人的劫持。需要说明的是,本实施例中预设数值S除了代表时长之外,还可以包括多种形式,此处,为了便于理解,仅以时长为例进行说明,本实施例下文会提到预设数值包括的多种形式,具体参见下文描述。
在本实施例中,预设数值可以在终端出厂之前预制存储在终端的固定区域中,无需协商,也可以由第一终端与第二终端协商得到,或者,也可以由一方生成发给对方,或者,还可以由第一终端写在协议规定的数据包中,在第一终端向第二终端发送数据时一起发送给第二终端。该预设数值对于能否识别出中间人的劫持至关重要,因此,为了防止该预设 数值被篡改,本实施例提出了几种获取预设数值的方式,具体可以参见实施例1中对于几种获取预设数值的方式的详细说明。
此外,在本实施例中,作为一种可选的实施方式,预设数值可以至少包括:预设的时长、预设的周期个数、预设的脉冲个数或者预设的相位差,因此,本实施例中,第一终端和第二终端也相应地有不同的计时统计方式,以及判断计时得到的数值是否达到预设数值的方式,下面分别针对各种预设数值进行详细的说明。
作为一种本实施例可选的实施方式,预设数值可以包括:预设的时长,其中,该预设的时长大于第二终端对接收到的第一数据中的待处理数据进行数据处理的时长(由于第二终端需要在处理数据之后达到计时得到的数值才发送第二数据),此外,可选地,预设的时长可以小于或等于FWT;在步骤S34中,第一终端计时得到的数值达到预设数值,包括:第一终端从发送完成第一数据之后计时得到的时长达到预设的时长;在步骤S33中,第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后计时得到的时长达到预设的时长。
在该种可选实施方式中,第一终端与第二终端中均具有计时器,支持精确计时功能,可以通过计时器计时得到的时长判断是否达到预设时长或是否在预设时长范围内。例如,第二终端可以为具有晶振的智能卡,该具有晶振的智能卡可以通过其内部时钟计时的时长的方式来统计计时,其计时精确度由智能卡的时钟精确度决定。例如,S=5×10-3s,以蓝牙为例,第二终端在计时达到5×10-3s时发送第二数据,第一终端只有在计时达到5×10-3s时才允许开始接收第二数据,只有在计时达到5×10-3s时接收到第二数据才说明没有出现中间人的劫持的情况,由此,可以识别出中间人的劫持。虽然,该可选实施方式仅以蓝牙通信方式进行了举例说明,但其他短距离通信方式均属于本发明保护的范围。
对于无源、无晶振的终端(如智能卡)来说,该终端没有计时功能,而在本实施例中,由于在第一终端与第二终端通信的整个过程中,第一终端始终产生载波信号,因此,本实施例中提出了有别与时钟计时的计时统计方式,本实施例还可以通过计算载波信号的周期个数、脉冲个数以及相位差来统计计时得到的数值,预设数值具体可以包括:预设的载波信号的周期个数、预设的载波信号的脉冲个数以及预设的载波信号的相位差,其中,上述预设的载波信号的周期个数、预设的载波信号的脉冲个数以及预设的载波信号的相位差对应得到的时长均大于第二终端对接收到的第一数据中的待处理数据进行数据处理的时长,此外,可选地,上述预设的周期个数对应的时长、预设的脉冲个数对应的时长、以及预设的相位差对应的时长均可以小于或等于FWT。作为一种可选的实施方式,预设数值可以包括:预设的周期个数;在步骤S34中,第一终端计时得到的数值达到预设数值,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的周期个数达到预设的周期个数;步骤S33中,第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的周期个数达到预设的周期个数。
在本实施例中,第一终端始终在产生载波信号,在第一终端需要发送数据时,例如, 第一终端发送第一数据是将第一数据调制在载波信号上发送至第二终端的,在第一终端不需要发送数据时,第一终端发送该载波信号至第二终端,该载波信号上没有携带数据。该可选实施方式中,第一终端与第二终端均具有计数器,可以计算上述情况下载波的周期个数,该可选实施方式提供了一种可选的统计计时得到的数值的方式,第一终端与第二终端无需使用时钟计时,也可以达到精确计时的目的,举例来说,以支持NFC通信方式的终端为例,第一终端与第二终端的工作频率为13.56MHZ,在第一终端与第二终端通信过程中,第一终端(例如读卡器)始终产生13.56MHz的载波,载波的时间周期T是固定的,T=1/13.56MHz,约等于74ns,以周期来统计计时得到的数值,单位可以精确到ns,由此可以达到精确统计的效果,而且,该可选实施方式可以适用于无源无晶振的智能卡。虽然,该可选实施方式仅以NFC通信方式进行了举例说明,但其他短距离通信方式均属于本发明保护的范围。
此外,作为另一种本实施例可选的实施方式,预设数值可以包括:预设的脉冲个数;在步骤S34中,第一终端计时得到的数值达到预设数值,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的脉冲个数达到预设的脉冲个数;在步骤S33中,第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的脉冲个数达到预设的脉冲个数。
统计载波信号的脉冲个数即统计载波信号的峰值的个数,相比于上述统计载波信号的周期个数的方式,统计脉冲个数可以达到进一步精确统计的效果,而且,该可选实施方式可以适用于无源无晶振的智能卡。
此外,作为另一种本实施例可选的实施方式,预设数值可以包括:预设的相位差;在步骤S34中,第一终端计时得到的数值达到预设数值,包括:载波信号在第一相位与第二相位的相位差达到预设的相位差,其中,第一相位为载波信号在第一终端发送完成第一数据的时间点的相位,第二相位为载波信号在第一终端允许开始接收第二数据的时间点的相位;在步骤S33中,第二终端计时得到的数值达到预设数值,包括:载波信号在第三相位与第四相位的相位差达到预设的相位差,其中,第三相位为载波信号在第二终端在接收完成第一数据的时间点的相位,第四相位为载波信号在第二终端开始发送所述第二数据的时间点的相位。
例如,第一终端与第二终端可以采用之前提到的获得预设数值的方式,协商或一方生成预设的相位差s=(1/2+40)π,在以第一终端为读卡器,第二终端为智能卡为例,读卡器在发送完成第一数据后以及智能卡在接收完成该第一数据后,两者之间的通信波形就是标准的正弦波载波,记录此刻的相位为0(即第一相位与第三相位为0),在载波相位差(即第三相位与第四相位的相位差)达到(1/2+40)π时,智能卡发送第二数据,此时,读卡器只有在计时得到的相位差达到(1/2+40)π时允许开始接收且只有接收到第二数据才说明没有出现中间人的劫持的情况,由此,可以识别出中间人的劫持。
在该可选实施方式中,以支持NFC通信方式的终端为例,第一终端与第二终端的工作频率为13.56MHz,在第一终端与第二终端通信过程中,第一终端(例如读卡器)始终产生13.56MHz的载波,载波的时间周期是固定的,T=1/13.56MHz,约等于74ns,相位是可以将一个周期在2π的角度来划分,以相位来统计计时,单位可以精确到74/2πns,相比于上述统计载波信号的周期个数以及脉冲个数的方式,统计相位差可以达到进一步精确统计的效果,而且,该可选实施方式可以适用于无源无晶振的智能卡。虽然,该可选实施方式仅以NFC通信方式进行了举例说明,但其他短距离通信方式均属于本发明保护的范围。
通过本发明实施例提供的数据通讯方法,通过第二终端定时发送第一终端定时接收的策略,使得第一终端即使在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况,避免用户在毫不知情的情况下造成经济损失。
实施例4
基于同一发明构思,本发明实施例还提供一种数据通讯系统。可以参见图6所示的数据通讯系统,该数据通讯系统包括:第一终端和第二终端,第一终端和第二终端执行如实施例3中的数据通讯方法。其中:
第一终端,用于向第二终端发送第一数据,并从发送完成第一数据的时间点开始计时,其中,第一数据至少包括待处理数据;第二终端,用于接收第一数据,并从接收完成第一数据的时间点开始计时;第二终端,还用于在第二终端计时得到的数值达到预设数值时,将第二数据发送至第一终端,其中,第二数据为第二终端对待处理数据进行数据处理后得到的数据;第一终端,还用于在计时得到的数值达到预设数值时,允许开始接收第二数据。
作为一种可选的方式,第一终端与第二终端之间的通信方式包括:短距离无线通信方式。
作为一种可选的方式,第一终端,还用于在第一终端从发送完成第一数据的时间点开始计时之前,与第二终端进行双向的身份认证,在双向的身份认证通过后,与第二终端协商得到传输密钥;
第二终端,还用于生成预设数值,并利用传输密钥对预设数值加密,将加密后的预设数值发送至第一终端;第一终端,还用于利用传输密钥对加密后的预设数值解密得到预设数值,并保存;或者,
第一终端,还用于生成预设数值,并利用传输密钥对预设数值加密,将加密后的预设数值发送至第二终端;第二终端,还用于利用传输密钥对加密后的预设数值解密得到预设数值,并保存。
作为一种可选的方式,第一终端,还用于在第一终端从发送完成第一数据的时间点开始计时之前,与第二终端进行双向的身份认证;
第二终端,还用于在双向的身份认证通过后,生成预设数值,并利用第一终端的公钥对预设数值加密,将加密后的预设数值发送至第一终端;第一终端,还用于利用第一终端 的私钥对加密后的预设数值解密得到预设数值,并保存;
或者,
第一终端,还用于在双向的身份认证通过后,生成预设数值,并利用第二终端的公钥对预设数值加密,将加密后的预设数值发送至第二终端;第二终端,还用于利用第二终端的私钥对加密后的预设数值解密得到预设数值,并保存。
作为一种可选的方式,第一终端,还用于在第一终端向第二终端发送第一数据之前,生成预设数值;第一数据至少还包括:预设数值以及基于预设数值计算得到的防篡改校验值;
第二终端,还用于在接收第一数据之后,还从第一数据中获取预设数值以及防篡改校验值,并对防篡改校验值进行校验,在校验通过后,保存预设数值。
作为一种可选的方式,预设数值包括:预设的时长,预设的时长小于或等于第一终端与第二终端采用的通信协议规定的帧等待时间FWT;
第一终端计时得到的数值达到预设数值,包括:第一终端从发送完成第一数据之后计时得到的时长达到预设的时长;
第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后计时得到的时长达到预设的时长。
作为一种可选的方式,第一终端,还用于在第一终端与第二终端通信的整个过程中,始终产生载波信号;
预设数值包括:预设的周期个数,预设的周期个数对应的时长小于或等于第一终端与第二终端采用的通信协议规定的FWT;第一终端计时得到的数值达到预设数值,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的周期个数达到预设的周期个数;第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的周期个数达到预设的周期个数;或者,
预设数值包括:预设的脉冲个数,预设的脉冲个数对应的时长小于或等于第一终端与第二终端采用的通信协议规定的FWT;其中:第一终端计时得到的数值达到预设数值,包括:第一终端从发送完成第一数据之后持续向第二终端发送的载波信号的脉冲个数达到预设的脉冲个数;第二终端计时得到的数值达到预设数值,包括:第二终端从接收完成第一数据之后持续接收到的载波信号的脉冲个数达到预设的脉冲个数;或者,
预设数值包括:预设的相位差,预设的相位差对应的时长小于或等于第一终端与第二终端采用的通信协议规定的FWT;其中:第一终端计时得到的数值达到预设数值,包括:载波信号在第一相位与第二相位的相位差达到预设的相位差,其中,第一相位为载波信号在第一终端发送完成第一数据的时间点的相位,第二相位为载波信号在第一终端允许开始接收第二数据的时间点的相位;第二终端计时得到的数值达到预设数值,包括:载波信号在第三相位与第四相位的相位差达到预设的相位差,其中,第三相位为载波信号在第二终端在接收完成第一数据的时间点的相位,第四相位为载波信号在第二终端开始发送第二数 据的时间点的相位。
通过本发明实施例提供的数据通讯系统,通过第二终端定时发送第一终端定时接收的策略,使得第一终端即使在接收到第二数据的T2<FWT时,仍然可以识别出是否存在中间人劫持的情况,避免用户在毫不知情的情况下造成经济损失。
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所属技术领域的技术人员所理解。
应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。例如,如果用硬件来实现,和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。
本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。
此外,在本发明各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。
上述提到的存储介质可以是只读存储器,磁盘或光盘等。
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施例或示例中以合适的方式结合。
尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在不脱离本发明的原理和宗旨的情况下在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。本发明的范围由所附权利要求及其等同限定。

Claims (16)

  1. 一种数据通讯方法,其特征在于,包括:
    第一终端向第二终端发送第一数据,并从发送完成所述第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据;
    所述第二终端接收所述第一数据,并从接收完成所述第一数据的时间点开始计时;
    当所述第二终端计时得到的数值达到预设数值时,所述第二终端将第二数据发送至所述第一终端,其中,所述第二数据为所述第二终端对所述待处理数据进行数据处理后得到的数据;
    所述第一终端计时得到的数值在所述预设数值的有效范围内,则所述第一终端允许开始接收所述第二数据。
  2. 根据权利要求1所述的方法,其特征在于,
    所述预设数值的有效范围为[S,S+2ΔS],其中,S为所述预设数值,ΔS由所述第一终端与所述第二终端之间采用的通信方式所支持的最大通信距离确定,其中,S+2ΔS的和对应的时长小于或等于所述第一终端与所述第二终端采用的通信协议规定的帧等待时间FWT。
  3. 根据权利要求2所述的方法,其特征在于,
    所述第一终端与所述第二终端之间采用的通信方式包括:短距离无线通信方式。
  4. 根据权利要求1至3任一项所述的方法,其特征在于,
    在所述第一终端从发送完成所述第一数据的时间点开始计时之前,所述方法还包括:
    所述第一终端与所述第二终端进行双向的身份认证,在所述双向的身份认证通过后,所述第一终端与所述第二终端协商得到传输密钥;所述第二终端生成所述预设数值,并利用所述传输密钥对所述预设数值加密,将加密后的预设数值发送至所述第一终端;所述第一终端利用所述传输密钥对所述加密后的预设数值解密得到所述预设数值,并保存;或者,所述第一终端生成所述预设数值,并利用所述传输密钥对所述预设数值加密,将加密后的预设数值发送至所述第二终端;所述第二终端利用所述传输密钥对所述加密后的预设数值解密得到所述预设数值,并保存;或者,
    所述第一终端与所述第二终端进行双向的身份认证;在所述双向的身份认证通过后,所述第二终端生成所述预设数值,并利用所述第一终端的公钥对所述预设数值加密,将加密后的预设数值发送至所述第一终端;所述第一终端利用其私钥对所述加密后的预设数值解密得到所述预设数值,并保存;或者,在所述双向的身份认证通过后,所述第一终端生成所述预设数值,并利用所述第二终端的公钥对所述预设数值加密,将加密后的预设数值 发送至所述第二终端;所述第二终端利用其私钥对所述加密后的预设数值解密得到所述预设数值,并保存。
  5. 根据权利要求1至3任一项所述的方法,其特征在于,
    在所述第一终端向第二终端发送第一数据之前,所述方法还包括:所述第一终端生成所述预设数值;
    所述第一数据至少还包括:所述预设数值以及基于所述预设数值计算得到的防篡改校验值;
    所述第二终端接收所述第一数据之后,所述方法还包括:
    所述第二终端从所述第一数据中获取所述预设数值以及所述防篡改校验值,并对所述防篡改校验值进行校验,在校验通过后,保存所述预设数值。
  6. 根据权利要求2至5任一项所述的方法,其特征在于,
    所述预设数值包括:预设的时长;所述ΔS为在所述第一终端与所述第二终端之间的距离为两者采用的通信方式所支持的最大通信距离时,所述第一终端传输数据至所述第二终端所需的时长;所述第一终端计时得到的数值在所述预设数值的有效范围内,包括:所述第一终端从发送完成所述第一数据之后计时得到的时长在所述[S,S+2ΔS]范围内;
    所述第二终端计时得到的数值达到所述预设数值,包括:所述第二终端从接收完成所述第一数据之后计时得到的时长达到所述预设的时长;或者,
    所述预设数值包括:预设的周期个数;在所述第一终端与所述第二终端通信的整个过程中,所述第一终端始终产生载波信号;所述ΔS为所述载波信号经过所述第一终端与所述第二终端之间采用的通信方式所支持的最大通信距离所产生的周期个数;其中:所述第一终端计时得到的数值在所述预设数值的有效范围内,包括:所述第一终端从发送完成所述第一数据之后持续向所述第二终端发送的所述载波信号的周期个数在所述[S,S+2ΔS]范围内;
    所述第二终端计时得到的数值达到所述预设数值,包括:所述第二终端从接收完成所述第一数据之后持续接收到的所述载波信号的周期个数达到所述预设的周期个数;或者,
    所述预设数值包括:预设的脉冲个数;在所述第一终端与所述第二终端通信的整个过程中,所述第一终端始终产生载波信号;所述ΔS为所述载波信号经过所述第一终端与所述第二终端之间采用的通信方式所支持的最大通信距离所产生的脉冲个数;其中:所述第一终端计时得到的数值在所述预设数值的有效范围内,包括:所述第一终端从发送完成所述第一数据之后持续向所述第二终端发送的所述载波信号的脉冲个数在所述[S,S+2ΔS]范围内;所述第二终端计时得到的数值达到所述预设数值,包括:所述第二终端从接收完成所述第一数据之后持续接收到的所述载波信号的脉冲个数达到所述预设的脉冲个数;或者,
    所述预设数值包括:预设的相位差;在所述第一终端与所述第二终端通信的整个过程 中,所述第一终端始终产生载波信号;所述ΔS为所述载波信号经过所述第一终端与所述第二终端之间采用的通信方式所支持的最大通信距离所产生的相位变化值;其中:所述第一终端计时得到的数值在所述预设数值的有效范围内,包括:所述载波信号在第一相位与第二相位的相位差在所述[S,S+2ΔS]范围内,其中,所述第一相位为所述载波信号在所述第一终端发送完成所述第一数据的时间点的相位,所述第二相位为所述载波信号在所述第一终端允许开始接收所述第二数据的时间点的相位;所述第二终端计时得到的数值达到所述预设数值,包括:所述载波信号在第三相位与第四相位的相位差达到所述预设的相位差,其中,所述第三相位为所述载波信号在所述第二终端在接收完成所述第一数据的时间点的相位,所述第四相位为所述载波信号在所述第二终端开始发送所述第二数据的时间点的相位。
  7. 根据权利要求1至6任一项所述的方法,其特征在于,
    所述第一终端为读取装置,所述第二终端为应答装置。
  8. 一种数据通讯系统,包括:如权利要求1至7中所述第一终端和所述第二终端;
    所述第一终端和所述第二终端执行如权利要求1至7所述的数据通讯方法。
  9. 一种数据通讯方法,其特征在于,包括:
    第一终端向第二终端发送第一数据,并从发送完成所述第一数据的时间点开始计时,其中,所述第一数据至少包括待处理数据;
    所述第二终端接收所述第一数据,并从接收完成所述第一数据的时间点开始计时;
    在所述第二终端计时得到的数值达到预设数值时,所述第二终端将第二数据发送至所述第一终端,其中,所述第二数据为所述第二终端对所述待处理数据进行数据处理后得到的数据;
    在所述第一终端计时得到的数值达到所述预设数值时,所述第一终端允许开始接收所述第二数据。
  10. 根据权利要求9所述的方法,其特征在于,
    所述第一终端与所述第二终端之间的通信方式包括:短距离无线通信方式。
  11. 根据权利要求9或10所述的方法,其特征在于,
    在所述第一终端从发送完成所述第一数据的时间点开始计时之前,所述方法还包括:
    所述第一终端与所述第二终端进行双向的身份认证,在所述双向的身份认证通过后,所述第一终端与所述第二终端协商得到传输密钥;所述第二终端生成所述预设数值,并利用所述传输密钥对所述预设数值加密,将加密后的预设数值发送至所述第一终端;所述第 一终端利用所述传输密钥对所述加密后的预设数值解密得到所述预设数值,并保存;或者,所述第一终端生成所述预设数值,并利用所述传输密钥对所述预设数值加密,将加密后的预设数值发送至所述第二终端;所述第二终端利用所述传输密钥对所述加密后的预设数值解密得到所述预设数值,并保存;或者,
    所述第一终端与所述第二终端进行双向的身份认证;在所述双向的身份认证通过后,所述第二终端生成所述预设数值,并利用所述第一终端的公钥对所述预设数值加密,将加密后的预设数值发送至所述第一终端;所述第一终端利用其私钥对所述加密后的预设数值解密得到所述预设数值,并保存;或者,在所述双向的身份认证通过后,所述第一终端生成所述预设数值,并利用所述第二终端的公钥对所述预设数值加密,将加密后的预设数值发送至所述第二终端;所述第二终端利用其私钥对所述加密后的预设数值解密得到所述预设数值,并保存。
  12. 根据权利要求9或10所述的方法,其特征在于,
    在所述第一终端向第二终端发送第一数据之前,所述方法还包括:所述第一终端生成所述预设数值;
    所述第一数据至少还包括:所述预设数值以及基于所述预设数值计算得到的防篡改校验值;
    所述第二终端接收所述第一数据之后,所述方法还包括:
    所述第二终端从所述第一数据中获取所述预设数值以及所述防篡改校验值,并对所述防篡改校验值进行校验,在校验通过后,保存所述预设数值。
  13. 根据权利要求9至12任一项所述的方法,其特征在于,
    所述预设数值包括:预设的时长,所述预设的时长小于或等于所述第一终端与所述第二终端采用的通信协议规定的帧等待时间FWT;
    所述第一终端计时得到的数值达到预设数值,包括:
    所述第一终端从发送完成所述第一数据之后计时得到的时长达到所述预设的时长;
    所述第二终端计时得到的数值达到所述预设数值,包括:
    所述第二终端从接收完成所述第一数据之后计时得到的时长达到所述预设的时长。
  14. 根据权利要求9至12任一项所述的方法,其特征在于,
    在所述第一终端与所述第二终端通信的整个过程中,所述第一终端始终产生载波信号;
    所述预设数值包括:预设的周期个数,所述预设的周期个数对应的时长小于或等于所述第一终端与所述第二终端采用的通信协议规定的FWT;其中:所述第一终端计时得到的数值达到预设数值,包括:所述第一终端从发送完成所述第一数据之后持续向所述第二终端发送的所述载波信号的周期个数达到所述预设的周期个数;所述第二终端计时得到的数 值达到所述预设数值,包括:所述第二终端从接收完成所述第一数据之后持续接收到的所述载波信号的周期个数达到所述预设的周期个数;或者,
    所述预设数值包括:预设的脉冲个数,所述预设的脉冲个数对应的时长小于或等于所述第一终端与所述第二终端采用的通信协议规定的FWT;其中:所述第一终端计时得到的数值达到预设数值,包括:所述第一终端从发送完成所述第一数据之后持续向所述第二终端发送的所述载波信号的脉冲个数达到所述预设的脉冲个数;所述第二终端计时得到的数值达到所述预设数值,包括:所述第二终端从接收完成所述第一数据之后持续接收到的所述载波信号的脉冲个数达到所述预设的脉冲个数;或者,
    所述预设数值包括:预设的相位差,所述预设的相位差对应的时长小于或等于所述第一终端与所述第二终端采用的通信协议规定的FWT;其中:所述第一终端计时得到的数值达到预设数值,包括:所述载波信号在第一相位与第二相位的相位差达到预设的相位差,其中,所述第一相位为所述载波信号在所述第一终端发送完成所述第一数据的时间点的相位,所述第二相位为所述载波信号在所述第一终端允许开始接收所述第二数据的时间点的相位;所述第二终端计时得到的数值达到所述预设数值,包括:所述载波信号在第三相位与第四相位的相位差达到预设的相位差,其中,所述第三相位为所述载波信号在所述第二终端在接收完成所述第一数据的时间点的相位,所述第四相位为所述载波信号在所述第二终端开始发送所述第二数据的时间点的相位。
  15. 根据权利要求9至14任一项所述的方法,其特征在于,
    所述第一终端为读取装置,所述第二终端为应答装置。
  16. 一种数据通讯系统,包括:如权利要求9至15中所述第一终端和所述第二终端;
    所述第一终端和所述第二终端执行如权利要求9至15所述的数据通讯方法。
PCT/CN2017/096025 2016-08-05 2017-08-04 一种数据通讯方法及数据通讯系统 WO2018024250A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US16/314,007 US10609552B2 (en) 2016-08-05 2017-08-04 System and method for data communication protection
EP17836431.1A EP3495985A4 (en) 2016-08-05 2017-08-04 DATA COMMUNICATION METHOD AND DATA COMMUNICATION SYSTEM
KR1020187034251A KR101998543B1 (ko) 2016-08-05 2017-08-04 데이터 통신 방법 및 데이터 통신 시스템

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201610640015.3A CN107688760B (zh) 2016-08-05 2016-08-05 一种数据通讯方法及数据通讯系统
CN201610639441.5A CN107689946B (zh) 2016-08-05 2016-08-05 一种数据通讯方法及数据通讯系统
CN201610639441.5 2016-08-05
CN201610640015.3 2016-08-05

Publications (1)

Publication Number Publication Date
WO2018024250A1 true WO2018024250A1 (zh) 2018-02-08

Family

ID=61073475

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/096025 WO2018024250A1 (zh) 2016-08-05 2017-08-04 一种数据通讯方法及数据通讯系统

Country Status (4)

Country Link
US (1) US10609552B2 (zh)
EP (1) EP3495985A4 (zh)
KR (1) KR101998543B1 (zh)
WO (1) WO2018024250A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP7082012B2 (ja) * 2018-08-23 2022-06-07 株式会社東海理化電機製作所 通信不正成立防止システム及び通信不正成立防止方法
CN112491843B (zh) * 2020-11-17 2022-06-21 苏州浪潮智能科技有限公司 一种数据库多重认证方法、系统、终端及存储介质
CN112688774A (zh) * 2020-12-09 2021-04-20 天地融科技股份有限公司 一种利用定时通讯保护密钥协商的安全通信方法及系统
WO2022121938A1 (zh) * 2020-12-09 2022-06-16 天地融科技股份有限公司 一种利用定时通讯保护密钥协商的安全通信方法及系统
CN115412104A (zh) * 2021-05-28 2022-11-29 北京小米移动软件有限公司 手势识别方法及装置、移动终端、计算机可读存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1936917A (zh) * 2006-10-23 2007-03-28 北京飞天诚信科技有限公司 一种主机与智能卡信息交互的方法和装置
US20130136046A1 (en) * 2011-11-30 2013-05-30 Secureall Corporation Establishment of wireless communications
CN103227816A (zh) * 2013-03-25 2013-07-31 北京小米科技有限责任公司 数据发送方法、数据处理方法、装置和系统
WO2014062623A1 (en) * 2012-10-15 2014-04-24 Powered Card Solutions, Llc System and method for secure remote access and remote payment using a mobile device and a powered display card
CN104754501A (zh) * 2015-04-21 2015-07-01 北京云迹科技有限公司 一种数据传输方法及装置
CN104915616A (zh) * 2015-05-15 2015-09-16 飞天诚信科技股份有限公司 一种访问智能卡的方法和读卡器

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2760280B1 (fr) 1997-03-03 1999-05-21 Innovatron Ind Sa Procede de gestion des collisions dans un systeme d'echange de donnees sans contact
US7038797B1 (en) * 1999-05-25 2006-05-02 Silverbrook Research Pty Ltd Method and system for delivery of mail
EP1325404A4 (en) 2000-09-12 2006-02-01 Canon Kk MAP OF ACCESS TO SERVICES
CA2541824A1 (en) * 2003-10-08 2005-04-14 Stephan J. Engberg Method and system for establishing a communication using privacy enhancing techniques
WO2007038743A2 (en) * 2005-09-28 2007-04-05 Visa International Service Association Device, system and method for reducing an interaction time for a contactless transaction
EP2247024B1 (en) * 2009-04-30 2015-08-19 Nxp B.V. Determining the validity of a connection between a reader and a transponder
FR2954550A1 (fr) * 2009-12-23 2011-06-24 Commissariat Energie Atomique Procede de protection dans une communication radiofrequence sans contact.
EP2973215B1 (en) * 2013-03-15 2023-05-17 NIKE Innovate C.V. Feedback signals from image data of athletic performance

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1936917A (zh) * 2006-10-23 2007-03-28 北京飞天诚信科技有限公司 一种主机与智能卡信息交互的方法和装置
US20130136046A1 (en) * 2011-11-30 2013-05-30 Secureall Corporation Establishment of wireless communications
WO2014062623A1 (en) * 2012-10-15 2014-04-24 Powered Card Solutions, Llc System and method for secure remote access and remote payment using a mobile device and a powered display card
CN103227816A (zh) * 2013-03-25 2013-07-31 北京小米科技有限责任公司 数据发送方法、数据处理方法、装置和系统
CN104754501A (zh) * 2015-04-21 2015-07-01 北京云迹科技有限公司 一种数据传输方法及装置
CN104915616A (zh) * 2015-05-15 2015-09-16 飞天诚信科技股份有限公司 一种访问智能卡的方法和读卡器

Also Published As

Publication number Publication date
US20190342751A1 (en) 2019-11-07
EP3495985A1 (en) 2019-06-12
US10609552B2 (en) 2020-03-31
KR20180137557A (ko) 2018-12-27
EP3495985A4 (en) 2020-03-25
KR101998543B1 (ko) 2019-07-09

Similar Documents

Publication Publication Date Title
WO2018024250A1 (zh) 一种数据通讯方法及数据通讯系统
CN102315942B (zh) 一种带蓝牙的安全终端及其与客户端的通信方法
CN103501191B (zh) 一种基于nfc近场通信技术的移动支付装置及其方法
US20180077124A1 (en) Secure wireless communication device and method
WO2018176670A1 (zh) 一种无线通信的握手方法及设备
CN103236926B (zh) 基于点对点的数据传输系统及传输方法
RU2015137715A (ru) Система связи через тело
CN107392001B (zh) 一种授权方法、系统及卡片
US10979899B2 (en) Data communication method and system
CN107689946B (zh) 一种数据通讯方法及数据通讯系统
EP2725736B1 (en) Methods and terminals for secure radio frequency communication
CN107690133B (zh) 一种数据通信方法及系统
CN107688760B (zh) 一种数据通讯方法及数据通讯系统
JP6698880B2 (ja) 安全通信方法及びシステム
CN107690144A (zh) 一种数据通信方法及系统
CN107688761B (zh) 一种数据通讯方法及数据通讯系统
CN101887503B (zh) 种子流通监管系统及其认证方法
CN107688749B (zh) 一种安全通信方法和系统
CN107690143B (zh) 一种数据通信方法及系统
CN112713991A (zh) 一种利用定时通讯保护密钥协商的安全通信方法及系统
WO2018024251A1 (zh) 一种数据通信方法及系统
TW201446067A (zh) 用於確保通信裝置之鄰近之系統、方法及設備
CN107690141B (zh) 一种数据通信方法及系统
CN111356136B (zh) 对与服务器通信的转发器进行安全认证的方法
CN107690142B (zh) 一种数据通信方法及系统

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 20187034251

Country of ref document: KR

Kind code of ref document: A

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

Ref document number: 17836431

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2017836431

Country of ref document: EP

Effective date: 20190305