Temporary password generation and verification method of intelligent lock and intelligent lock

Through the time synchronization and password generation rules of the control end and the lock end, the contradiction between the temporary password length and security in the existing smart lock is solved, and a temporary password generation method with high security and ease of use is realized.

CN120823656APending Publication Date: 2025-10-21SHENZHEN XUANWU ZHIZAO TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410436060.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-11
Publication Date
2025-10-21

AI Technical Summary

Technical Problem

In the existing temporary password generation method of smart locks, if the password is too long, it will cause user input errors, affecting the user experience. If the password is too short, the security will be reduced, and the number of valid time code bits is limited, resulting in a high error rate.

Method used

The control end and the lock end synchronize time, set the same random number combination, temporary password configuration and generation rules, generate a temporary password that does not carry auxiliary information, and perform password comparison through the time fallback mechanism to ensure the security and effectiveness of the password.

Benefits of technology

It improves the security of temporary passwords, reduces error rates, improves user experience, and ensures the security and convenience of smart locks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120823656A_ABST
    Figure CN120823656A_ABST
Patent Text Reader

Abstract

The invention discloses a temporary password generation and verification method of an intelligent lock and the intelligent lock, and belongs to the technical field of intelligent locks. The control end and the lock end carry out time synchronization, the same random number combination, temporary password configuration and temporary password generation rules are set at the control end and the lock end, and the control end carries out password generation according to the number of times of use input by a user and the number of temporary passwords of the number of times of use generated within unit time recorded by the control end. The temporary password is generated and shared to the unlocking person, the lock end generates temporary password data according to the current time or obtains the temporary password data from the local storage to carry out password comparison, and if the current time comparison fails, time rollback is carried out, and the temporary password is regenerated to carry out password comparison. In the temporary password generated by the scheme, a specific digit does not need to be used for carrying auxiliary information such as use times and effective time, and the length of the temporary password can be set to be a reasonable length which can be accepted by a user, so that the safety of the temporary password is improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of smart locks, and in particular to a temporary password generation and verification method for a smart lock and a smart lock. Background Art

[0002] Many smart locks on the market support setting temporary passwords through mini-programs / APPs. In addition to the password itself, the generated temporary password usually uses specific digits to carry auxiliary information such as the number of times the temporary password is used and the effective time. The length of the temporary password needs to be set to a larger value. For example, in smart locks on the market, many temporary passwords are set to 12 digits, of which the password bit and the auxiliary information bit are both 6 digits. Among them, the effective time auxiliary information is a code based on a certain reference time. Because the number of coding bits is limited, a higher error rate will occur in the time period at the boundary of the reference time. In order to reduce the number of digits in the temporary password, some solutions use a 5-digit password plus 3 digits of auxiliary information to form an 8-digit temporary password. Because the above solution carries auxiliary information, the difficulty of cracking the temporary password is reduced, which reduces the security of the product. However, when the temporary password is too long, users are prone to input errors, which affects the user experience. Summary of the Invention

[0003] The technical problem to be solved by the present invention is: in view of the above-mentioned defects of the prior art, a temporary password generation and verification method for a smart lock and a smart lock are provided.

[0004] To achieve the above objectives, the present invention provides a method for generating and verifying a temporary password for a smart lock, the method comprising the following steps:

[0005] Step S1: The control terminal and the lock terminal synchronize time and configuration information. The configuration information includes a random number combination and a temporary password configuration. The temporary password configuration includes a temporary password length M, a temporary password validity period VT, a temporary password usage count combination {1, ..., N}, and a maximum number of temporary passwords generated per unit time for different usage counts {K1_NUM, ..., KN_NUM}. The control terminal and the lock terminal have the same temporary password generation rule built in. The temporary password generation rule is related to the input time, the random number combination, and the temporary password configuration.

[0006] Step S2: The control terminal obtains the number of times the temporary password entered by the user has been used and the number of temporary passwords generated for the number of times used per unit time as recorded by the control terminal, uses the current time as the input time, generates a temporary password using the password generation rule, and shares the temporary password with the unlocking person;

[0007] In step S3, the unlocker enters a temporary password at the lock end. The lock end uses the current time as the input time to generate temporary password data or obtains temporary password data from local storage and performs a password comparison. If the comparison fails, the input time is updated and a temporary password is regenerated for password comparison.

[0008] Preferably, the step S3 specifically includes:

[0009] Step S31, the lock terminal obtains the current time as the input time;

[0010] Step S32: If temporary password data matching the input time is locally stored, the locally stored temporary password data is compared with the input temporary password. If the comparison is successful but the remaining number of uses is 0, the unlocking action is not performed and the password comparison process is exited. If the comparison is successful and the remaining number of uses is greater than 0, the remaining number of uses is updated and the unlocking action is performed;

[0011] If there is no temporary password data matching the input time locally, the lock terminal generates a temporary password using the temporary password generation rule, compares the temporary password with the input password, and associates the parameters corresponding to the generated temporary password with the temporary password and stores them locally;

[0012] In step S33, if the temporary password comparison fails, the current time is rolled back by the unit time as the new input time, and the password comparison is continued according to the method of step S32. If no matching temporary password is found in all the rolled back input times within the temporary password validity time VT from the current time, it is determined that the temporary password input is incorrect and the unlocking action is not performed.

[0013] Preferably, the random number combination is used to identify different control terminals. When the control terminal registers as an administrator to the lock terminal, the lock terminal generates different random number combinations for different control terminals. The random number combination includes a first random number SK and a second random number SALT.

[0014] Preferably, the temporary password generation rule includes a characteristic content generation rule and an encryption rule. The characteristic content generation rule is used to generate characteristic content based on the input time, the number of times the temporary password entered by the user is used, and the number of temporary passwords generated the number of times within a unit time recorded by the control terminal. The encryption rule is used to encrypt the characteristic content to generate a temporary password; the characteristic content includes an input time field, a password use times field, a password serial number field, and a random number field; the encryption rule is: using the first random number SK as the key, using a secure encryption hash algorithm to perform an encryption operation on the characteristic content to generate a summary content, and then converting the summary content into a temporary password.

[0015] Preferably, the unit time is one hour, and the value of the input time field is the time value of the input time normalized to the hour; when the control terminal generates a temporary password through a temporary password generation rule, the current time is used as the input time of the temporary password generation rule.

[0016] Preferably, the specific method of converting the summary content into a temporary password is:

[0017] The digest content is grouped according to a certain rule, and the bytes in each group are XORed to obtain a first array; the number of groups = the length of the first array = RoundUp(M / 2), where M is the length of the temporary password; if M is an odd number, the upper 4 bits and the lower 4 bits of any byte in the first array are XORed to obtain a binary number with the upper 4 bits being 0, and the binary number is used to replace the corresponding original byte in the first array;

[0018] Separate the upper 4 bits and lower 4 bits of each byte in the first array and store them in a second array of M bytes, which is the length of the temporary password. If M is an odd number, for bytes in the first array whose upper 4 bits are 0 as obtained by the previous step, store their values ​​directly in the second array.

[0019] Construct a MAP array with a length of 16 bytes. The values ​​of the MAP array are all random numbers between 0 and 9.

[0020] Construct an output array OUT with a length of M bytes of the temporary password;

[0021] For each number in the second array, record its position in the second array as INDEX, use its value as the index to query the MAP array, obtain its mapped value in the MAP array, and fill the mapped value into the corresponding position of INDEX in the OUT array;

[0022] Concatenate all the numbers in the OUT array into a string according to certain rules to get a temporary password.

[0023] Preferably, when there are multiple groups of random number combinations on the lock end, when comparing the temporary password, the current time is obtained as the input time for generating the temporary password, and each group of random number combinations is used as a parameter in turn to compare the temporary password. When all random number combinations are traversed and no temporary password matching the input password is obtained, the current time is retracted by the unit time, and the temporary password comparison is continued, and this process is repeated until the comparison is completed.

[0024] Preferably, when the lock terminal generates characteristic content according to the characteristic content generation rule, if the difference between the input time and the next hourly time is less than a preset difference compensation time TD, the next hourly time is used to construct the characteristic content.

[0025] Preferably, the control end responds to the user's operation and, when connected to the lock end, dynamically adjusts the values ​​of the temporary password length M, the temporary password validity time VT, the number of uses of the temporary password {1,...,N}, and the maximum value combination of the number of temporary passwords generated with different numbers of uses per unit time {K1_NUM,...,KN_NUM}.

[0026] The present invention also provides a smart lock, including a control device, which includes a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, it executes the processing method of the smart lock end in the temporary password generation and verification method of the smart lock as described above.

[0027] The technical solution of the present invention is to synchronize the time between the control end and the lock end, and set the same random number combination, temporary password configuration and temporary password generation rules on the control end and the lock end. The temporary password generation rules include time information, random number combination information, and temporary password configuration information. The control end generates a temporary password according to the temporary password generation rules based on the number of times the temporary password entered by the user is used and the number of temporary passwords generated for the said number of times per unit time recorded by the control end, and shares it with the unlocker. The lock end generates temporary password data based on the current time or obtains temporary password data from local storage and performs password comparison. If the current time comparison fails, the time is rolled back and a new temporary password is generated for password comparison. Through the solution of the present invention, the generated temporary password does not need to use specific digits to carry auxiliary information such as the number of times the temporary password is used and the validity period, and there is no error rate problem caused by the limitation of the number of bits of the valid time code. The same temporary password length has higher security. Therefore, the temporary password length can be set to a reasonable length acceptable to the user, which not only improves the security of the temporary password but also improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0029] Figure 1 A schematic diagram of the steps of a method for generating and verifying a temporary password for a smart lock provided in an embodiment of the present invention.

[0030] Figure 2 A schematic diagram of the operation page for generating a temporary password provided in an embodiment of the present invention.

[0031] Figure 3 A schematic diagram of a page showing the result of generating a one-time temporary password according to an embodiment of the present invention.

[0032] Figure 4 This is a schematic diagram of a page showing the results of generating multiple valid temporary passwords according to an embodiment of the present invention.

[0033] Figure 5 A schematic diagram of the operation page for generating a temporary password provided in an embodiment of the present invention.

[0034] Figure 6 A schematic diagram of a page showing a list of historical temporary passwords provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of 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. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0036] The general idea of ​​the present invention is: the control end and the lock end are synchronized in time, and the same random number combination, temporary password configuration and temporary password generation rule are set on the control end and the lock end. The temporary password generation rule includes time information, random number combination information, and temporary password configuration information. The control end generates a temporary password according to the temporary password generation rule based on the number of times the temporary password entered by the user is used and the number of temporary passwords generated for the said number of times within a unit time recorded by the control end, and shares it with the unlocker. The lock end obtains temporary password data from local storage or generates temporary password data according to the current time, and performs password comparison. The lock is unlocked only if the password comparison is successful and the remaining number of times is greater than 0. If the current time comparison fails, the current time is rolled back, and the above method is repeated for password comparison until the time difference from the current time is greater than the preset temporary password validity time or the password comparison is successful.

[0037] The embodiments of the present invention are described in further detail below in conjunction with the accompanying drawings. It should be understood that the embodiments described herein are only used to illustrate and explain the present invention and are not intended to limit the present invention.

[0038] The control terminal described in the present invention includes an electronic device such as a mobile phone, laptop, tablet computer, wearable device, etc. that can install a mini-program or app and supports wireless connection such as WiFi, Bluetooth, Lora, ZigBee, 4G or 5G. The control terminal sets a temporary password for the smart lock through the mini-program / app.

[0039] This invention is suitable for smart locks that experience poor network signals and are often offline. The lock administrator can remotely generate a temporary password and provide it to the unlocker. It is also suitable for smart locks installed in offices, hotels, and shops, where there is high traffic and diverse temporary password requirements. Modern households with frequent needs such as courier pickups, visitors, and part-time cleaning services can also use the smart locks described in this invention to improve unlocking convenience.

[0040] like Figure 1 As shown, an embodiment of the present invention provides a method for generating and verifying a temporary password for a smart lock, the method comprising the following steps:

[0041] Step S1: The control terminal and the lock terminal synchronize time and configuration information. The configuration information includes a random number combination and a temporary password configuration. The temporary password configuration includes a temporary password length M, a temporary password validity period VT, a temporary password usage count combination {1, ..., N}, and a maximum number of temporary passwords generated per unit time for different usage counts {K1_NUM, ..., KN_NUM}. The control terminal and the lock terminal have the same temporary password generation rule built in. The temporary password generation rule is related to the input time, the random number combination, and the temporary password configuration.

[0042] In the prior art, the time of the control end is not used in the generation process of some temporary passwords. The control end uses certain digits of the temporary password as the validity period of the temporary password, and generates the password part of the temporary password through a temporary password generation algorithm agreed upon with the lock end. After the lock end receives the temporary password input by the user, it calculates the temporary password according to the temporary password generation algorithm. If the calculated temporary password matches the temporary password input by the user, the unlocking action is performed. Because this solution does not use the time information of the corresponding end during the password generation and verification process, it will cause the temporary password that has not been used to be valid all the time, which seriously reduces the security of the smart lock. Therefore, it is crucial to synchronize the time of the control end and the lock end, and generate and verify the temporary password based on the time value, in order to ensure the security of the smart lock.

[0043] In the technical solution of the present invention, the control terminal and the lock terminal are connected via a wireless connection method, and the wireless connection method includes WIFI, Bluetooth, ZigBee, Lora, 4G, and 5G. In the embodiment of the present invention, the purpose of time synchronization between the control terminal and the lock terminal is to synchronize the time of the lock terminal with that of the control terminal. The control terminal calculates a temporary password based on the time of the control terminal. When the lock terminal verifies the temporary password, it calculates the temporary password based on the time of the lock terminal. If the time of the control terminal and the time of the lock terminal are not synchronized, the lock terminal will not be able to calculate the same temporary password as the control terminal through the lock terminal time, and thus the temporary password verification cannot be achieved. In some embodiments of the present invention, the control terminal and the lock terminal are connected via Bluetooth. The control terminal has the ability to obtain an accurate clock. The control terminal directly synchronizes with the lock terminal by sending a time synchronization command to the lock terminal. In other embodiments of the present invention, the control terminal and the lock terminal are connected via a non-Bluetooth method. The control terminal and the lock terminal can achieve time synchronization indirectly through a third-party platform. The present invention does not limit the specific synchronization method.

[0044] The configuration information synchronization can be specifically implemented by transmitting the configuration information through communication between the control end and the lock end when the control end registers the administrator identity with the lock end. For example, when the control end registers the administrator identity, the lock end sends the configuration information to the control end. Optionally, configuration information synchronization can also be implemented by a third party, such as a server backend, sending the configuration information to the control end and the lock end respectively. The present invention does not limit the specific synchronization method.

[0045] In order to facilitate the generation and verification of the temporary password, the length of the temporary password is usually a fixed value. Therefore, in the embodiment of the present invention, the same temporary password length M is preset on the control end and the lock end.

[0046] In the temporary password scheme of the prior art, in addition to the password itself, the temporary password generated by the control end usually uses specific digits to carry auxiliary information such as the number of times the temporary password is used and the validity period. In order to make the password itself more difficult to crack, the length of the temporary password needs to be set to a larger value. For example, in smart locks on the market, the length of many temporary passwords is set to 12 digits, of which the password digit and the auxiliary information digit are both 6 digits. In the embodiment of the present invention, the temporary password digits only contain temporary password information and do not contain specific auxiliary information digits. Therefore, when the length of the temporary password in the embodiment of the present invention is set to 8 digits, 9 digits, 10 digits, etc., sufficient security can still be guaranteed.

[0047] In the embodiment of the present invention, considering that the general temporary password requirements all require short-term validity, the same temporary password validity time VT is set on the control end and the lock end. The value of VT is set to 24 hours to meet most requirements. The present invention has no limitation on the specific value of the temporary password validity time VT.

[0048] The embodiment of the present invention further sets the number of times the same temporary password can be used {1, ..., N} and the maximum number of temporary passwords generated per unit time {K1_NUM, ..., KN_NUM} on the control terminal and the lock terminal. The number of times the temporary password can be used {1, ..., N} and the maximum number of temporary passwords generated per unit time {K1_NUM, ..., KN_NUM} are common configurations for all control terminals. Each user of the control terminal is an administrator of the lock terminal, and each administrator can set a temporary password individually through their own control terminal. The maximum number of temporary passwords generated per unit time {K1_NUM, ..., KN_NUM} sets a temporary password limit for each control terminal, rather than a limit on the total number of temporary passwords generated by all control terminals.

[0049] The combination of {1,...,N} for the number of times a temporary password is used includes the number of times a temporary password is commonly used in daily life. For example, {1,3,5,10} supports the generation of temporary passwords with a number of uses of 1, 3, 5, and 10. Furthermore, the maximum number of temporary passwords generated per unit time, {K1_NUM,...,KN_NUM}, limits the number of temporary passwords with different numbers of uses. For example, for the combination of {1,3,5,10} for the number of times a temporary password is used, {K1_NUM,...,KN_NUM} = {10,1,1,1}, indicating that for each device, within a unit time, a temporary password with a number of uses of 1 can be generated at most 10 times, and a temporary password with a number of uses of 3, 5, and 10 can be generated at most 1 time. For example, to correspond to the temporary password usage count combination {1, 2, 4, 8}, set {K1_NUM, ..., KN_NUM} = {10, 3, 2, 1}. This means that within a unit of time, a temporary password with a usage count of 1 can be used at most 10 times, a temporary password with a usage count of 2 can be used at most 3 times, a temporary password with a usage count of 4 can be used at most 2 times, and a temporary password with a usage count of 8 can be used at most 1 time. For another example, to correspond to the temporary password usage count combination {1, 3, 5, 10, 9999}, set {K1_NUM, ..., KN_NUM} = {10, 2, 1, 1, 1}. This means that within a unit of time, a temporary password with a usage count of 1 can be used at most 10 times, a temporary password with a usage count of 3 can be used at most 2 times, and temporary passwords with a usage count of 5, 10, or 9999 can each be used at most 1 time. Setting the usage count to a larger number like 9999 allows an unlimited number of times within the temporary password's validity period VT, which can meet the need for frequent unlocking in a short period of time. In actual applications, you can also use a string such as 'UNLIMITED' to indicate an unlimited number of times. For example, if the number of uses is set to {1, 3, 10, 'UNLIMITED'}, set {K1_NUM,...,KN_NUM} = {10, 3, 1, 1}, which means that within a unit of time, a temporary password with a usage of 1 can be used at most 10 times, a temporary password with a usage of 3 can be used at most 3 times, and a temporary password with a usage of 10 times and 'UNLIMITED' can be used at most only 1 time.

[0050] The unit time is usually set to one hour. If the maximum number of temporary passwords set is used up within one hour, a new limit will be available within the next hour, and the previous unused limit will be reset to zero. The unit time can also be set to two hours or other values ​​as needed. For home users, there is a greater demand for generating temporary passwords that can be used once for couriers, visitors, or hourly workers who come to pick up packages temporarily. In a corporate environment, if there are multiple different couriers picking up packages, multiple temporary passwords that can be used once can be generated at one time; if the same courier picks up packages multiple times within the temporary password validity period VT, a temporary password that can be used multiple times can be generated. In a corporate environment, a temporary password that can be used multiple times can also be generated for each employee who works overtime on weekends. For homestays, short-term rentals, hotels, etc., one or more temporary passwords with a use count of 9999 or 'UNLIMITED' can be generated.

[0051] In some embodiments of the present invention, the random number combination is used to identify different control terminals. When the control terminal registers an administrator identity with the lock terminal, the lock terminal generates different random number combinations for different control terminals and stores all random number combinations locally.

[0052] To generate the same temporary password on both the control and lock terminals, identical temporary password generation rules are built into both terminals. These temporary password generation rules are related to the input time, the random number combination, and the temporary password configuration. The generated temporary password includes information such as the input time, the random number combination, and the number of unlocks. The same temporary password generation rules are preset on both the control and lock terminals. The control terminal generates a temporary password based on the preset temporary password generation rules in response to the user's input of temporary password generation conditions. The lock terminal uses the same temporary password generation rules to generate a series of possible temporary passwords to match the password entered by the user on the lock terminal. Therefore, even if the lock terminal is offline for an extended period, it can instantly generate a temporary password using the same temporary password generation rules as the control terminal and compare it with the temporary password entered by the user.

[0053] In some embodiments of the present invention, the control terminal, in response to user operation, dynamically adjusts the values ​​of the temporary password length M, the temporary password validity period VT, the combination of the number of temporary password uses {1,...,N}, and the maximum number of temporary passwords generated per unit time {K1_NUM,...,KN_NUM} when connected to the lock terminal. By adjusting the temporary password length M, dynamic support for temporary password length can be achieved. In this case, the control terminal and the lock terminal must have built-in temporary password generation rules corresponding to the temporary password length M. By adjusting the password validity period VT, personalized validity period requirements can be met. By adjusting the combination of the number of temporary password uses and the maximum number of temporary passwords generated per unit time, special requirements for the number of unlocking times and unlocking times can be met.

[0054] In some embodiments of the present invention, the random number combination includes a first random number SK and a second random number SALT.

[0055] The first random number SK and the second random number SALT are random number sequences generated by random number hardware or a pseudo-random algorithm. The present invention has no special requirements for the length of the first random number SK and the second random number SALT. For security reasons, it is recommended that the first random number SK and the second random number SALT be 64 bytes or longer. In the embodiment of the present invention, the length of the random number is generally 64 bytes.

[0056] The temporary password generation rules include characteristic content generation rules and encryption rules. The characteristic content generation rules are used to generate characteristic content based on the input time, the number of times the temporary password entered by the user is used, and the number of temporary passwords generated the number of times within a unit time recorded by the control terminal. The encryption rules are used to encrypt the characteristic content to generate a temporary password; the characteristic content includes an input time field, a password use count field, a password sequence number field, and a random number field.

[0057] In some embodiments of the present invention, the unit of the length of the temporary password validity period VT is hours, the unit time is one hour, and the value of the input time field is the time value of the input time normalized to the hour; when the control end generates a temporary password according to the temporary password generation rule, the current time is used as the input time of the temporary password generation rule.

[0058] The characteristic content is the content to be encrypted. In one embodiment of the present invention, the characteristic content is defined in the following format.

[0059] title:title

[0060] date: The current time normalized to the hour

[0061] num1: Number of times the temporary password is used

[0062] num2: Temporary password serial number

[0063] salt: second random number SALT

[0064] The title field is the title, and its content can be customized. Date is the input time field. In this embodiment of the present invention, the current time is normalized to the hour. num1 is the password usage count field, and num2 is the password sequence number field. If num1 is 1, a maximum of 10 temporary passwords with a usage count of 1 can be generated per unit time. In this case, num2 has a value of 1 to 10. The salt value selects a second random number, SALT, to improve the security of the encryption algorithm. num1 is the number of temporary password uses entered by the user on the Generate Temporary Password page, and num2 is the number of temporary passwords generated per unit time with that number of uses, as recorded by the control terminal, plus 1.

[0065] For example, between 2024-03-26 09:00:00 and 2024-03-26 09:59:59, the characteristic content of the fifth temporary password used once is as follows:

[0066] title:temp_passkey

[0067] date:2024-03-26 09:00:00

[0068] num1:1

[0069] num2:5

[0070] salt:SALT

[0071] All time values ​​between 2024-03-26 09:00:00 and 2024-03-26 09:59:59 are normalized to 2024-03-26 09:00:00. For example, if the control end generates a temporary password at 2024-03-26 09:08:00, 2024-03-26 09:08:00 is normalized to 2024-03-26 09:00:00 and used as the value of the date field to construct the feature content. If the control end generates a temporary password at 2024-03-26 09:48:00, 2024-03-26 09:48:00 is also normalized to 2024-03-26 09:00:00 and used as the value of the date field to construct the feature content.

[0072] The encryption rule is: using the first random number SK as a key, using a secure encryption hash algorithm to perform an encryption operation on the feature content to generate a summary content, and then converting the summary content into a temporary password.

[0073] The secure encryption hash algorithms include HMAC-MD5, HMAC-SHA1, HMAC-SHA256, and HMAC-SHA512. The above algorithms are all based on HMAC, which is a key-based message authentication code algorithm designed to ensure that data is not tampered with during transmission and to verify the identity of the sender. It generates a message digest of a fixed length associated with the message by combining a shared key and a hash function. This digest reflects the content of the original message and contains key information, so that only legitimate recipients with the same key can verify the authenticity of the message. The HMAC algorithm is widely used in various secure communication scenarios, including: network protocol security, API authentication, message queue security, and file integrity checking. Its application in the field of smart locks is still relatively small. The present invention chooses HMAC as the secure encryption hash algorithm because HMAC has high security and the digest content generated by HMAC is of moderate length, which is particularly suitable for smart lock application scenarios.

[0074] In the embodiment of the present invention, the specific method of converting the digest content into a temporary password is:

[0075] (1) Grouping the digest content according to a certain rule, performing an XOR operation on the bytes in each group to obtain a first array; the number of groups = the length of the first array = RoundUp(M / 2), where RoundUp() represents rounding up, and M is the length of the temporary password; if M is an odd number, performing an XOR operation on the upper 4 bits and the lower 4 bits of any byte in the first array to obtain a binary number with the upper 4 bits being 0, and replacing the corresponding original byte in the first array;

[0076] (2) Separate the upper 4 bits and lower 4 bits of each byte in the first array in turn, and store them into a second array of M bytes of the length of the temporary password; if M is an odd number, for the bytes in the first array whose upper 4 bits are 0 obtained by the previous step, directly store their values ​​into the second array, thereby obtaining a second array of an odd number of length;

[0077] (3) Construct a MAP array with a length of 16 bytes. The values ​​of the MAP array are all random numbers between 0 and 9.

[0078] (4) Construct an output array OUT with a length of M bytes of the temporary password;

[0079] (5) For each number in the second array, record its position in the second array as INDEX, use its value as the index to query the MAP array, obtain its mapping value in the MAP array, and fill the mapping value into the corresponding position of INDEX in the OUT array;

[0080] (6) All the numbers in the OUT array are concatenated into a string according to certain rules to obtain a temporary password.

[0081] Specifically, in some embodiments of the present invention, the secure encryption hash algorithm is HMAC-SHA1, the length of the digest content is 20 bytes, and the temporary password is a 10-digit decimal number. The method for converting the digest content into a temporary password is:

[0082] (1) Divide the summary content into 5 groups according to a certain rule, each group has 4 bytes, and perform an XOR operation on the 4 bytes in each group to obtain a first array with a length of 5 bytes. There are many specific grouping methods for dividing the summary content into 5 groups, such as grouping 4 adjacent bytes according to the order in which they appear in the summary content, that is, dividing the bytes into 5 groups according to the subscript range of the bytes in the summary content array: 0-3, 4-7, 8-11, 12-15, 16-19, or dividing adjacent numbers into different groups in sequence according to the order in which they appear in the summary content. The present invention only requires that all 20 bytes be divided into corresponding groups, and each byte only appears once, so as to fully utilize the summary content of each byte. Moreover, according to the same division method, the same grouping result can be obtained each time. The present invention has no limitation on the specific grouping method, and the same algorithm can be used on the control end and the lock end.

[0083] (2) Separate the upper 4 bits and lower 4 bits of each byte in the first array in sequence, and store them in a second array of 10 bytes in length. Specifically, the upper 4 bits and lower 4 bits of each byte in the first array can be separated and then stored in the second array in sequence, for example, in the order of the upper 4 bits of the first byte, the lower 4 bits of the first byte, the upper 4 bits of the second byte, and the lower 4 bits of the second byte. The present invention has no special restrictions on the specific storage rules, and the same algorithm can be used on the control end and the lock end. In this way, the summary content of 20 bytes in length is converted into a second array of 10 bytes in length, and the value range of each byte in the second array is 0 to 15.

[0084] (3) Construct a MAP array with a length of 16 bytes. The values ​​of the MAP array are all random numbers between 0 and 9.

[0085] (4) Construct an output array OUT with a length of 10 bytes.

[0086] (5) For each number in the second array, its position in the second array is recorded as INDEX, and its value is used as the index to query the MAP array to obtain its mapping value in the MAP array, and the mapping value is filled into the corresponding position of INDEX in the OUT array.

[0087] To convert the numbers 0 to 15 in the 10-byte second array into decimal numbers, a 16-byte MAP array is constructed. The MAP array is queried using the values ​​in the second array as indexes to obtain their mapped values ​​in the MAP array. These mapped values ​​are then entered into the OUT array to obtain a 10-byte decimal number. The values ​​in the MAP array are all random numbers between 0 and 9. To ensure the same algorithms on the control and lock ends, identical MAP arrays can be pre-set on both ends. The present invention does not impose any specific restrictions on the specific content of the MAP array; it only requires that each number in the range of 0 to 9 appear at least once in the MAP array. The mapped values ​​of the second array, after being mapped by the MAP array, can be stored in the OUT array in sequence or shuffled according to certain rules. This is not a limitation of the present invention; it is sufficient to ensure that the processing methods on the control and lock ends are consistent.

[0088] (6) All the numbers in the OUT array are concatenated into a string according to a certain rule to obtain a temporary password. Specifically, the numbers in the OUT array can be concatenated in sequence to form the temporary password, or the numbers can be shuffled and reassembled to form the temporary password. The present invention does not limit the specific concatenation method, as long as the processing methods of the control end and the lock end are consistent.

[0089] The following example illustrates how to convert a digest into a temporary password. Assume the temporary password is 10 characters long, CAL is the digest obtained by encrypting the signature using the HMAC-SHA1 algorithm, and is a 20-byte hexadecimal array. REDU is the first array of 5 bytes, and TENA is the second array of 10 bytes. The specific conversion method is as follows:

[0090] (1) Group the summary content CAL according to the following rules and perform XOR operation on each data in the group to obtain REDU, where ∧ represents XOR.

[0091] REDU[0]=CAL[0]∧CAL[5]∧CAL

[10] ∧CAL

[15]

[0092] REDU[1]=CAL[1]∧CAL[6]∧CAL

[11] ∧CAL

[16]

[0093] REDU[2]=CAL[2]∧CAL[7]∧CAL

[12] ∧CAL

[17]

[0094] REDU[3]=CAL[3]∧CAL[8]∧CAL

[13] ∧CAL

[18]

[0095] REDU[4]=CAL[4]∧CAL[9]∧CAL

[14] ∧CAL

[19]

[0096] (2) Use >> to represent right shift and & to represent AND operation to transform the values ​​in the first array REDU into the second array TENA. The specific transformation process is as follows.

[0097] TENA[0]=(REDU[0]>>4)&0x0F

[0098] TENA[1]=REDU[0]&0x0F

[0099] TENA[2]=(REDU[1]>>4)&0x0F

[0100] TENA[3]=REDU[1]&0x0F

[0101] TENA[4]=(REDU[2]>>4)&0x0F

[0102] TENA[5]=REDU[2]&0x0F

[0103] TENA[6]=(REDU[3]>>4)&0x0F

[0104] TENA[7]=REDU[3]&0x0F

[0105] TENA[8]=(REDU[4]>>4)&0x0F

[0106] TENA[9]=REDU[4]&0x0F

[0107] (3) Construct the MAP array shown below.

[0108] MAP[0]=0

[0109] MAP[1]=1

[0110] MAP[2]=2

[0111] MAP[3]=3

[0112] MAP[4]=4

[0113] MAP[5]=5

[0114] MAP[6]=6

[0115] MAP[7]=7

[0116] MAP[8]=8

[0117] MAP[9]=9

[0118] MAP

[10] =3

[0119] MAP

[11] =4

[0120] MAP

[12] =5

[0121] MAP

[13] =6

[0122] MAP

[14] =7

[0123] MAP

[15] =8

[0124] (4) Construct an output array OUT with a length of 10 bytes.

[0125] (5) Fill OUT with the mapping value of each number in the second array TENA in the MAP array. In this example, fill OUT with the mapping value of each number in TENA according to its subscript value in TENA. For example, if TENA[0] = 3, query MAP with 3 as index and get MAP[3] = 3, then OUT[0] = 3. If TENA[3] = 13, query MAP with 13 as index and get MAP

[13] = 6, then OUT[3] = 6.

[0126] (6) Concatenate the numbers in OUT to form a temporary password. In this example, the numbers in OUT are concatenated in the order they appear to be in to form a temporary password.

[0127] Assume that the length of the temporary password is 8, CAL1 is the digest content obtained by encrypting the feature content based on the HMAC-SHA1 algorithm, which is a 20-byte hexadecimal array, REDU1 is the first array with a length of 5 bytes, and TENA1 is the second array with a length of 8 bytes. The specific conversion method is as follows:

[0128] (1) Referring to the method with a temporary password length of 10, perform an XOR operation on each data in CAL1 to obtain REDU1. Randomly select 2 bytes in the REDU1 array and perform an XOR operation on them again. Keep the calculation result and combine the calculation result with the remaining 3 bytes in the REDU1 array to form a new 4-byte REDU1. For example, select REDU1[0] and REDU1[4] for calculation:

[0129] REDU1[0]=REDU1[0]∧REDU1[4]

[0130] REDU1[4] is discarded, and the new REDU1[0] and the remaining 3 bytes form a 4-byte REDU1 array.

[0131] (2) Referring to the method with a temporary password length of 10, the values ​​in the first array REDU1 are transformed into the second array TENA1, and the 8-bit temporary password conversion is completed according to the subsequent steps in the method with a temporary password length of 10.

[0132] Assume the temporary password is 8 characters long, CAL2 is the digest of the signature content encrypted using the HMAC-SHA256 algorithm, and is a 32-byte hexadecimal array. REDU2 is the first array of 4 bytes, and TENA2 is the second array of 8 bytes. The specific conversion method is as follows:

[0133] (1) Referring to the method of temporary password length 10, perform XOR operation on each data in CAL2 to obtain REDU2. For example, perform XOR operation on each data in CAL2 in the following manner:

[0134] REDU2[0]=CAL2[0]∧CAL2[4]∧CAL2[8]∧CAL2

[12] ∧CAL2

[16] ∧CAL2

[20] ∧CAL2

[24] ∧CAL2

[28]

[0135] REDU2[1]=CAL2[1]∧CAL2[5]∧CAL2[9]∧CAL2

[13] ∧CAL2

[17] ∧CAL2

[21] ∧CAL2

[25] ∧CAL2

[29]

[0136] REDU2[2]=CAL2[2]∧CAL2[6]∧CAL2

[10] ∧CAL2

[14] ∧CAL2

[18] ∧CAL2

[22] ∧CAL2

[26] ∧CAL2

[30]

[0137] REDU2[3]=CAL2[3]∧CAL2[7]∧CAL2

[11] ∧CAL2

[15] ∧CAL2

[19] ∧CAL2

[23] ∧CAL2

[27] ∧CAL2

[31]

[0138] (2) Referring to the method with a temporary password length of 10, the values ​​in the first array REDU2 are converted to the second array TENA2, and the 8-bit temporary password conversion is completed according to the subsequent steps in the method with a temporary password length of 10.

[0139] Assume that the length of the temporary password is 9, CAL3 is the digest content obtained by encrypting the feature content based on the HMAC-SHA1 algorithm, which is a 20-byte hexadecimal array, REDU3 is the first array with a length of 5 bytes, and TENA3 is the second array with a length of 9 bytes. The specific conversion method is as follows:

[0140] (1) Referring to the method of temporary password length 10, perform XOR operation on each data in CAL3 to obtain REDU3. Randomly select a byte of REDU3, perform XOR operation on its high 4 bits and low 4 bits, and obtain a binary number with high 4 bits of 0. This number and the remaining 4 bytes form REDU3. For example, select REDU3[0] for calculation:

[0141] REDU3[0]=((REDU3[0]>>4)∧(REDU3[0]&0x0F))&0x0F

[0142] Through the above calculation, REDU3[0] becomes a binary number with the upper 4 bits being 0.

[0143] (2) Referring to the method for a temporary password length of 10, the values ​​in the first array REDU3 are transformed into the second array TENA3. For the bytes in REDU3 whose upper 4 bits are 0 obtained by the previous transformation, their values ​​are directly stored in TENA3, thereby obtaining a TENA3 with a length of 9. For example, if REDU3[0] is a byte with upper 4 bits 0, let TENA3[0] = REDU3[0], and transform REDU3[1] to REDU3[4] into TENA3[1] to TENA3[8] according to the method for a temporary password length of 10. Then, referring to the subsequent steps in the method for a temporary password length of 10, the conversion from TENA3 to a 9-digit temporary password is completed.

[0144] In the prior art, some solutions use the HMAC-SHA1 algorithm to generate temporary passwords. However, in the subsequent step of generating the temporary password, the 20-byte digest generated by HMAC-SHA1 is truncated. In contrast, in the embodiments of the present invention, the digest generated by the HMAC-SHA1 algorithm or the HMAC-SHA256 algorithm is fully utilized, resulting in a temporary password with a lower repetition rate and correspondingly higher security.

[0145] In addition, in the temporary password generated by the solution of the embodiment of the present invention, each digit is password information, and no specific digit is used to represent auxiliary information such as the number of times the temporary password is used and the validity period. Therefore, even if the temporary password is intercepted, it is impossible to find the auxiliary information that facilitates cracking the temporary password, which increases the difficulty of cracking the temporary password.

[0146] In the prior art, many solutions use temporary passwords based on the administrator password. Before the temporary password is generated on the control end, the administrator password must be entered first. The administrator password is usually 6 to 8 digits long and relatively easy to crack. Once cracked or leaked, the temporary password can be generated by installing a mini-program / APP on the control end, rendering the temporary password useless. However, the solution of the embodiment of the present invention does not require the user to enter the administrator password. The temporary password is generated using random numbers pre-set on the control end and the lock end. Only the control end that has registered its administrator identity with the lock end has the authority to generate the temporary password, ensuring the security and reliability of the temporary password.

[0147] In step S2, the control end obtains the number of times the temporary password entered by the user has been used and the number of temporary passwords generated for the number of times in a unit time recorded by the control end, takes the current time as the input time, generates a temporary password using the password generation rule, and shares the temporary password with the unlocker.

[0148] Figure 2 Schematic diagram of the page for generating temporary passwords for the control terminal, the corresponding combination of the number of times a temporary password is used is {1,...,N}={1,5,'UNLIMITED'}, the corresponding maximum combination of the number of temporary passwords with different uses generated per unit time is {K1_NUM,...,KN_NUM}={10,2,1}, the unit time is 1 hour, that is, within each hour, 10 temporary passwords valid once, 2 temporary passwords valid five times, and 1 temporary password valid multiple times can be generated. In the page, "Number remaining" indicates the number of temporary passwords of each type remaining in the current unit time. The user selects the type of temporary password to be generated on the control terminal page, clicks the "Confirm" button below, and the control terminal generates a temporary password based on the type of temporary password selected by the user. Within an hour, the user can generate a temporary password at most Figure 2 The page shown generates 10 temporary passwords valid for one time, 2 temporary passwords valid for five times, and 1 temporary password valid for multiple times. For example, if the user selects "valid for one time" at 2024-03-26 09:10:00, a temporary password valid for one time is generated and the page jumps to Figure 3 The details page of the temporary password that is valid for one time is shown. At 2024-03-26 09:20:00, select "valid for multiple times" and generate a temporary password that is valid for multiple times. Jump to Figure 4 The details page of the multiple valid temporary passwords is shown. Figure 3 and Figure 4The generated temporary password content and the expiration time of the temporary password are displayed in the table. The control terminal records the number of temporary passwords generated per unit time in real time, which is used to construct the password sequence number field in the feature content. Based on the number of records, the "Number Remaining" section on the "Generate Temporary Password" page is updated. If a user accesses the "Generate Temporary Password" page at 2024-03-26 09:30:00, the "Generate Temporary Password" page will be displayed as follows: Figure 5 As shown, the "remaining number" corresponding to "valid once" and "valid multiple times" have been updated. Figure 6 This is the temporary password list page, where users can view information about all temporary passwords generated in the past.

[0149] In the embodiment of the present invention, the control terminal normalizes the current time to the hour, checks the remaining number of temporary passwords for each number of times of use, and if the remaining number is 0, Figure 2 Disable the corresponding selection box in the "Generate Temporary Password" page, or when the user selects this option, remind the user to re-trigger the temporary password generation operation at the next hour.

[0150] In existing technologies, the control terminal can usually only generate one unique temporary password per unit time, or by adding a digit to the temporary password as a loop digit, cycling through the numbers 0 to 9, to generate a maximum of 10 temporary passwords. In contrast, the present invention can generate multiple different temporary passwords per unit time based on a set value, increasing the flexibility of temporary password settings.

[0151] In step S3, the unlocker enters a temporary password at the lock end. The lock end uses the current time as the input time to generate temporary password data or obtains temporary password data from local storage and performs a password comparison. If the comparison fails, the input time is updated and a temporary password is regenerated for password comparison.

[0152] When multiple random number combinations exist on the lock, indicating the presence of multiple administrators, the lock uses the current time as the input time for generating the temporary password. Each random number combination is then used as a parameter for the temporary password comparison. If no matching temporary password is found after traversing all random number combinations, the lock sets the current time back by the specified unit time and continues the temporary password comparison, repeating this process until the comparison is complete. Using time as the first dimension and the controller / administrator as the second dimension allows for faster matching of the temporary password.

[0153] In the embodiment of the present invention, specifically, the lock terminal verifies the temporary password according to the following steps:

[0154] Step S31, the lock terminal obtains the current time as the input time;

[0155] Step S32: If temporary password data matching the input time is locally stored, the locally stored temporary password data is compared with the input temporary password. If the comparison is successful but the remaining number of uses is 0, the unlocking action is not performed and the password comparison process is exited. If the comparison is successful and the remaining number of uses is greater than 0, the remaining number of uses is updated and the unlocking action is performed;

[0156] If there is no temporary password data matching the input time locally, the lock terminal generates a temporary password using the temporary password generation rule, compares the temporary password with the input password, and associates the parameters corresponding to the generated temporary password with the temporary password and stores them locally;

[0157] In step S33, if the temporary password comparison fails, the current time is rolled back by the unit time as the new input time, and the password comparison is continued according to the method of step S32. If no matching temporary password is found in all the rolled back input times within the temporary password validity time VT from the current time, it is determined that the temporary password input is incorrect and the unlocking action is not performed.

[0158] In the present invention, when the control terminal generates a temporary password, it uses the current time as the input time for the temporary password generation rule, and the generated temporary password is shared with the unlocker. However, the time when the unlocker enters the temporary password on the lock terminal lags behind the time when the temporary password is generated. The lock terminal recognizes that the input password is a delayed temporary password and cannot obtain the generation time of the temporary password from the temporary password. Therefore, the lock terminal generates a temporary password according to the preset temporary password generation rule starting from the current time, and compares the generated temporary password with the password entered by the user one by one. If the temporary password within the current time cannot match the password entered by the user, the current time is rolled back, and the temporary password is generated using the rolled back time, and compared with the password entered by the user. The password comparison ends until the password comparison is successful or no matching temporary password is found for all the rolled back input times within the temporary password validity time VT from the current time.

[0159] The following example illustrates the lock's password comparison process using fallback. Assume the unit time is 1 hour, the number of control-side administrators corresponding to the lock is 1, and the control side generates a temporary password with a usage count of 1 at 9:06 AM on March 26, 2024. The control side uses the normalized hourly time 2024-03-26 09:00:00 as the input time field to construct feature content and perform encryption to obtain the temporary password. The key preset configurations for the control side and lock side are: temporary password length M = 10, temporary password validity period VT = 24 hours, the number of temporary password usage combinations {1,...,N} = {1, 5, 10, 20}, and the maximum number of temporary passwords generated per unit time with different usage counts {K1_NUM,...,KN_NUM} = {10, 1, 1, 1}. Then, every hour, the maximum number of temporary passwords that may be generated is 10+1+1+1=13, including 10 temporary passwords used 1 time, 1 temporary password used 5 times, 1 temporary password used 10 times, and 1 temporary password used 20 times.

[0160] Assume that the unlocker enters a temporary password on the lock at 11:08 AM on March 26, 2024. The lock doesn't have any temporary password data for that date yet. For ease of description, 11:08 AM on March 26, 2024, will be referred to as the "unlock time." The lock normalizes the unlock time to 2024-03-26 11:00:00 and uses this time value as the input time field to construct the feature content and perform encryption to obtain the temporary password. Because the preset temporary password configuration allows each administrator to generate a maximum of 13 temporary passwords per hour, the lock generates 13 temporary passwords corresponding to 2024-03-26 11:00:00, including 10 temporary passwords with a use count of 1, 1 temporary password with a use count of 5, 1 temporary password with a use count of 10, and 1 temporary password with a use count of 20. The lock then compares these 13 temporary passwords against the password entered by the unlocker, finding all of them failed. The lock then rewinds the unlock time by one hour to 10:08 AM on March 26, 2024, and normalizes it to 2024-03-26 10:00:00, generating the corresponding 13 temporary passwords. The lock then compares these temporary passwords against the password entered by the unlocker, finding all of them failed. The lock will roll back the unlock time by one hour to 9:08 AM on March 26, 2024, and normalize it to 2024-03-26 9:00:00. This is the same time the controller used to generate the temporary password. Therefore, among the passwords generated by the lock for unlocking with a count of 1 based on this time, one will necessarily match the temporary password generated by the controller. If the unlocker enters the correct password, the lock will successfully match the password. If the temporary password validity period VT = 24 hours, the lock will need to roll back the time a maximum of 23 times. For each administrator, the lock will generate 13 passwords each time, for a maximum of 24 x 13 = 312 passwords generated consecutively, and 312 password comparisons performed. If the lock has three administrators, the lock will generate a maximum of 24 x 13 x 3 = 936 passwords during the password comparison.

[0161] To improve the efficiency of multiple temporary password verifications within the temporary password's validity period (VT), the lock stores the parameters corresponding to each generated temporary password locally in association with the temporary password during the password comparison process. The parameters corresponding to the generated temporary password include the number of times the temporary password has been used. After the lock recognizes that the password entered by the unlocker is a temporary password, it first searches the local storage for temporary password data corresponding to the current time. If so, it directly uses the stored temporary password data to verify the temporary password. The lock determines whether there are any remaining uses of the temporary password based on the number of uses of the temporary password stored in association with the temporary password. After a successful temporary password comparison, if the locally stored number of uses of the temporary password is greater than 0, the unlocking operation is performed and the number of uses of the temporary password is reduced by 1. The next time the lock matches the same temporary password, if the number of uses of the temporary password is 0, the unlocking operation is not performed and the password comparison process is exited.

[0162] Although the control and lock terminals are synchronized, they may still experience clock misalignment after long-term operation due to various reasons. If the lock terminal's clock is faster than the control terminal's, as long as the time difference between the two terminals is less than 24 hours, the lock terminal can revert to the time when the control terminal generated the temporary password, generate the same temporary password as the control terminal, and successfully compare it with the password entered by the unlocker. If the lock terminal's clock is slower than the control terminal's, and the control terminal is faster than a certain hourly time, the lock terminal is slower than the said hourly time. For example, if the control terminal generates a temporary password at 2024-03-26 09:00:01 using 2024-03-26 09:00:00, and the unlocker enters the password on the lock terminal, the lock terminal's time is 2024-03-26 08:55:00. The lock terminal will then start password verification at 2024-03-26 08:00:00, and the lock terminal will not be able to generate the same temporary password as the control terminal. In some embodiments of the present invention, a time difference compensation mechanism is introduced, that is, when the lock terminal generates feature content according to the feature content generation rule, if the difference between the input time and the next hourly time is less than the preset difference compensation time TD, the next hourly time is used to construct the feature content.

[0163] Specifically, TD is set to a shorter time value, such as 5 minutes. Assuming the lock time is 2024-03-26 08:55:00 when the unlocker enters the password on the lock, after introducing a 5-minute time compensation, the lock will start password verification at 2024-03-26 09:00:00. The time compensation mechanism ensures that the lock can still successfully verify the temporary password even if the time lag between the lock and the control end is within TD.

[0164] In some application scenarios, the unit of the temporary password validity time VT is minutes, and the value is greater than 10, for example, 30 minutes or 40 minutes. In this case, the unit time can be adjusted accordingly, for example, to 10 minutes, and the value of the input time field of the temporary password generation rule is also adjusted accordingly, for example, normalized to the nearest ten minutes in the past time to the current time. The same adjustment is also made when the lock end verifies the temporary password. For example, if the temporary password validity period VT is 30 minutes, and the control end generates a temporary password at 2024-03-26 09:11:00, the time will be adjusted from 2024-03-26 09:11:00 to 2024-03-26 09:10:00 to construct the feature content. If the lock end receives the temporary password input at 2024-03-26 09:21:00, it will first adjust the time from 2024-03-26 09:22:00 to 2024-03-26 09:20:00 to construct the feature content and generate a temporary password. If it is found that the temporary password does not match the password entered by the user, the current time will be rolled back 10 minutes to 2024-03-26 09:12:00, and then adjusted to 2024-03-26 At 09:10:00, the signature content is constructed and a temporary password is generated. The temporary password generated at this time is exactly the same as the one generated by the control end. If the user enters the password correctly, the temporary password matches successfully. The unit time can also be adjusted to 5 minutes, and the principle is similar to adjusting it to 10 minutes.

[0165] An embodiment of the present invention also provides a smart lock, characterized in that it includes a control device, the control device includes a processor, a memory, and a computer program stored in the memory and runnable on the processor, and when the processor executes the computer program, it executes the lock-end processing method in the registration, login and management method of the smart lock as described above.

[0166] The technical solution of the present invention synchronizes time between the control terminal and the lock terminal, and sets the same random number combination, temporary password configuration, and temporary password generation rules on both terminals. The temporary password generation rules include time information, random number combination information, and temporary password configuration information. The control terminal generates a temporary password according to the temporary password generation rules based on the number of times the temporary password entered by the user has been used and the number of temporary passwords generated for the number of times used per unit time recorded by the control terminal. The temporary password is shared with the unlocking user according to the temporary password generation rules. The lock terminal generates temporary password data based on the current time or obtains temporary password data from local storage and performs a password comparison. The lock is unlocked only if the password comparison is successful and the remaining number of times is greater than 0. If the current time comparison fails, the current time is rolled back and the above method is repeated for password comparison until the time difference from the current time is greater than the preset temporary password validity period or the password comparison is successful. With the solution of the present invention, the generated temporary password does not need to use specific digits to carry auxiliary information such as the number of times the temporary password is used and the validity period, eliminating the error rate problem caused by the limited number of bits in the valid time encoding. The same temporary password length provides higher security. Therefore, the temporary password length can be set to a reasonable length acceptable to the user, which not only improves the security of the temporary password but also improves the user experience.

[0167] In addition, by adopting the solution of the present invention, a temporary password with a limited number of times and validity period can be generated, and multiple temporary passwords can be generated per unit time. Different control terminals can set temporary passwords, which greatly facilitates the temporary password setting process. When the lock terminal detects the temporary password, it automatically generates possible temporary passwords and compares them with the input passwords one by one. There is no need to store the temporary passwords generated in advance by the control terminal, so that the lock terminal can also verify the temporary passwords when it is offline for a long time, which greatly improves the convenience of using temporary passwords and enables each temporary password to be used independently without affecting each other.

[0168] Because the feature content carries a time field, the input time is normalized to the hour, so that a batch of new passwords can be generated every hour, which can meet the user's need to generate temporary passwords multiple times a day.

[0169] When the control end and the lock end are connected, the values ​​of the pre-set temporary password length M, password validity time VT, number of times the temporary password is used, and the maximum number of temporary passwords generated with different numbers of uses per unit time are dynamically adjusted to meet the user's diverse needs for temporary passwords.

[0170] The above is only a specific embodiment of the present invention and cannot be used to limit the scope of the present invention. Equal changes made by ordinary technicians in this technical field based on this creation, as well as changes well known to technicians in this field, should still fall within the scope of the present invention.

Claims

1. A method for generating and verifying a temporary password for a smart lock, characterized in that: The method comprises the following steps: Step S1: The control terminal and the lock terminal synchronize time and configuration information. The configuration information includes a random number combination and a temporary password configuration. The temporary password configuration includes a temporary password length M, a temporary password validity period VT, a temporary password usage count combination {1, ..., N}, and a maximum number of temporary passwords generated per unit time for different usage counts {K1_NUM, ..., KN_NUM}. The control terminal and the lock terminal have the same temporary password generation rule built in. The temporary password generation rule is related to the input time, the random number combination, and the temporary password configuration. Step S2: The control terminal obtains the number of times the temporary password entered by the user has been used and the number of temporary passwords generated for the number of times used per unit time as recorded by the control terminal, uses the current time as the input time, generates a temporary password using the password generation rule, and shares the temporary password with the unlocking person; In step S3, the unlocker enters a temporary password at the lock end. The lock end uses the current time as the input time to generate temporary password data or obtains temporary password data from local storage and performs a password comparison. If the comparison fails, the input time is updated and a temporary password is regenerated for password comparison.

2. The method for generating and verifying a temporary password for a smart lock according to claim 1, wherein: The step S3 specifically includes: Step S31, the lock terminal obtains the current time as the input time; Step S32: If temporary password data matching the input time is locally stored, the locally stored temporary password data is compared with the input temporary password. If the comparison is successful but the remaining number of uses is 0, the unlocking action is not performed and the password comparison process is exited. If the comparison is successful and the remaining number of uses is greater than 0, the remaining number of uses is updated and the unlocking action is performed; If there is no temporary password data matching the input time locally, the lock terminal generates a temporary password using the temporary password generation rule, compares the temporary password with the input password, and associates the parameters corresponding to the generated temporary password with the temporary password and stores them locally; In step S33, if the temporary password comparison fails, the current time is rolled back by the unit time as the new input time, and the password comparison is continued according to the method of step S32. If no matching temporary password is found in all the rolled back input times within the temporary password validity time VT from the current time, it is determined that the temporary password input is incorrect and the unlocking action is not performed.

3. The method for generating and verifying a temporary password for a smart lock according to claim 1, wherein: The random number combination is used to identify different control terminals. When the control terminal registers as an administrator with the lock terminal, the lock terminal generates different random number combinations for different control terminals. The random number combination includes a first random number SK and a second random number SALT.

4. The method for generating and verifying a temporary password for a smart lock according to claim 3, wherein: The temporary password generation rule includes a characteristic content generation rule and an encryption rule. The characteristic content generation rule is used to generate characteristic content based on the input time, the number of times the temporary password entered by the user is used, and the number of temporary passwords generated the number of times within a unit time recorded by the control terminal. The encryption rule is used to encrypt the characteristic content to generate a temporary password; the characteristic content includes an input time field, a password use number field, a password sequence number field, and a random number field; the encryption rule is: using the first random number SK as a key, using a secure encryption hash algorithm to perform an encryption operation on the characteristic content to generate a digest content, and then converting the digest content into a temporary password.

5. The method for generating and verifying a temporary password for a smart lock according to claim 4, characterized in that: The unit time is one hour, and the value of the input time field is the time value of the input time normalized to the hour; when the control terminal generates a temporary password according to the temporary password generation rule, the current time is used as the input time of the temporary password generation rule.

6. The method for generating and verifying a temporary password for a smart lock according to claim 4, wherein: The specific method of converting the digest content into a temporary password is: The digest content is grouped according to a certain rule, and the bytes in each group are XORed to obtain a first array; the number of groups = the length of the first array = RoundUp(M / 2), where M is the length of the temporary password; if M is an odd number, the upper 4 bits and the lower 4 bits of any byte in the first array are XORed to obtain a binary number with the upper 4 bits being 0, and the binary number is used to replace the corresponding original byte in the first array; Separate the upper 4 bits and lower 4 bits of each byte in the first array and store them in a second array of M bytes, which is the length of the temporary password. If M is an odd number, for bytes in the first array whose upper 4 bits are 0 as obtained by the previous step, store their values ​​directly in the second array. Construct a MAP array with a length of 16 bytes. The values ​​of the MAP array are all random numbers between 0 and 9. Construct an output array OUT with a length of M bytes of the temporary password; For each number in the second array, record its position in the second array as INDEX, use its value as the index to query the MAP array, obtain its mapped value in the MAP array, and fill the mapped value into the corresponding position of INDEX in the OUT array; Concatenate all the numbers in the OUT array into a string according to certain rules to get a temporary password.

7. The method for generating and verifying a temporary password for a smart lock according to claim 1, wherein: When there are multiple random number combinations on the lock end, when comparing the temporary password, the current time is obtained as the input time for generating the temporary password, and each random number combination is used as a parameter to compare the temporary password in turn. When all random number combinations are traversed and no temporary password matching the input password is obtained, the current time is retracted by the unit time, and the temporary password comparison is continued, and this process is repeated until the comparison is completed.

8. The method for generating and verifying a temporary password for a smart lock according to claim 4, wherein: When the lock terminal generates characteristic content according to the characteristic content generation rule, if the difference between the input time and the next hourly time is less than the preset difference compensation time TD, the next hourly time is used to construct the characteristic content.

9. The method for generating and verifying a temporary password for a smart lock according to claim 1, wherein: In response to user operations, the control end dynamically adjusts the values ​​of the temporary password length M, the temporary password validity time VT, the number of uses of the temporary password {1,...,N}, and the maximum number of temporary passwords generated with different numbers of uses per unit time {K1_NUM,...,KN_NUM} when connected to the lock end.

10. A smart lock, characterized in that: It includes a control device, which includes a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, it executes the processing method of the smart lock end in the temporary password generation and verification method of the smart lock as described in any one of claims 1 to 9.