Temporary password generation and verification method for Internet of Things lock
By using the same encryption algorithms and encryption factors on smart locks and smart terminals to generate and verify temporary passwords, the problems of unreliability and insecure temporary passwords in smart locks are solved, and a safe and convenient temporary lock unlocking function is achieved.
Patent Information
- Application Number
- CN202411672159.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-02-25
AI Technical Summary
The temporary passwords in existing smart locks are unreliable and unsafe, making it difficult to meet the needs of temporary unlocking without affecting security and convenience.
By setting the same encryption algorithm and encryption factor on the smart lock and smart terminal, the hash message authentication code (HMAC) and SHA algorithm are used to generate temporary passwords, and offline verification is performed on the smart lock end, ensuring the security and reliability of temporary passwords.
It realizes the security and convenience of generating and verifying temporary passwords without the need for networking, enhances the security and user experience of smart locks, and reduces the risk of network attacks.
Smart Images

Figure CN119516651A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart lock key generation, and in particular to a temporary password generation and verification method for an Internet of Things lock. Background Art
[0002] Smart locks are increasingly used due to their simple operation, no need to carry keys, and high security. At the same time, more requirements are put forward for the functions of smart locks. For example, when the owner of the smart lock is not at home and someone needs to enter temporarily, the owner of the smart lock can only tell the visitor the password. For safety reasons, the owner of the smart lock needs to change the password afterwards, which brings a lot of inconvenience to the user.
[0003] In response to the application needs of temporary unlocking, smart locks with temporary password functions have appeared on the market, mainly including: 1) Setting and storing fixed temporary passwords in the local smart lock body, but the temporary password needs to be set in advance. In order to avoid the security risk of password leakage, the temporary password must be changed or deleted after use, which brings inconvenience to users; 2) For smart locks with networking functions, users set temporary passwords through APP and transmit them to the server. After receiving, the server sends it to the smart lock body. The smart lock body receives and stores the temporary password, but the smart lock in this way must have networking function, otherwise it cannot be unlocked, which reduces the reliability of temporary password unlocking, and the hardware cost is high, the power consumption is large, and it is vulnerable to network attacks during the communication process; 3) The smart lock consists of two parts: the smart lock body and the mobile phone APP. They have the same key library or the same temporary password algorithm built in when leaving the factory, such as the Chinese patent "Temporary Password Management Method and System for Non-Time Management of Smart Door Locks" (Patent No. 111260827 A) The SHA-1 encryption algorithm is used in the smart terminal to generate multiple temporary passwords. The user uses the same algorithm to generate multiple temporary passwords on the door lock end, and then compares them one by one to realize the offline temporary password unlocking function. However, the key library must be fixed in the smart lock before leaving the factory. Once the key library is cracked, it will lose its security, and the original key can be deduced by obtaining several sets of temporary passwords. In addition, after obtaining the encryption algorithm or source code, it is also easy to deduced the original password. Therefore, how to ensure the reliability and security of temporary passwords is a problem that needs to be solved urgently. Summary of the invention
[0004] In order to solve the problem that temporary passwords in existing smart locks in the background technology are unreliable and unsafe, the present invention provides a temporary password generation and verification method for an IoT lock.
[0005] The technical solution of the present invention is: a temporary password generation and verification method for an IoT lock, including a smart lock and a smart terminal, and setting a temporary password function on the smart lock. The specific operation steps are: S1, sleep state, the smart lock is in sleep state when there is no operation, reducing power consumption; S2. Touch the smart lock panel to wake up the smart lock; S3. Press *# keys continuously to enter the administrator password; S4. Password matching is successful and the menu interface is entered; S5. Enable the temporary password function in the menu interface; S6, activate the internal encryption algorithm; S7. The smart lock obtains a temporary password; On the premise that the temporary password function is enabled on the smart lock, the operation steps of the smart terminal are as follows: A1. Log in to the smart terminal and set the encryption factor M. This encryption factor must be the same as the encryption factor of the smart lock. A2. Enable the temporary password function in the smart terminal; A3. Activate the same encryption algorithm built into the smart terminal as that of the smart lock. A4. Generate a temporary password and pass it to the visitor; S8. The visitor enters a temporary password on the smart lock. S9. The smart lock compares the typed information with the temporary password generated by the smart lock to see if they are the same; if they are the same, the lock is unlocked; otherwise, it prompts that the unlocking failed.
[0006] As a further improvement of the present invention, in the above step S6, the input parameter of the algorithm is a hash-based message authentication code, which is processed using the following formula: Hmac(T,M) = H(T⊕opad)‖H(T⊕ipad)‖M Among them, T is the key used to generate HMAC, M is the data to be authenticated, and H is the hash function; opad and ipad are two fixed padding values; among them, each byte value of opad is 0x5C, and each byte value of ipad is 0x36; the symbol ⊕ represents a bitwise XOR operation, and ‖ represents a concatenation operation.
[0007] As a further improvement of the present invention, the smart lock secure offline unlocking password generation algorithm, in step S6, adopts the SHA algorithm for encryption processing, and the specific operation steps of the encryption algorithm are: S601, obtaining the local timestamp of the smart lock, and extracting a digital string of length L as a time factor T; S602, performing hash filling on the time factor T; S603, perform an XOR operation on the T digital string filled with hash and opad; S604, performing an XOR operation on the hash-filled T digital string and the iPad; S605, the encryption factor M is a digital string set by the user; S606, concatenate the XOR results of S603 and S604 with S605, and use the whole as input Y of the encryption algorithm; S607, perform inner hash operation according to input Y; S608. Obtain the final temporary password.
[0008] As a further improvement of the present invention, hash padding is performed so that the length of the information summary is B bytes.
[0009] As a further improvement of the present invention, the opad is 0x5c, and each byte is XOR-operated with opad.
[0010] As a further improvement of the present invention, the ipad is 0x36, and each byte is XORed with the ipad.
[0011] As a further improvement of the present invention, the inner hash operation has a preset 160-bit message digest buffer, which is operated N times with the input Y to obtain the final result.
[0012] As a further improvement of the present invention, the smart terminal includes a mini-program and / or an APP.
[0013] As a further improvement of the present invention, the encryption algorithm is valid for 5 minutes, and the allowable time error is 2 minutes. After the encryption algorithm is activated, the time factor is advanced forward by 7 minutes and then backward by 2 minutes to generate 9 groups of temporary passwords. The lock can be unlocked if the temporary password typed externally is the same as one of them.
[0014] As a further improvement of the present invention, the normal password for unlocking the smart lock is 6 digits, and the temporary password is 8 digits; when the temporary password is entered, the smart lock will be triggered to start the internal encryption algorithm, generating 9 groups of temporary passwords, which will match the entered temporary passwords, and the lock can be unlocked if they are the same; password matching is performed, and if the input matches are unsuccessful for 3 times, the system will be locked for 3 minutes, and the unlocking failure will be prompted.
[0015] The beneficial effects of the present invention are: whether to enable the offline temporary password is controlled by the user; the temporary password can be enabled or disabled at any time on the smart lock side according to demand, and the function is flexible to meet the diverse needs of users; the dual information input method of time factor and encryption factor is adopted, and no other additional mechanism is required to ensure data integrity and convenience of operation; there is no communication connection between the smart lock and the smart terminal to prevent network attacks during communication transmission; the algorithm used is irreversible in itself, and each user will set a different encryption factor by himself to achieve double insurance, and even if the structure of the algorithm is known, it cannot be cracked; there is an effective time setting for the temporary password, and the time consistency requirement for the smart lock and the smart terminal is not strict, and a certain time error is allowed, which reduces the requirements for the internal system of the smart lock. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 The flowchart of opening the temporary password of the smart lock terminal of the present invention.
[0017] Figure 2 The encryption algorithm flow chart of the present invention.
[0018] Figure 3 This is a flow chart of the present invention for opening a smart lock using a temporary password through a smart terminal. DETAILED DESCRIPTION
[0019] The embodiments of the present invention are further described below in conjunction with the accompanying drawings: Depend on Figure 1 Combination Figure 2-3 As shown, a temporary password generation and verification method for IoT locks is different from the existing method that requires networking or connecting to a temporary password server first. The present invention does not require networking at all. It includes a smart lock and a smart terminal. These two parts have the same key generation algorithm, extract the same time factor and message key as input, and can generate the same temporary password. This method allows the smart lock user to set the encryption factor independently, and can control whether to turn on the offline password mode. When a temporary password is needed to unlock the lock, under the premise that the lock body opens the temporary password, click on the temporary password on the mobile phone APP, which will activate the internal encryption algorithm and obtain the temporary password. Type the temporary password generated by the mobile phone into the smart lock body. If it is the same as the temporary password of the lock body, the lock will be unlocked. The temporary unlocking function of the smart lock is realized, ensuring the safety and convenience of the smart lock.
[0020] The method for offline temporary password unlocking requires a smart lock and a smart terminal, wherein the smart terminal includes a mini program and / or an APP; the smart terminal can be a WeChat mini program or a mobile phone APP, or an APP or mini program on other smart devices. Take a mobile phone APP as an example for explanation.
[0021] To enable the temporary password function on the smart lock, the specific steps are as follows: S1, sleep state, the smart lock is in sleep state when there is no operation, reducing power consumption; S2. Touch the smart lock panel to wake up the smart lock; S3. Press *# keys continuously to enter the administrator password; S4. Password matching is successful and the menu interface is entered; S5. Enable the temporary password function in the menu interface; S6, activate the internal encryption algorithm; S7. The smart lock obtains a temporary password; If the user wants to allow visitors to open the door with a temporary password, the following process is required. Under the premise that the temporary password function is enabled on the smart lock, the operation steps of the smart terminal are as follows: A1. Log in to the smart terminal and set the encryption factor M. This encryption factor must be the same as the encryption factor of the smart lock. A2. Enable the temporary password function in the smart terminal; A3. Activate the same encryption algorithm built into the smart terminal as that of the smart lock. A4. Generate a temporary password and pass it to the visitor; S8. The visitor enters a temporary password on the smart lock. S9. The smart lock compares the typed information (usually numbers, but can also be other information, such as patterns, etc.) with the temporary password generated by the smart lock to see if they are the same; if they are the same, the lock is unlocked, otherwise the unlocking failure is prompted. The beneficial effects of the present invention are that whether to open the offline temporary password is controlled by the user; the temporary password can be opened or closed at any time according to the needs at the smart lock end, and the function is flexible to meet the diverse needs of users; the dual information input method of time factor and encryption factor is adopted, and no other additional mechanism is required to ensure data integrity and convenience of operation; there is no communication connection between the smart lock and the smart terminal to prevent network attacks during communication transmission; the algorithm used itself is irreversible, and each user will set different encryption factors by himself to achieve double insurance, and even if the structure of the algorithm is known, it cannot be cracked; there is an effective time setting for the temporary password, and the time consistency requirements for the smart lock and the smart terminal are not strict, and a certain time error is allowed, which reduces the requirements for the internal system of the smart lock. Through the above steps, the problem of how to let visitors open the smart lock when the smart lock user is not on site can be solved safely and conveniently. Therefore, the temporary password generated by the present invention is transformed from the time factor and the encryption factor set by the user, and the password is evolved by combining HMAC-SHA to ensure the irreversibility of the algorithm and the uniqueness of the password. The same encryption algorithm is used on the smart lock side and the APP side to generate a consistent temporary password. This system does not need to be connected to the network, and a certain time error is allowed. Whether the temporary password function is turned on is set by the user, and the function is flexible to meet the needs of different users.
[0022] In the present invention, the user can set the temporary password function on or off at any time on the smart lock body to meet the diverse needs of users. The smart lock end turns on the temporary password function, but does not need to generate a temporary password at a fixed frequency. The encryption algorithm is only turned on when the temporary password is entered from the outside, which reduces the power consumption of the lock body.
[0023] The present invention sets the encryption algorithm to be effective for 5 minutes and allows a time error of 2 minutes. After the encryption algorithm is activated, the time factor is advanced forward by 7 minutes and then retracted by 2 minutes to generate 9 groups of temporary passwords. The lock can be unlocked if the temporary password entered externally is the same as one of them.
[0024] In the above step S6, the input parameter of the algorithm is a hash-based message authentication code, which is processed using the following formula: Hmac(T,M) = H(T⊕opad)‖H(T⊕ipad)‖M Where T is the key used to generate HMAC, M is the data to be authenticated, and H is the hash function. SHA-1 and SHA-256 are optional. opad and ipad are two fixed padding values, which are usually a byte sequence. Each byte value of opad is 0x5C, and each byte value of ipad is 0x36. The symbol ⊕ represents a bitwise XOR operation, and ‖ represents a concatenation operation.
[0025] Smart lock security offline unlocking password generation algorithm, in step S6, the SHA algorithm is used for encryption processing, and the specific operation steps of the encryption algorithm are: S601, obtaining the local timestamp of the smart lock, and extracting a digital string of length L as a time factor T; S602, performing hash filling on the time factor T; S603, perform an XOR operation on the T digital string filled with hash and opad; S604, performing an XOR operation on the hash-filled T digital string and the iPad; S605, the encryption factor M is a digital string set by the user; S606, concatenate the XOR results of S603 and S604 with S605, and use the whole as input Y of the encryption algorithm; S607, perform inner hash operation according to input Y; S608, get the final temporary password. This algorithm cannot restore information from the message digest, that is, the algorithm is irreversible; two different messages will not produce the same message digest, that is, the result is unique.
[0026] The time factor T extracted in the present invention is a digital string with a length of 12 bytes. For example, at 12:30 on January 1, 2021, T=202101011230.
[0027] Hash padding is performed so that the length of the information digest is B bytes, specifically, the length of the information digest is 20 bytes.
[0028] The opad is 0x5c, and each byte is XORed with opad. The opad is 0x5c, that is, 01011100, and all 20 bytes are XORed with opad.
[0029] The ipad is 0x36, and each byte is XORed with the ipad. The ipad is 0x36, that is, 00110110, and all 20 bytes are XORed with the ipad.
[0030] The inner hash operation of the present invention has a preset 160-bit message digest buffer, and performs N operations with input Y to obtain the final result. Specifically, the inner hash operation has a preset 160-bit message digest buffer, uses a 32-bit processing chip, and the buffer is preset with 5 words: A = 0x67452301; B = 0xEFCDAB89; C = 0x98BADCFE; D = 0x10325476; E = 0xC3D2E1F0. A, B, C, D, E, as initial values and input Y, perform 80 operations through operations such as shifting, XOR, adding constants, rounding, etc., to obtain a 20-byte message digest, and intercept the first 8 bits to obtain the final temporary password.
[0031] The normal unlocking password of the smart lock in the present invention is 6 digits, and the temporary password is 8 digits; when the temporary password is entered, the internal encryption algorithm of the smart lock is triggered to generate 9 sets of temporary passwords, which match the temporary passwords entered, and the lock can be unlocked if they are the same; if the passwords are matched, the system will be locked for 3 minutes if the input matches are unsuccessful 3 times, and the unlocking failure will be prompted. Through the above steps, the problem of how to allow visitors to open the smart lock when the smart lock user is not on site can be solved safely and conveniently. Compared with the existing smart locks with temporary password functions, it has higher reliability and security and is more difficult to crack.
[0032] In the description of the present invention, it should be noted that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.
[0033] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances. In addition, in the description of the present invention, unless otherwise specified, "plurality" means two or more.
[0034] Technical personnel should note that: Although the present invention has been described according to the above specific implementation methods, the inventive concept of the present invention is not limited to this invention, and any modification using the inventive concept will be included in the scope of protection of the patent right of the present invention.
Claims
1. A temporary password generation and verification method for an IoT lock, comprising a smart lock and a smart terminal, characterized in that : Set up the temporary password function on the smart lock. The specific steps are as follows: S1, sleep state, the smart lock is in sleep state when there is no operation, reducing power consumption; S2. Touch the smart lock panel to wake up the smart lock; S3. Press *# keys continuously to enter the administrator password; S4. Password matching is successful and the menu interface is entered; S5. Enable the temporary password function in the menu interface; S6, activate the internal encryption algorithm; S7. The smart lock obtains a temporary password; On the premise that the temporary password function is enabled on the smart lock, the operation steps of the smart terminal are as follows: A1. Log in to the smart terminal and set the encryption factor M. This encryption factor must be the same as the encryption factor of the smart lock. A2. Enable the temporary password function in the smart terminal; A3. Activate the same encryption algorithm built into the smart terminal as that of the smart lock. A4. Generate a temporary password and pass it to the visitor; S8. The visitor enters a temporary password on the smart lock. S9. The smart lock compares the typed information with the temporary password generated by the smart lock to see if they are the same; if they are the same, the lock is unlocked; otherwise, it prompts that the unlocking failed.
2. A temporary password generation and verification method for IoT lock according to claim 1, characterized in that In the above step S6, the input parameter of the algorithm is a hash-based message authentication code, which is processed using the following formula: Hmac(T,M) = H(T⊕opad)‖H(T⊕ipad)‖M Among them, T is the key used to generate HMAC, M is the data to be authenticated, and H is the hash function; opad and ipad are two fixed padding values; among them, each byte value of opad is 0x5C, and each byte value of ipad is 0x36; the symbol ⊕ represents a bitwise XOR operation, and ‖ represents a concatenation operation.
3. A temporary password generation and verification method for IoT lock according to claim 2, characterized in that Smart lock security offline unlocking password generation algorithm, in step S6, the SHA algorithm is used for encryption processing, and the specific operation steps of the encryption algorithm are: S601, obtaining the local timestamp of the smart lock, and extracting a digital string of length L as a time factor T; S602, performing hash filling on the time factor T; S603, perform an XOR operation on the T digital string filled with hash and opad; S604, performing an XOR operation on the hash-filled T digital string and the iPad; S605, the encryption factor M is a digital string set by the user; S606, concatenate the XOR results of S603 and S604 with S605, and use the whole as input Y of the encryption algorithm; S607, perform inner hash operation according to input Y; S608. Obtain the final temporary password.
4. A temporary password generation and verification method for IoT lock according to claim 3, characterized in that Hash padding is performed so that the length of the information summary is B bytes.
5. A temporary password generation and verification method for IoT lock according to claim 3, characterized in that The opad is 0x5c, and each byte is XORed with opad.
6. A temporary password generation and verification method for IoT lock according to claim 3, characterized in that The ipad is 0x36, and each byte is XORed with the ipad.
7. A temporary password generation and verification method for IoT lock according to claim 4, characterized in that The inner hash operation has a preset 160-bit message digest buffer, which is operated N times with the input Y to obtain the final result.
8. A temporary password generation and verification method for IoT lock according to claim 4, characterized in that The smart terminal includes a mini-program and / or an APP.
9. A temporary password generation and verification method for IoT lock according to claim 1, characterized in that The encryption algorithm is set to be valid for 5 minutes, with an allowable time error of 2 minutes. After activating the encryption algorithm, the time factor is advanced by 7 minutes and then moved back by 2 minutes to generate 9 sets of temporary passwords. The lock can be unlocked if the temporary password entered externally is the same as one of them.
10. A temporary password generation and verification method for IoT lock according to claim 1, characterized in that The normal password for unlocking the smart lock is 6 digits, and the temporary password is 8 digits. When you enter the temporary password, the smart lock will be triggered to start the internal encryption algorithm, generating 9 sets of temporary passwords, which will match the temporary passwords you entered. If the passwords are the same, the lock can be unlocked. If the passwords are matched three times and the match fails, the system will be locked for 3 minutes and the unlocking failure will be prompted.
Citation Information
Patent Citations
Temporary password management method and system for non-time management of intelligent door lock
CN111260827A