Fingerprint lock and its working method
By using the update key to encrypt communication between the fingerprint lock's main control MCU and the fingerprint module, the vulnerability of existing fingerprint locks is solved, improving security and reducing costs.
Patent Information
- Application Number
- CN201810422349.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-05-04
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2038-05-04
AI Technical Summary
Existing fingerprint locks are vulnerable to replay attacks and cracking during communication, and hardware encryption solutions increase cost and volume.
By using a preset method to generate update keys between the main control MCU and the fingerprint module, the communication messages are encrypted and decrypted, ensuring that different keys are used for each communication to avoid replay attacks and cracking.
It effectively improves the security of the fingerprint lock, avoids cracking by swapping fingerprint modules, and eliminates the need to add hardware chips, reducing costs.
Smart Images

Figure CN108833086B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart locks, and in particular to a fingerprint lock and a working method thereof. Background Art
[0002] With the popularity of the fingerprint lock market, various cracking methods and videos have gradually been exposed to the public, and the security of fingerprint locks has become more and more concerned by consumers. Currently, fingerprint locks use UART or SPI interfaces to communicate between fingerprint modules and the main control MCU. The communication content is plain text or simple encryption, which can be easily cracked by replay attacks. If a hardware encryption solution is used, an additional encryption chip is required, which increases the size and cost. Summary of the invention
[0003] The main purpose of the present invention is to provide a fingerprint lock and a working method thereof, aiming to improve the security of the fingerprint lock in a low-cost manner.
[0004] To achieve the above object, the present invention provides a working method of a fingerprint lock, wherein the fingerprint lock includes a main control MCU and a fingerprint module communicatively connected to the main control MCU, and the working method includes the following steps:
[0005] A. The main control MCU generates an update key in a preset manner, encrypts the operation instruction to be sent and the update key with its latest stored key, and adds them to the first communication message, sends the first communication message to the fingerprint module, and stores the update key;
[0006] B. After receiving the first communication message, the fingerprint module uses its latest stored key to decrypt the first communication message and verify the communication content obtained by decryption;
[0007] C. After the fingerprint module successfully verifies the communication content, the update key is stored and the operation instruction in the communication content is executed;
[0008] D. The fingerprint module encrypts the operation result of executing the operation instruction with the updated key stored most recently, adds the encrypted result to the second communication message, and feeds the second communication message back to the main control MCU;
[0009] E. The main control MCU uses its latest stored update key to decrypt the second communication message, and verifies the decrypted content to perform corresponding processing according to the verification result.
[0010] Preferably, after step A, the working method further comprises:
[0011] If the main control MCU does not receive a reply from the fingerprint module within a first preset time, determining whether the main control MCU has resent the first communication message;
[0012] If the main control MCU has not resent the first communication message, resending the first communication message to the fingerprint module;
[0013] If the main control MCU resends the first communication message, the communication with the fingerprint module is terminated.
[0014] Preferably, the working method further comprises:
[0015] If the fingerprint module fails to verify the communication content, a third communication message is sent to the main control MCU, wherein the third communication message includes a confirmation character indicating that the status is verification failure;
[0016] The master control MCU verifies the received third communication message, and after the integrity check of the third communication message fails or the status of the confirmation character in the third communication message is confirmed to be a check failure, determines whether the master control MCU has resent the first communication message;
[0017] If the main control MCU has not resent the first communication message, resending the first communication message to the fingerprint module;
[0018] If the main control MCU resends the first communication message, the communication with the fingerprint module is terminated.
[0019] Preferably, the first communication message and the second communication message both contain an encrypted magic number, and the verification of the decrypted communication content by the fingerprint module and the verification of the decrypted content by the main control MCU both include: integrity verification and magic number verification.
[0020] Preferably, the preset method for the master MCU to generate an update key includes:
[0021] The main control MCU generates an n-byte random number, and uses a bytes of the pre-stored MAC address of the fingerprint module and any b bytes of the generated n-byte random number to form an update key.
[0022] Preferably, the working method further comprises:
[0023] The main control MCU sends a MAC address reading command to the fingerprint module;
[0024] The fingerprint module feeds back its own MAC address to the main control MCU;
[0025] The main control MCU stores the MAC address.
[0026] The present invention also provides a fingerprint lock, comprising a main control MCU and a fingerprint module communicatively connected to the main control MCU;
[0027] The main control MCU is used to generate an update key in a preset manner, encrypt the operation instruction to be sent and the update key with its latest stored key, and add them to the first communication message, send the first communication message to the fingerprint module, and store the update key;
[0028] The fingerprint module is used to decrypt the first communication message using its latest stored key after receiving the first communication message, and verify the communication content obtained by decryption; and after the communication content verification is successful, store the updated key, execute the operation instruction in the communication content; and encrypt the operation result of executing the operation instruction using its latest stored updated key, add it to the second communication message, and feed back the second communication message to the main control MCU;
[0029] The main control MCU is also used to use its latest stored update key to decrypt the second communication message, and verify the decrypted content to perform corresponding processing according to the verification result.
[0030] Preferably, the main control MCU is also used to determine whether the first communication message has been resent to the fingerprint module after not receiving a reply from the fingerprint module within a first preset time; and after determining that the first communication message has not been resent, resend the first communication message to the fingerprint module; and after determining that the first communication message has been resent to the fingerprint module, terminate the communication with the fingerprint module.
[0031] Preferably, the fingerprint module is further used to send a third communication message to the main control MCU after the communication content verification fails, and the third communication message contains a confirmation character with a status of verification failure;
[0032] The main control MCU is also used to verify the received third communication message, and after the integrity check of the third communication message fails or the status of the confirmation character in the third communication message is confirmed to be a verification failure, determine whether the first communication message has been resent to the fingerprint module; and after determining that the first communication message has not been resent, resend the first communication message to the fingerprint module; and after determining that the first communication message has been resent to the fingerprint module, end the communication with the fingerprint module.
[0033] Preferably, the preset method for the master MCU to generate an update key includes:
[0034] The main control MCU generates an n-byte random number, and uses a bytes of the pre-stored MAC address of the fingerprint module and any b bytes of the generated n-byte random number to form an update key.
[0035] According to the technical solution of the present invention, the main control MCU will first update the key each time it communicates with the fingerprint module, and then encrypt the updated key and the operation instruction together with the key sent to the fingerprint module last time, add them into the communication message and send them to the fingerprint module, after the fingerprint module decrypts the communication message sent by the main control MCU and verifies it successfully, it stores the updated key in the decrypted communication content, so as to decrypt the communication message sent by the MCU next time, so that different keys are used for each communication between the main control MCU and the fingerprint module, which effectively avoids the interchange of fingerprint modules, cracking and replay attacks, and ensures the security of the fingerprint lock; at the same time, this solution does not add any additional hardware chips, and will not increase the additional hardware cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0037] Figure 1 It is a schematic diagram of a flow chart of an embodiment of a working method of a fingerprint lock of the present invention;
[0038] Figure 2 It is a flow chart of the second embodiment of the working method of the fingerprint lock of the present invention;
[0039] Figure 3 This is a schematic diagram of the module structure of a preferred embodiment of the fingerprint lock of the present invention.
[0040] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0043] The present invention provides a working method of a fingerprint lock. The fingerprint lock comprises a main control MCU and a fingerprint module which is communicatively connected to the main control MCU.
[0044] like Figure 1 As shown, Figure 1 This is a flow chart of an embodiment of the working method of the fingerprint lock of the present invention. In this embodiment, the working method of the fingerprint lock includes:
[0045] Step S10, the main control MCU generates an update key in a preset manner, encrypts the operation instruction to be sent and the update key with its latest stored key, and adds them to the first communication message, sends the first communication message to the fingerprint module, and stores the update key;
[0046] When the main control MCU wants to communicate with the fingerprint module, the main control MCU first generates an update key in a preset manner, and then uses the latest stored key (i.e., the update key stored during the last communication) to encrypt the operation instruction to be sent and the update key of this time, and the encrypted operation instruction and update key are added to the first communication message, and the first communication message is sent to the fingerprint module. The main control MCU stores the update key of this time as the encryption key for the next communication. In this embodiment, the preset method for the main control MCU to generate the update key is, for example: 1. Randomly generate a random number of N (e.g., 8, 16, etc.) bytes; 2. Randomly generate a random number of N bytes, and combine the odd bytes of the random number of N bytes with the last few bytes of the MAC address of the fingerprint module obtained in advance to form an update key (such as the last 4 bytes of the fingerprint module MAC address + the 1st, 3rd, 5th, and 7th bytes of the 8-byte random number generated by the main control MCU); and so on. The encryption algorithm used by the main control MCU of this embodiment is preferably the RC4 algorithm, and of course, other encryption algorithms can also be used.
[0047] Step S20, after receiving the first communication message, the fingerprint module uses its latest stored key to decrypt the first communication message and verifies the communication content obtained by decryption;
[0048] After the fingerprint module receives the first communication message sent by the main control MCU, the fingerprint module uses its latest stored key (the latest stored key is the updated key obtained from the decrypted communication content in the last communication with the main control MCU) to decrypt the first communication message to decrypt the encrypted part of the first communication message, thereby obtaining all the communication content of the first communication message, and then the fingerprint module verifies the decrypted communication content. In this embodiment, the first communication message includes the XOR operation value of all data and the encrypted magic number, and the verification of the communication content by the fingerprint module includes: the verification of the XOR operation value for the integrity verification of the communication content and / or the magic number verification for the key in the communication content; the magic number is a fixed character used to verify the correctness of the data. After each decryption, in order to determine the correct decryption, it is necessary to compare the decrypted magic number with the pre-stored magic number. If they are consistent, it means that the decryption is correct.
[0049] Step S30, after the fingerprint module successfully verifies the communication content, it stores the updated key and executes the operation instruction in the communication content;
[0050] When the fingerprint module successfully verifies the decrypted communication content, it confirms that the first communication message is successfully decrypted. After verifying and confirming that the first communication message is successfully decrypted, the fingerprint module stores the updated key obtained by decrypting the first communication message for use in decrypting the message sent by the master MCU next time, and as an encryption key for the operation result of executing the operation instruction; the fingerprint module executes the operation instruction in the communication content.
[0051] Step S40, the fingerprint module encrypts the operation result of executing the operation instruction with the latest stored update key, adds it to the second communication message, and feeds the second communication message back to the main control MCU;
[0052] After the fingerprint module obtains the operation result of executing the operation instruction, it uses the latest stored update key to encrypt the operation result, then adds the encrypted operation result to the second communication message, and then feeds back the second communication message to the main control MCU.
[0053] In step S50, the main control MCU uses its latest stored update key to decrypt the second communication message, and verifies the decrypted content to perform corresponding processing according to the verification result.
[0054] After the main control MCU receives the second communication message fed back by the fingerprint module, the main control MCU uses its latest stored key to decrypt the second communication message fed back by the fingerprint module, and verifies the decrypted second communication message. The second communication message includes the XOR operation value of all data and the encrypted magic number. The verification of the second communication message fed back by the fingerprint module by the main control MCU includes: verification of the XOR operation value for integrity verification of the decrypted second communication message, and / or magic number verification for verifying the key in the communication content.
[0055] After the master MCU successfully verifies (i.e., the comparison is consistent), it performs corresponding processing (such as unlocking) according to the operation result in the second communication message. If the verification fails, the communication can be directly terminated or other processing can be performed.
[0056] In one embodiment, the main control MCU sends an operation instruction for fingerprint collection to the fingerprint module in a first communication message. After the fingerprint module executes the operation instruction for fingerprint collection, it feeds back the executed operation result to the main control MCU through a second communication message. After the main control MCU successfully verifies the second communication message, it controls the motor inside the smart door lock to perform an unlocking operation.
[0057] According to the technical solution of the present invention, the main control MCU will first update the key each time it communicates with the fingerprint module, and then encrypt the updated key and the operation instruction together with the key sent to the fingerprint module last time, add them into the communication message and send them to the fingerprint module, after the fingerprint module decrypts the communication message sent by the main control MCU and verifies it successfully, it stores the updated key in the decrypted communication content, which will be used to decrypt the communication message sent by the MCU next time and to encrypt the operation result fed back to the main control MCU, so that different keys are used for each communication between the main control MCU and the fingerprint module, which effectively avoids the interchange of fingerprint modules, cracking and replay attacks, and ensures the security of the fingerprint lock; at the same time, this solution does not add any additional hardware chips, and will not increase the additional hardware cost.
[0058] Furthermore, in this embodiment, after step S10, the working method of the fingerprint lock further includes:
[0059] If the main control MCU does not receive a reply from the fingerprint module within a first preset time, determining whether the main control MCU has resent the first communication message;
[0060] After the main control MCU sends the first communication message to the fingerprint module, if the fingerprint module has no feedback within the first preset time (for example, 10 seconds), it is judged that the fingerprint module has not received the first communication message sent by the main control MCU or the first communication message sent by the main control MCU has failed to be sent, and other abnormal situations. At this time, the main control MCU determines whether the first communication message has been resent before, and determines whether to resend the first communication message again based on the resending record.
[0061] If the main control MCU has not resent the first communication message, resending the first communication message to the fingerprint module;
[0062] When the main control MCU determines that the first communication message has not been resent, the first communication message is resent to the fingerprint module to avoid the influence of such accidental abnormal situations as sending failure or receiving failure on the communication interaction.
[0063] If the main control MCU resends the first communication message, the communication with the fingerprint module is terminated.
[0064] When the main control MCU determines that the first communication message has been resent, it is likely that other abnormal conditions occur in the fingerprint module or the main control MCU. At this time, the first communication message is no longer resent, and the communication with the fingerprint module is directly terminated.
[0065] like Figure 2 As shown, Figure 2 This is a flow chart of a second embodiment of the working method of the fingerprint lock of the present invention; in this embodiment, the working method of the fingerprint lock also includes:
[0066] Step S60: If the fingerprint module fails to verify the communication content, a third communication message is sent to the main control MCU, wherein the third communication message includes a confirmation character indicating that the status is verification failure;
[0067] When the fingerprint module fails to verify the communication content and the data XOR operation value fails or the magic number verification fails, it means that the fingerprint module failed to decrypt the first communication message and did not decrypt correctly. At this time, the fingerprint module feeds back a third communication message containing a confirmation character with a status of verification failure to the main control MCU, telling the main control MCU that the fingerprint module decryption failed.
[0068] Step S70, the master control MCU verifies the received third communication message, and after the integrity check of the third communication message fails or the status of the confirmation character in the third communication message is confirmed to be a check failure, determines whether the master control MCU has resent the first communication message;
[0069] After receiving the third communication message fed back by the fingerprint module, the main control MCU first verifies the third communication message. In this embodiment, the third communication message contains the XOR operation value of all data, and the integrity check of the third communication message is to verify the XOR operation value of the third communication message. If the check fails, or the check succeeds but the status of the confirmation character is found to be a check failure, it is determined whether to repeat the first communication message, and the fingerprint module decrypts the first communication message again.
[0070] Step S80: if the main control MCU has not resent the first communication message, resend the first communication message to the fingerprint module;
[0071] Step S90: If the main control MCU has resent the first communication message, the communication with the fingerprint module is terminated.
[0072] Furthermore, in this embodiment, the working method of the fingerprint lock further includes:
[0073] The main control MCU sends a MAC address reading command to the fingerprint module;
[0074] The fingerprint module feeds back its own MAC address to the main control MCU;
[0075] The main control MCU stores the MAC address.
[0076] The above steps are performed when the main control MCU communicates with the fingerprint module for the first time. In addition, during the first communication, the main control MCU also generates an initial key based on the MAC address for storage and sends it to the fingerprint module for storage. Since the MAC address of each fingerprint module is unique, the initial key confirmed by the MAC address is also unique. Therefore, in subsequent use, if the fingerprint module is replaced, the new fingerprint module cannot decrypt the first communication message sent by the main control MCU. Therefore, this embodiment effectively solves the hidden danger of cracking the fingerprint lock by exchanging fingerprint modules.
[0077] Preferably, in this embodiment, the preset method for the master MCU to generate the update key is:
[0078] The main control MCU generates an n-byte random number, and combines a bytes (e.g., the last 4 bytes) of the MAC address of the fingerprint module stored in advance with any b bytes (e.g., the 1st, 3rd, 5th, and 7th bytes) of the generated n-byte (e.g., 8-byte) random number to form an update key.
[0079] Of course, in other embodiments, the master MCU may generate the update key in other ways.
[0080] like Figure 3As shown, the present invention also proposes a fingerprint lock 10, comprising a main control MCU 101 and a fingerprint module 102 connected to the main control MCU 101 for communication; the main control MCU 101 is used to generate an update key in a preset manner, encrypt the operation instruction to be sent and the update key with its latest stored key, add them to a first communication message, send the first communication message to the fingerprint module 102, and store the update key;
[0081] When the main control MCU101 wants to communicate with the fingerprint module 102, the main control MCU101 first generates an update key in a preset manner, and then uses the latest stored key (i.e., the update key stored during the last communication) to encrypt the operation instruction to be sent and the update key of this time, and the encrypted operation instruction and update key are added to the first communication message, and the first communication message is sent to the fingerprint module 102. The main control MCU101 stores the update key of this time as the encryption key for the next communication. In this embodiment, the preset method for the main control MCU101 to generate the update key is, for example: 1. Randomly generate a random number of N (e.g., 8, 16, etc.) bytes; 2. Randomly generate a random number of N bytes, and combine the odd bytes of the random number of N bytes with the last few bytes of the MAC address of the fingerprint module 102 obtained in advance to form an update key (such as the last 4 bytes of the MAC address of the fingerprint module 102 + the 1st, 3rd, 5th, and 7th bytes of the 8-byte random number generated by the main control MCU101); and so on. The encryption algorithm adopted by the main control MCU 101 of this embodiment is preferably the RC4 algorithm. Of course, other encryption algorithms may also be adopted.
[0082] The fingerprint module 102 is used to decrypt the first communication message using its latest stored key after receiving the first communication message, and verify the communication content obtained by decryption; and after the communication content verification is successful, store the updated key, execute the operation instruction in the communication content; and encrypt the operation result of executing the operation instruction using its latest stored updated key, add it to the second communication message, and feed the second communication message back to the main control MCU101;
[0083] After the fingerprint module 102 receives the first communication message sent by the main control MCU101, the fingerprint module 102 uses its latest stored key (the latest stored key is the updated key obtained from the decrypted communication content in the last communication with the main control MCU101) to decrypt the first communication message to decrypt the encrypted part in the first communication message, thereby obtaining all the communication content of the first communication message, and then the fingerprint module 102 verifies the decrypted communication content. In this embodiment, the first communication message includes the XOR operation value of all data and the encrypted magic number, and the verification of the communication content by the fingerprint module 102 includes: the verification of the XOR operation value for the integrity verification of the communication content and / or the magic number verification for verifying the key in the communication content; the magic number is a fixed character used to verify the correctness of the data. After each decryption, in order to determine the correct decryption, it is necessary to compare the decrypted magic number with the pre-stored magic number. If they are consistent, it means that the decryption is correct. When the fingerprint module 102 successfully verifies the decrypted communication content, it is confirmed that the first communication message is successfully decrypted. After verifying and confirming that the first communication message is successfully decrypted, the fingerprint module 102 stores the updated key obtained by decrypting the first communication message, so as to be used for decrypting the message sent by the main control MCU 101 next time, and as an encryption key for the operation result of executing the operation instruction; and the fingerprint module 102 executes the operation instruction in the communication content, and after obtaining the operation result of executing the operation instruction, uses the most recently stored updated key to encrypt the operation result, and then adds the encrypted operation result to the second communication message, and then feeds the second communication message back to the main control MCU 101. The second communication message contains an initial key, which is predetermined by the main control MCU 101 and the fingerprint module 102, and the initial key is stored in both the main control MCU 101 and the fingerprint module 102.
[0084] The main control MCU 101 is also used to use its latest stored update key to decrypt the second communication message, and verify the decrypted content to perform corresponding processing according to the verification result.
[0085] After the main control MCU101 receives the second communication message fed back by the fingerprint module 102, the main control MCU101 uses its latest stored key to decrypt the second communication message fed back by the fingerprint module 102, and verifies the decrypted second communication message. The second communication message includes the XOR operation value of all data and the encrypted magic number. The verification of the second communication message fed back by the fingerprint module by the main control MCU101 includes: verification of the XOR operation value for integrity verification of the decrypted second communication message, and / or magic number verification for verifying the key in the communication content.
[0086] After the main control MCU101 successfully verifies (i.e., the comparison is consistent), it performs corresponding processing (such as unlocking) according to the operation result in the second communication message. If the verification fails, the communication can be directly terminated or other processing can be performed.
[0087] In one embodiment, the main control MCU101 sends the operation instruction of fingerprint collection to the fingerprint module 102 in the first communication message. After executing the operation instruction of fingerprint collection, the fingerprint module 102 feeds back the executed operation result to the main control MCU101 through the second communication message. After the main control MCU101 successfully verifies the second communication message, it controls the motor inside the smart door lock to perform the unlocking operation.
[0088] According to the technical solution of the present invention, the main control MCU 101 will first update the key each time it communicates with the fingerprint module 102, and then encrypt the updated key together with the operation instruction using the key sent to the fingerprint module 102 last time, add it to the communication message and send it to the fingerprint module 102. After the fingerprint module 102 decrypts the communication message sent by the main control MCU 101 and verifies it successfully, it stores the updated key in the decrypted communication content, which will be used to decrypt the communication message sent by the MCU next time and to encrypt the operation result fed back to the main control MCU 101. In this way, different keys are used for each communication between the main control MCU 101 and the fingerprint module 102, which effectively avoids the interchange of the fingerprint module 102 for cracking and replay attacks, and ensures the security of the fingerprint lock 10. At the same time, this solution does not add any additional hardware chips, and will not increase the additional hardware cost.
[0089] Furthermore, in the present embodiment, the main control MCU 101 is also used to determine whether the first communication message has been resent to the fingerprint module 102 after not receiving a reply from the fingerprint module 102 within a first preset time; and after determining that the first communication message has not been resent, resend the first communication message to the fingerprint module 102; and after determining that the first communication message has been resent to the fingerprint module 102, terminate the communication with the fingerprint module 102.
[0090] After the main control MCU 101 sends the first communication message to the fingerprint module 102, if the fingerprint module 102 has no feedback within the first preset time (for example, 10 seconds), it is judged that the fingerprint module 102 has not received the first communication message sent by the main control MCU 101 or the first communication message of the main control MCU 101 fails to send and other abnormal situations. At this time, the main control MCU 101 determines whether the first communication message has been resent before, and determines whether to resend the first communication message again according to the resending record. When the main control MCU 101 determines that the first communication message has not been resent, the first communication message is resent to the fingerprint module 102 to avoid the influence of such accidental abnormal situations on the communication interaction due to the failure to send or receive. When the main control MCU 101 determines that the first communication message has been resent, it is likely that the fingerprint module 102 or the main control MCU 101 has other abnormal situations. At this time, the first communication message is no longer resent, and the communication with the fingerprint module 102 is directly terminated.
[0091] Preferably, the fingerprint module 102 is further used to send a third communication message to the main control MCU 101 after the communication content verification fails, and the third communication message contains a confirmation character with a status of verification failure;
[0092] The main control MCU101 is also used to verify the received third communication message, and after the integrity check of the third communication message fails or the status of the confirmation character in the third communication message is confirmed to be a verification failure, determine whether the first communication message has been resent to the fingerprint module 102; and after determining that the first communication message has not been resent, resend the first communication message to the fingerprint module 102; and after determining that the first communication message has been resent to the fingerprint module 102, end the communication with the fingerprint module 102.
[0093] When the fingerprint module 102 fails to verify the communication content and the XOR value of the data fails to be verified or the magic number fails to be verified, it means that the fingerprint module 102 fails to decrypt the first communication message and does not decrypt correctly. At this time, the fingerprint module 102 feeds back a third communication message containing a confirmation character with a status of verification failure to the main control MCU101, telling the main control MCU101 that the fingerprint module 102 fails to decrypt. After receiving the third communication message fed back by the fingerprint module 102, the main control MCU101 first performs an integrity check on the third communication message; in this embodiment, the third communication message contains the XOR value of all data, and the integrity check of the third communication message is to check the XOR value of the third communication message; if the integrity check of the third communication message fails, or the integrity check succeeds but the status of the confirmation character is found to be a verification failure, it is determined whether to repeat the first communication message and let the fingerprint module 102 decrypt the first communication message again.
[0094] Furthermore, in this embodiment, the main control MCU 101 is also used to send a MAC address read command to the fingerprint module, and store the MAC address fed back by the fingerprint module 102;
[0095] The fingerprint module 102 is further configured to feed back its own MAC address to the main control MCU 101 after receiving a MAC address read command.
[0096] The above operation is performed when the main control MCU 101 communicates with the fingerprint module 102 for the first time. In addition, during the first communication, the main control MCU 101 also generates an initial key based on the MAC address for storage, and sends it to the fingerprint module 102 for storage. Since the MAC address of each fingerprint module 102 is unique, the initial key confirmed by the MAC address is also unique. Therefore, in subsequent use, if the fingerprint module 102 is replaced, the new fingerprint module 102 cannot decrypt the first communication message sent by the main control MCU. Therefore, this embodiment effectively solves the hidden danger of cracking the fingerprint lock 10 by exchanging the fingerprint module 102.
[0097] Preferably, in this embodiment, the preset method for the master MCU 101 to generate the update key is:
[0098] The main control MCU101 generates an n-byte random number, and combines a bytes (e.g., the last 4 bytes) of the pre-stored MAC address of the fingerprint module 102 with any b bytes (e.g., the 1st, 3rd, 5th, and 7th bytes) of the generated n-byte (e.g., 8-byte) random number to form an update key.
[0099] Of course, in other embodiments, the master MCU 101 may generate the update key in other ways.
[0100] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the inventive concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. A fingerprint lock working method, characterized in that: The fingerprint lock includes a main control MCU and a fingerprint module that is communicatively connected to the main control MCU. The working method includes the following steps: A. The master control MCU generates an update key in a preset manner, encrypts the operation instruction to be sent and the update key with its latest stored key, and adds them to the first communication message, sends the first communication message to the fingerprint module, and stores the update key, wherein the preset manner for the master control MCU to generate the update key is: the master control MCU generates an n-byte random number, and combines a bytes of the MAC address of the fingerprint module stored in advance with any b bytes of the generated n-byte random number to form an update key; B. After receiving the first communication message, the fingerprint module uses its latest stored key to decrypt the first communication message and verify the communication content obtained by decryption; C. After the fingerprint module successfully verifies the communication content, the update key is stored and the operation instruction in the communication content is executed; D. The fingerprint module encrypts the operation result of executing the operation instruction with the updated key stored most recently, adds the encrypted result to the second communication message, and feeds the second communication message back to the main control MCU; E. The main control MCU uses its latest stored update key to decrypt the second communication message, and verifies the decrypted content to perform corresponding processing according to the verification result.
2. The working method of the fingerprint lock as claimed in claim 1, characterized in that: After step A, the working method further comprises: If the main control MCU does not receive a reply from the fingerprint module within a first preset time, determining whether the main control MCU has resent the first communication message; If the main control MCU has not resent the first communication message, resending the first communication message to the fingerprint module; If the main control MCU resends the first communication message, the communication with the fingerprint module is terminated.
3. The working method of the fingerprint lock as claimed in claim 1, characterized in that: The working method also includes: If the fingerprint module fails to verify the communication content, a third communication message is sent to the main control MCU, wherein the third communication message includes a confirmation character indicating that the status is verification failure; The master control MCU verifies the received third communication message, and after the integrity check of the third communication message fails or the status of the confirmation character in the third communication message is confirmed to be a check failure, determines whether the master control MCU has resent the first communication message; If the main control MCU has not resent the first communication message, resending the first communication message to the fingerprint module; If the main control MCU resends the first communication message, the communication with the fingerprint module is terminated.
4. The working method of the fingerprint lock as claimed in claim 1, characterized in that: The first communication message and the second communication message both contain an encrypted magic number, and the verification of the decrypted communication content by the fingerprint module and the verification of the decrypted content by the main control MCU both include: integrity verification and magic number verification.
5. The working method of the fingerprint lock according to any one of claims 1 to 4, characterized in that: The working method also includes: The main control MCU sends a MAC address reading command to the fingerprint module; The fingerprint module feeds back its own MAC address to the main control MCU; The main control MCU stores the MAC address.
6. A fingerprint lock, characterized in that: It includes a main control MCU and a fingerprint module connected to the main control MCU; The master control MCU is used to generate an update key in a preset manner, encrypt the operation instruction to be sent and the update key with its latest stored key, and add them to the first communication message, send the first communication message to the fingerprint module, and store the update key. The preset manner for the master control MCU to generate the update key is: the master control MCU generates an n-byte random number, and uses a bytes of the MAC address of the fingerprint module stored in advance and any b bytes of the generated n-byte random number to form an update key; The fingerprint module is used to decrypt the first communication message using its latest stored key after receiving the first communication message, and verify the communication content obtained by decryption; After the communication content is successfully verified, the update key is stored and the operation instruction in the communication content is executed; and encrypting the operation result of executing the operation instruction with the updated key stored most recently, adding the encrypted result to the second communication message, and feeding back the second communication message to the main control MCU; The main control MCU is also used to use its latest stored update key to decrypt the second communication message, and verify the decrypted content to perform corresponding processing according to the verification result.
7. The fingerprint lock according to claim 6, characterized in that: The main control MCU is also used to determine whether the first communication message has been resent to the fingerprint module after not receiving a reply from the fingerprint module within a first preset time; and resend the first communication message to the fingerprint module after determining that the first communication message has not been resent; And after determining that the first communication message has been resent to the fingerprint module, the communication with the fingerprint module is terminated.
8. The fingerprint lock as claimed in claim 6, characterized in that: The fingerprint module is also used to send a third communication message to the main control MCU after the communication content verification fails, and the third communication message contains a confirmation character with a status of verification failure; The main control MCU is also used to verify the received third communication message, and after the integrity check of the third communication message fails or the status of the confirmation character in the third communication message is confirmed to be a check failure, determine whether the first communication message has been resent to the fingerprint module; and after determining that the first communication message has not been resent, resending the first communication message to the fingerprint module; And after determining that the first communication message has been resent to the fingerprint module, the communication with the fingerprint module is terminated.
