Detailed Description
Embodiments of the present invention will now be described with reference to the drawings, wherein like parts are designated by like reference numerals. The embodiments described below and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is an exemplary flowchart of a reservation authorization method according to an embodiment of the present invention, where the reservation authorization method of the embodiment is applied to an authorizer, where the authorizer may be a terminal device of a homeowner of a house installed with an intelligent lock, an APP for authorization installed on the terminal device, or may also be a server associated with the terminal device of the homeowner or the APP for authorization.
As shown in fig. 1, the subscription authorization method of the present embodiment includes:
s101, generating a password field based on a reserved time period parameter and an agreed key factor;
s102, generating a reservation authorization code comprising the password field and a time field corresponding to the reservation period parameter;
s103, the reservation authorization code is sent to the authorized party, so that the authorized party provides the reservation authorization code for the intelligent lock to be verified.
In this embodiment, an APP for authorization (hereinafter, abbreviated as APP) installed on a terminal device in which an authorized party is a house owner is taken as an example for description. When the visitor contacts the homeowner ahead of time, tells it about the time of arrival, and requests reservation authorization, the homeowner may enter a reservation period parameter on the APP. For example, when the visitor announces an arrival time between 3 pm and 5 pm on 7/29/2019, the homeowner may select a start time of 15 on 7/29/2019 and an end time of 17 on 7/29/2019 in the date and time selection box on APP.
The APP may generate the password field S of the reservation authorization code based on the reservation period parameter entered by the homeowner and a key factor agreed with the smart lock in advance. The agreed key factor may be, for example, a fixed string or a random number that is regularly changed, etc. In some embodiments, the agreed key factor may include a management password of the smart lock by an authorized party, such as a homeowner, and when the agreed key factor includes the management password, the homeowner may enter the correct smart lock management password in the APP when the reservation authorization code needs to be generated, such that the generation of the reservation authorization code is strongly correlated with the smart lock management password to ensure that only a person who knows the smart lock management password can generate the temporary reservation authorization code of the smart lock. In some embodiments, the agreed-upon key factor may include a unique device identification, UID, of the smart lock to ensure that the temporary password is only available on the smart lock.
Meanwhile, the APP determines that the effective duration is 2 hours according to the input reservation time period parameters, and the effective time is 7 months, 29 days and 15 days in 2019, the corresponding duration code can be searched for the effective duration according to a predetermined coding rule, and the corresponding effective time code can be determined for the effective time.
For example, the valid duration may be in units of 30 minutes, and the encoding rule of the valid duration may be: 0-30 minutes; 1-1 hour; 2-2 hours; 3-6 hours; 4-12 hours; 1 day; 6-2 days; 7, 3 days; 8-4 days; when 9 is 5 days, the valid duration of 2 hours is coded as 2. It should be understood that this encoding rule is only an example given in this embodiment, and those skilled in the art can perform the required encoding on the commonly used valid duration as needed, for example, the valid duration may be set to be in units of 15 minutes, and the number of bits to be encoded may also not be limited to 1 bit number, but may be 2 bit numbers.
For example, the encoding rule of the effective time may be that a reference time is agreed in advance, and then the number of hours from the effective time of the present reservation to the reference time is encoded as the effective time, and for example, when the reference time is 2019, 7, month, 1, day 0, and the number of hours from the reference time when the effective time is 2019, 7, month, 29, and 15 in this embodiment is 28 × 24+15, 687, the encoding rule of the effective time of the present reservation may be 687, or 6870, 0687, and the like. In an example of the encoding rule, when the reference time is 0 on 1 day of the month, it may be updated every month, so that the number of encoding bits at the effective time may be limited to a predetermined number of bits.
In this embodiment, the APP may generate the password field S of the reservation authorization code based on the validation time code 687 corresponding to the validation time of the reservation and the agreed key factor, for example, the validation time code 687 and an agreed random number may be used to synthesize a salt, and after performing hash operation based on the agreed key factor and the salt, the operation result is used as the password field S.
Meanwhile, in this embodiment, the APP may combine the effective time code 687 and the duration code 2 into 6872 as a numerical value of the time field D, the password field S obtained by the operation may be, for example, 6-bit digits, and the password field S and the time field D may be combined into a reservation authorization code of 10-bit digits. The combining process may be sequentially splicing the password field S and the time field D, or sequentially splicing the numerical value of the time field D with the password field S after disordering the sequence according to an agreed rule, or arranging the time field D between any pair of adjacent password subfields after dividing the password field S into a plurality of subfields, and so on, so that an effect of preventing the combination rule from being easily recognized can be achieved.
And after the generation of the reservation authorization code is completed, the APP sends the reservation authorization code to the authorized party. The authorized party may be a terminal device of the visitor, a corresponding APP installed on the terminal device of the visitor, and so on. In this embodiment, the sending mode of the reservation authorization code is not limited, the APP can call programs such as a short message and a WeChat to send to the visitor, and the homeowner can also inform the visitor of the reservation authorization code through the modes such as WeChat, short message, email, telephone announcement and the like after the APP generates the reservation authorization code.
After the visitor knows the reservation authorization code, the visitor arrives at the door within the reserved time period, the reservation authorization code is input into a panel of an intelligent lock on the door, the intelligent lock verifies the reservation authorization code, if the reservation authorization code passes the verification, the visitor is unlocked, the unlocking record can be uploaded, and the unlocking record is marked as 'temporary password unlocking'. Specifically, after receiving the input reservation authorization code, the smart lock first determines whether the password is a fixed password or a temporary password, and the determination may be performed according to a difference of bits, for example, the fixed password may be 8 bits, and the temporary password may be 10 bits. After the intelligent lock judges that the intelligent lock is a temporary password, the reservation authorization code is verified according to the generation rule of the temporary password, in the embodiment, firstly, according to an agreed combination rule (such as the above sequence splicing, disorder splicing and the like), a password field and a time field are extracted from the reservation authorization code, a valid time code is extracted from the time field, the valid time code and an agreed random number are combined into a salt value, after hash operation is carried out based on an agreed key factor and the salt value, the operation result is compared with the password field, if the comparison result is consistent, the corresponding valid time period is determined according to the valid time corresponding to the valid time code and the valid duration corresponding to the duration code in the time field, whether the current time is within the authorized valid time period is determined according to the current system time of the intelligent lock, and if the current time is determined to be within the valid reserved time period, the intelligent lock is unlocked for the visitor, and the visitor can enter the house to take needed articles or perform transaction processing and the like.
By the reservation authorization method, the reservation authorization code with the effective time period limit is generated and issued to the visitor as the temporary password, so that the unlocking requirement of the visitor when the visitor is inconvenient to remotely unlock in real time can be met, the safety can be ensured, and the operation process is simple, convenient and easy to implement.
In an embodiment of the present invention, it is also unnecessary to encode the effective time, the password field may be generated according to an agreed key factor and a count value C, and the count value C may be generated based on the effective time of the present appointment, an agreed reference time, and an agreed time step. Here, the validation time T is also exemplified by 7/29/15 in 2019, the agreed reference time T0 is exemplified by 1/0 in 2019, the agreed time step X is, for example, 15 minutes, and the count value C can be calculated from (T-T0)/X, and C is calculated as 20124. Then, a salt value can be synthesized by using the count value C and an agreed random array, and a password field is obtained by performing hash operation on the agreed key factor and the salt value; alternatively, the cryptographic field may also be calculated using the hot algorithm, using the count value C and the key factor as parameter K. In this embodiment, since the validation time T is selected as a whole, and the difference between the validation time T and the reference time T0 can be eliminated by a time step of 15 minutes, the above formula can be used to calculate the count value C, and if the difference between the validation time T of the reservation authorization and the reference time T0 cannot be eliminated by a time step of 15 minutes, the calculation formula C is RoundDown ((T-T0)/X), and other calculation formulas for the count value C are given below.
In an embodiment of the present invention, when the smart lock has a networking function, the smart lock may also periodically submit a random number with a predetermined number of bits (for example, 64 bits) as a dynamic factor a to the APP server, so that when the APP generates the reservation authorization code, the APP server may first obtain the latest dynamic factor a, and generate the reservation authorization code based on the obtained dynamic factor a and other parameters. For example, a count value C may be generated based on the dynamic factor a, the validation time T, the reference time T0, and the agreed time step X, such as C ═ a ^ (RoundDown ((T-T0)/X)), C ═ a ^ ((T-T0)/X). Or replacing a predetermined part in the dynamic factor with a count value C calculated according to the validation time T, the reference time T0 and the agreed time step X, and then performing hash operation on the replacement result as a salt value and the key factor to obtain a password field, and the like. When the intelligent lock verifies the reservation authorization code, the latest dynamic factor A cached locally is taken out to calculate in the same way. In this embodiment, due to the existence of the dynamic factor a, even if the attacker intercepts the reservation authorization code, the attacker cannot perform a brute force attack to reversely deduce the agreed key factor based on the known time and the reservation authorization code.
In an embodiment of the present invention, the reservation authorization code may further include an auxiliary field formed by an auxiliary value, in addition to the password field and the time field. The auxiliary field may be, for example, 1 bit and the auxiliary value may be, for example, a number R of cycles that is incremented by a cycle between 0 and 9, or a random number randomly chosen between 0 and 9. The auxiliary field may be 2 bits or more, and for convenience of description in the embodiment of the present invention, the auxiliary field is 1 bit. For example, when the auxiliary field is 1 bit and the auxiliary value is 0 to 9, the number R of the increasing cycles can ensure that 10 different passwords can be generated continuously under the same time parameter configuration, and thus, the problem that the password mechanism is suspected by a visitor because the reservation authorization code is generated the same each time under the same time parameter configuration can be avoided.
In one embodiment of the present invention, the auxiliary value of the auxiliary field is not only used to remove the guest's doubt of the cryptographic mechanism, but also used to perform a predetermined process on the value of the time field before the reservation authorization code is sent to the authorized party, so that the value of the time field changes with the change of the auxiliary value. For example, when the assist value is the number of cycles R, the time field D may be processed as follows using the number of cycles R to obtain a processed time field D': d' ═ R + D > 10R + D-10: r + D, and then combining the auxiliary field consisting of the number of cycles R with the password field S and the processed time field D' to generate the reservation authorization code. In the embodiment of the present invention, the smart lock may agree in advance with the APP whether to use the auxiliary field to process the time field D and what kind of processing is performed, so that when the smart lock performs verification, the auxiliary field in the reservation authorization code is used to perform reverse processing on the time field D' in the reservation authorization code to obtain a true value of the time field D, and then the foregoing verification process is performed on the password field S.
In some embodiments of the present invention, the auxiliary value of the auxiliary field may also participate in the generation process of the password field.
Specifically, in one embodiment, the password field may be generated based on the reserved period parameter, the agreed key factor, and the auxiliary value of the auxiliary field. For example, in the foregoing embodiment, after the APP determines the validation time T according to the reservation period parameter input by the homeowner, the APP may determine the validation time code corresponding to the validation time T according to a predetermined coding rule, insert the number of cycles R serving as an auxiliary value into a predetermined position in the validation time code, and perform hash operation on the obtained processed validation time code and the agreed random number to synthesize a salt value and an agreed key factor to obtain the password field S.
In another embodiment, the aforementioned count value C may be generated based on the secondary value, the validation time, the agreed reference time, and the agreed time step. For example, the count value C may be calculated according to the validation time T, the reference time T0, and the agreed time step X, the cycle number R as the auxiliary value is inserted into a predetermined position in the count value C, the obtained processed count value C 'is combined with the agreed random number to obtain a salt value, and the agreed key factor is subjected to a hash operation to obtain a password field, or the processed count value C' and the agreed key factor are used as the parameter K to perform an HOTP operation to obtain a password field, and so on. The method of processing the count value C using the number of cycles in the embodiment of the present invention is not limited to this, and other examples will be given below.
In some embodiments of the present invention, the reservation authorization code may also include an extension field indicating reusability and/or number of weeks.
For example, in an embodiment of the present invention, the reservation authorization code may include a 1-bit extension field E indicating reusability, and when the value of the extension field E is 0, it indicates that the password field S is a reusable password, and when the value is 1, it indicates that the password field S is a one-time password and is not reusable. The values 0 and 1 of the extension field E may have different meanings from those in the present embodiment, and for example, 1 may be used to indicate the password field S as a reusable password, and 0 may be used to indicate the password field S as a one-time password. In addition, the expansion field E indicating reusability may also directly define the reusability number of the password field S by a value from 1 to 9, for example, the password field S may be used three times when the value is 3, and the smart lock may record the decreased availability number for the reservation authorization code after the reservation authorization code is verified to pass the unlocking each time, and perform verification with reference to the recorded availability number when the reservation authorization code is verified next time.
For example, in another embodiment of the present invention, the reservation authorization code may include a 1-digit extended field E indicating the number of weeks, which may range from 1 to 7, and respectively indicates that the date of the effective time is the day of the week.
As another example, in yet another embodiment of the present invention, the same extension field E may be used to indicate both reusability and number of weeks. In the present embodiment, the extension field E may correspond to the week number and the reusability with numbers 0 to 9, each of which may correspond to one of 10 four-bit codes 0000 to 1001 according to a predetermined coding rule, where the week number is represented by the first three bits and the reusability is represented by the fourth bit, where the meaning of the first three bits may be defined as follows: 000-monday/thursday, 001-tuesday/friday, 010-tuesday, 011-saturday, 100-sunday; the fourth bit code can be defined as described above, for example, using 1 for a one-time password and 0 for a reusable password that can be used multiple times. For example, when the extension field E ═ 2 ═ 0010, its first three-bit code 001 indicates tuesday or friday, and its fourth bit 0 indicates a reusable password; when the extension field E is 1001, the first three-bit code 100 indicates a day of the week, and the fourth bit code 1 indicates a one-time password.
In some embodiments of the present invention, the auxiliary value of the auxiliary field in the foregoing embodiments may also be used to perform a predetermined process on the value of the extension field E, so that the value of the extension field also changes with the change of the auxiliary value. For example, when the assist value is the number of cycles R, the extended field E may be processed using the number of cycles R as follows to obtain a processed time field E': e' ═ R + E > 10R + E-10: r + E, and then combining the auxiliary field consisting of the number of cycles R with the password field S and the processed extension field E' to generate the reservation authorization code. In the embodiment of the present invention, the smart lock may agree in advance with the APP whether the extended field E is processed by using the auxiliary field and what kind of processing is performed, so that the smart lock performs the foregoing verification process on the password field S after performing reverse processing on the extended field E by using the auxiliary field in the reservation authorization code to obtain a true value of the extended field during verification.
In the embodiment of the present invention, the reserved authorization code, regardless of whether the reserved authorization code includes the time field D, the auxiliary field, or the extension field E, may be arranged alternately with the password field S, that is, the password field S may be divided into a plurality of subfields, and the time field D, the auxiliary field, and/or the extension field E are inserted between different subfields, so as to further confuse the arrangement rule of the reserved authorization code and protect the security of the reserved authorization code.
An embodiment of the present invention further provides a reservation authorization apparatus, which includes a processor configured to execute a predetermined computer executable instruction to execute the reservation authorization method in any of the above embodiments. The reservation authorization apparatus may be, for example, a smart mobile device, a tablet computer, a smart watch, etc. of a homeowner, and the APP for authorization in the foregoing embodiment may be the predetermined computer executable instruction.
The core idea of the reservation authorization method is that the intelligent lock and the APP are configured based on the same time parameters, the same key factors are adopted for calculation, and the same result is obtained. Therefore, even in the above embodiments, the effective time coding method or the counting value C calculation method and the password field calculation method need not be implemented exactly as described herein, and such algorithms are feasible as long as the smart lock and the APP adopt a consistent security algorithm, the value of the effective time coding or the counting value C is guaranteed to be unchanged within the time step, and R, D, E, a and other parameters affect the calculation result of the password field.
Similarly, the number of bits of the reserved authorization code can be adjusted according to the requirement in the aspect of safety. It is also possible that the reservation authorization code is increased to more than 11 bits as long as there is no problem in the use of the user. However, from the security point of view, it is not recommended that the number of digits of the HOTP portion is less than 5, so the 8-bit reservation authorization code should be the lowest number that satisfies the security requirement.
A specific embodiment of the present invention is given below to better explain the concept of the subscription authorization method of the present invention. It should be noted that the following embodiments include a plurality of features, but according to the concept of the present invention, these features are not necessarily included in the same embodiment, but may be separately implemented as in the foregoing embodiments.
Firstly, a homeowner inputs parameters required for generating a reservation authorization code in an authorization APP, wherein the parameters comprise effective time T and effective duration of reservation authorization, and whether a password is reusable or not is selected. After receiving the parameters, the APP determines the week number of an effective day according to the effective time T, and constructs an extension field E together with the reusability parameters; constructing a time field D according to the effective duration parameter; while the APP constructs the auxiliary field with a new cycle number R that automatically increments on the basis of the last used cycle number R.
Then, the APP performs standard HOTP calculation, and the input parameters of the HOTP function are as follows:
DIGIT=5
k ═ smart lock UID (8 bytes) + smart lock management password MD5 result (16 bytes)
X15 min
T0Reference time 2019-01-0100: 00, to the minute
T is the time of validity of the reserved authorization code yyyy-MM-nn hh: mm, to minute accuracy
The calculation process is as follows:
C=((E<<28)|(D<<24)|RoundDown((T-T0)/X))^(R|(R<<8)|(R<<16)|(R<<24))
S[5]=HOTP(K,C)
in the HOTP algorithm, the count value C is a 64-bit integer. In this embodiment, only the lower 48 bits of C are used, and the upper 16 bits of C yield to store the time field D and the extension field E, so that both E and D are included in the HOTP calculation. Here, the service life of the reservation authorization system of the present invention may be designed to be 2478-06-2515: 45 to ensure RoundDown ((T-T)0) X) does not exceed 0X00 FFFFFF.
In order to ensure that the suspicious phenomenon that reservation authorization codes generated twice continuously are the same under the same parameter configuration (effective time T, effective duration, week number and whether the reservation authorization codes can be reused or not) does not occur, the embodiment introduces the cycle number R to perform exclusive or intervention on each byte of the count value C. Since the number of the loop flags is increased from 0 to 9, the repeated reservation authorization codes are generated at least 10 times continuously.
After the HOTP operation is performed in the above manner, a 5-digit password string S [5] can be obtained, and xxxxx is used for convenience of explanation. It is also desirable to append the value of each field R, D, E to the final reservation authorization code so that the associated configuration information can be learned during smart lock verification. In order to make the fields D and E not fixed, it is possible to make the fields D and E variable as well as with the number of cycles R. Therefore, after the standard HOTP calculation is completed, the original fields D and E which are going to participate in the combination of the final reservation authorization code are subjected to secondary intervention by using the cycle number R, and the processing method is as follows:
D′=R+D>10R+D-10:R+D
E′=R+E>10R+E-10:R+E
then, the final S5, R, D 'and E' are spliced and combined as follows to obtain 8-bit reservation authorization code P8 in the shape of xRxx D 'xxE':
P[8]=S[0]+R+S[1]+S[2]+D+S[3]+S[4]+E
several examples of reservation authorization code formats are described in detail below.
Example 1: 8588 8287Indicating that this is a reusable temporary seal that is effective within 6 hoursCode, and the validity time of the password is tuesday or friday because:
R=5
D′=8
E′=7
d ═ D '-R > 0D' -R: 10+ D' -R-8-5-3, so the effective time is 6 hours
E=E′-R>0E′-R:10+E′-R=7-5=2=0010
The first three bits E [3..1] of the extension field E are encoded as 001, so the effective day is Tuesday or Friday
The fourth bit E [0] of the extension field E is encoded as 0, so the password field S is a reusable password.
Example 2: 2310 3212Indicating that this is a one-time password valid for 30 minutes, and that the valid time of the password is on a weekday. Because:
R=3
D′=3
E′=2
d ═ D '-R > 0D' -R: 10+ D' -R-3-0, so the effective time period is 30 minutes
E=E′-R>0E′-R:10+E′-R=10+2-3=9=0b1001
The first three bits E [3..1] of the extension field E are encoded to 100, so the effective day is the Sunday
The fourth bit E [0] of the extension field E is encoded as 1, so the cipher field S is a one-time cipher.
Fig. 2 is an exemplary flowchart of a reservation authorization verification method according to an embodiment of the present invention, where the verification method of the present embodiment is applied to an intelligent lock.
As shown in fig. 2, the method for verifying subscription authorization of the present embodiment includes:
s201, when receiving an input reservation authorization code to be verified, extracting a time field and a password field from the reservation authorization code to be verified;
s202, verifying the password field based on the time field.
In this embodiment, a generation manner of the reservation authorization code may refer to the description of the embodiment shown in fig. 1. After the visitor acquires the reservation authorization code, the visitor arrives at the door within the reserved time period, the reservation authorization code is input into a panel of an intelligent lock on the door, the intelligent lock verifies the reservation authorization code, if the reservation authorization code passes the verification, the visitor is unlocked, the unlocking record can be uploaded, and the unlocking record is marked as 'temporary password unlocking'.
Specifically, after receiving the input reservation authorization code, the smart lock first determines whether the password is a fixed password or a temporary password. After the intelligent lock judges that the intelligent lock is a temporary password, the reservation authorization code is verified according to the generation rule of the temporary password, for example, when the reservation authorization code is generated according to the manner illustrated in the embodiment shown in fig. 1, in this embodiment, a password field and a time field are extracted from the reservation authorization code according to an agreed combination rule, a valid time code is extracted from the time field, a salt is synthesized by using the valid time code and an agreed random array, after performing hash operation based on an agreed key factor and the salt, the operation result is compared with the password field, if the comparison result is consistent, the corresponding valid period is determined according to the valid time corresponding to the valid time code and the valid duration corresponding to the duration code in the time field, and whether the current time is within the valid period of reservation authorization is determined according to the current system time of the intelligent lock, and if the current time is determined to be within the effective time period, unlocking the visitor by the intelligent lock.
In the embodiment of the present invention, the agreed key factor may include a management password of the smart lock and/or a unique device identifier UID of the smart lock by an authorized party, for example, a homeowner, and when the agreed key factor includes the management password, the smart lock extracts the management password and/or the unique device identifier UID of the smart lock as the key factor to generate the verification code during verification.
By the reservation authorization method, the reservation authorization code with the effective time period limit is generated and issued to the visitor as the temporary password, so that the unlocking requirement of the visitor when the visitor is inconvenient to remotely unlock in real time can be met, the safety can be ensured, and the operation process is simple, convenient and easy to implement.
In an embodiment of the present invention, a password field in the reserved authorization code may be generated according to an agreed key factor and a count value C, when the smart lock performs verification, a maximum calculation time N is determined according to a time field in the reserved authorization code and an agreed time step, for example, when an effective duration corresponding to the time field is divided by the agreed time step to obtain N, then, a current system time of the smart lock is taken as a first time point, the time step is taken every time from the first time point back to the next time point, a count value is sequentially generated at each time point based on the time point, the agreed reference time and the agreed time step, and a verification value is generated according to the count value and the agreed key factor until a certain generated verification value is consistent with the password field, indicating that the current time is within the reserved period, the verification is confirmed and the lock is unlocked, or until the verification value generated when the verification value is generated for the (N + 1) th time is not consistent with the password field, confirming that the verification fails and refusing to unlock the lock for the visitor.
In some embodiments of the present invention, in order to take the system time error of the smart lock into account, when determining the first time point, the compensated first time point may be obtained by adding or subtracting a predetermined time to or from the current system time of the smart lock, for example, by adding or subtracting 5 minutes or 3 minutes to or from the current system time of the smart lock. The compensation process may be performed as soon as the smart lock receives the reservation authorization code, or in the foregoing embodiment, after the subsequent verification fails with the current system time of the smart lock as the first time point, the subsequent verification is performed again with the compensated first time point. Moreover, if the subsequent verification fails by taking the current system time of the intelligent lock plus the preset time as the compensated first time point, the subsequent verification can be performed again by taking the current system time of the intelligent lock minus the preset time as the compensated first time point, so that the system time error of the intelligent lock is fully considered, and a reasonable time margin is provided for the use of the reservation authorization code.
In some embodiments of the present invention, the foregoing count value is used when generating the reservation authorization code, and when the smart lock performs verification, the count value is generated based on the agreed dynamic factor, the time point, the agreed reference time, and the agreed time step when calculating the count value at each time point, and then the reservation authorization code to be verified is verified by generating the verification value according to the count value and the agreed key factor. Specifically, the smart lock may periodically submit a random number with a predetermined number of bits as the dynamic factor a to the server, so that when the APP generates the reservation authorization code, the generation of the reservation authorization code is performed based on the dynamic factor a and other parameters acquired from the server. When the reservation authorization code is verified, the intelligent lock takes out the latest dynamic factor A cached locally and calculates in the same way. In this embodiment, due to the existence of the dynamic factor a, even if the attacker intercepts the reservation authorization code, the attacker cannot perform a brute force attack to reversely deduce the agreed key factor based on the known time and the reservation authorization code.
In some embodiments of the present invention, the reservation authorization code to be verified further includes an auxiliary field formed by an auxiliary value, which may specifically refer to the reservation authorization method in the foregoing embodiment. When the auxiliary field is only used for obfuscating the reservation authorization code and is not used for performing intervention processing on other fields, the intelligent lock only needs to extract the time field, the password field and other required fields from the reservation authorization code to be verified during verification, and the value of the auxiliary field does not need to be considered or processed.
In some embodiments of the present invention, the time field in the reservation authorization code to be verified is a processed time field obtained by processing the original time field with the value of the auxiliary field, when the intelligent lock verifies the password field based on the time field, the intelligent lock further needs to extract the auxiliary value of the auxiliary field from the reservation authorization code to be verified, perform predetermined reverse processing on the time field extracted from the reservation authorization code to be verified with the auxiliary value to obtain a first conversion value, that is, the value of the original time field, and then determine the corresponding required time parameter according to the first conversion value, and perform subsequent verification on the value of the password field.
In some embodiments of the present invention, as described in the foregoing embodiments, when the auxiliary value of the auxiliary field participates in the generation of the password field, the smart lock further needs to extract the auxiliary value of the auxiliary field from the reserved authorization code to be verified when verifying the password field based on the time field, verify the value of the password field according to the time parameter corresponding to the current time, the time field, the agreed key factor and the auxiliary value, for example, corresponding to the above-mentioned embodiments, the smart lock determines the time code corresponding to the current time, inserts the auxiliary value into the predetermined position in the time code, performs hash operation on the obtained processed code and the agreed random array synthesis salt value and the agreed key factor to obtain a verification value, and compares the verification value with the password field extracted from the reserved authorization code to be verified, and determining whether the current password is in the valid event of the password according to the valid duration corresponding to the time field, and finally determining whether the password is unlocked by the visitor.
In some embodiments of the present invention, the password field of the reservation authorization code to be verified is generated based on the agreed key factor and the count value, and the count value is generated based on the secondary value, the validation time, the agreed reference time, and the agreed time step. When the smart lock verifies the password field based on the time field, the smart lock also generates a count value for each time point from the first time point by using the same parameters, calculates a verification value according to the count value and the agreed key factor, and compares the verification value with the password field extracted from the reserved authorization code to be verified.
In some embodiments of the present invention, the count value used when generating the password field in the reserved authorization code to be verified is obtained by performing predetermined processing on the original count value by using the auxiliary value, and then the smart lock performs the same data processing when performing verification, including generating the original count value based on each time point, an agreed reference time and a time step, then performing the same predetermined processing on the original count value by using the auxiliary value, and then generating the verification value by using the processed count value and an agreed key factor to compare and verify the password field extracted from the reserved authorization code to be verified.
In some embodiments of the present invention, the reservation authorization code to be verified further includes an extension field indicating reusability and/or a day number, and when the smart lock verifies the reservation authorization code to be verified, besides verifying the preliminary validity of the password field, the reusability of the password field may be determined according to the extension field, so as to determine the final validity of the password field; and/or the smart lock may also determine the number of weeks of the effective day from the expanded field, and when calculating the count value at each time point, skip those time points other than the determined number of weeks, and calculate the aforementioned count value only at those time points corresponding to the determined number of weeks, thereby enabling a significant reduction in the amount of calculation.
In some embodiments of the present invention, the extended field in the reservation authorization code to be verified may also be a processed extended field obtained by processing the original extended field with the value of the auxiliary field, and when the smart lock verifies the password field, the auxiliary value of the auxiliary field is further extracted from the reservation authorization code to be verified, and the value of the original extended field is obtained by performing predetermined reverse processing on the extended field extracted from the reservation authorization code to be verified with the auxiliary value, and then, the reusability verification or the week number determination is performed according to the value.
In some embodiments of the present invention, when the time field D, the auxiliary field, and/or the extension field E are inserted between different sub-fields constituting the cipher field, the time field, the auxiliary field, and the extension field need to be extracted from corresponding bits according to a predetermined arrangement rule.
The embodiment of the invention also provides an intelligent lock with a reservation authorization verification function, which comprises a processor, wherein the processor is configured to execute a predetermined computer executable instruction so as to execute the reservation authorization verification method in any embodiment.
A specific embodiment of the present invention is given below to better explain the concept of the subscription authorization verification method of the present invention. It should be noted that the following embodiments include a plurality of features, but according to the concept of the present invention, these features are not necessarily included in the same embodiment, but may be separately implemented as in the foregoing embodiments.
In the present embodiment, the allowable error of the system time of the smart lock is considered to be within plus or minus 5 minutes. After the smart lock receives the reserved authorization code to be verified, which is shaped like xRxx D 'xxE', the current system time of the smart lock is firstly obtained, and 5 minutes is added on the basis of the current system time to be used as a compensated first time point T1The aim is to compensate for the situation that the slow system time of the smart lock results in the password being valid but not valid.
Then, the smart lock calculates D and E according to R, D 'and E' extracted from the reservation authorization code to be verified, and determines whether the temporary password is a one-time password:
D=D′-R>0D′-R:10+D′-R
E=E′-R>0E′-R:10+E′-R
and then determining the maximum backtracking calculation times according to the effective duration D:
Nmaxtime (in minutes)/X represented by ═ D
And finally, the intelligent lock performs time backtracking calculation by taking 15 minutes as a unit, and performs cyclic execution on N at mostmaxIn the round of HOTP verification process, the calculation parameters of each round of HOTP are as follows:
DIGIT=5
k ═ smart lock UID (8 bytes) + smart lock management password MD5 result (16 bytes)
X15 min
T0 ═ reference time 2019-01-0100: 00, to the minute
T=T1-X × N, exactly to minute (N ═ 0max])
The calculation process is as follows:
C=((E<<28)|(D<<24)|RoundDown((T-T0)/X))^(R|(R<<8)|(R<<16)|(R<<24))
S[5]=HOTP(K,C)
if the result of the Nth HOTP matches the received password field xxxxx in the reserved authorization code to be verified, and N is not more than NmaxIf the password field is valid and the current time is within the reserved authorization time period, the verification is passed, otherwise, the verification fails.
It should be noted that, because the extended field E contains the description information that the effective date is the day of the week, and the smart lock also knows that the current system time is the day of the week during the calculation, in the backtracking calculation process, if it is determined that T does not conform to the description that the effective time is the day of the week, the calculation of the round can be skipped quickly. For example, the effective time is 2019-05-2510: 30, the valid period is 3 days, and since the valid date is saturday, E is 0110 and 6, and D is 7. If the smart lock time is 2019-05-279 when the smart lock is verified: 25, when the day is Monday, the intermediate time period can be directly skipped during backtracking calculation, and only Saturday can be calculated. For another example, the effective time is 2019-05-2110: the valid period of the one-time password of 30 is 5 days, and since the valid date is Monday, E is 0001-1, and D is 9. If the time of the intelligent lock is 2019-05-2500 during verification: 30, when the day is friday, the effective day is monday or thursday according to E [3..1] ═ 0, and it is only necessary to calculate the time points of two days, monday and thursday, and it is not necessary to calculate the time points of friday, wednesday and thursday. Theoretically, when the validity period is long, only 2 days of data (the effective time is Monday/Thursday or Tuesday/Friday), at most, need to be calculated, which can greatly improve the calculation efficiency.
Some examples of verifying the reservation authorization code to be verified are given below.
Example 1: assume that the validation time set when the password field is generated is 2019-05-2510: and 30, the expiration date is 6 hours, the repeated use is allowed, and as the date is saturday, the E is 0110 and 6, and the D is 3.
When the intelligent lock receives the reserved authorization code to be verified input by the user, the system time is 2019-05-2514: 23, then adding 5 minutes to obtain T1=2019-05-25 14:28。
Analysis D3, i.e. a 6 hour traceable period, then
Nmax=6*60/15=24
Then the intelligent lock performs HOTP verification calculation according to E-6 and D-3, and the intelligent lock obtains the result when N is 16
T=T1-X*N=2019-05-25 14:28-15*16=2019-05-25 10:28
When N is 16, the variables participating in the HOTP operation at the generation end and the verification end are completely matched, and thus the HOTP results are also completely matched. This means that if the reserved authorization code to be verified is still within the validity period, the verification is passed, and the lock can be unlocked.
Example 2: assume that the validation time set when the password is generated is 2019-05-2510: and 30, the validity period is 30 minutes, the date is saturday, and E is 0111 and 7, and D is 0.
When the intelligent lock receives the reserved authorization code to be verified input by the user, the system time is 2019-05-2511: 02, then adding 5 minutes to obtain T1=2019-05-25 11:07。
Then D is analyzed to be 0, i.e. a 30 minute traceable period, then
Nmax=30/15=2
Then the intelligent lock performs HOTP verification calculation according to the following three time points that E is 7 and D is 0:
when N is 0, T is 2019-05-2511: 07-15 × 0 ═ 2019-05-2511: 07
When N is 1, T is 2019-05-2511: 07-15 × 1 ═ 2019-05-2510: 52
When N is 2, T is 2019-05-2511: 07-15 × 2 ═ 2019-05-2510: 37
Since until N > NmaxIn the process, the variables of the generating end and the verifying end participating in the HOTP operation are not consistent, and the HOTP results are also not necessarily consistent. But finally giving an opportunity again because the situation that the intelligent locking time is possibly faster than the standard time needs to be considered, 5 minutes also needs to be compensated, namely 10 minutes is reduced on the basis of 5 minutes, and then N is equal to NmaxMake a supplementary correction calculation for the case (2):
T=Tmmax-10=2019-05-25 10:37-10=2019-05-25 10:27
because N is equal to NmaxAnd in the process, after the intelligent lock time compensation, the variables of the generating end and the verifying end participating in the HOTP operation are completely consistent, and the HOTP result is also necessarily completely consistent. This means that if the reserved authorization code to be verified is still within the validity period, the verification is passed, and the lock can be unlocked.
This example illustrates that in the case of a smart lock that is allowed a plus or minus 5 minute time error, the unlocking age will have a plus or minus maximum 10 minute error, which should be within an acceptable range.
Example 3: this example is slightly modified based on example 2 to facilitate comparison. Assume that the validation time set when the password field is generated is 2019-05-2510: 30, the validity period is still 30 minutes, and is a one-time password, and since the date is saturday, E is 0111 is 7, and D is 0.
When the intelligent lock receives the reservation authorization code to be verified input by the user, the system time is 2019-05-2511: 11, and then the time is increased by 5 minutes to obtain T1=2019-05-25 11∶16。
Then D is analyzed to be 0, i.e. a 30 minute traceable period, then
Nmax=30/15=2
Then the intelligent lock performs HOTP authentication calculation according to the following three time points according to the conditions that E is 7 and D is 0,
when N is 0, T is 2019-05-2511: 07-15 × 0 ═ 2019-05-2511: 16
When N is 1, T is 2019-05-2511: 07-15 × 1 ═ 2019-05-2511: 01
When N is 2, T is 2019-05-2511: 07-15 × 2 ═ 2019-05-2510: 46
Since until N equals NmaxIn the process, the variables of the generating end and the verifying end participating in the HOTP operation are not consistent, and the HOTP results are also not necessarily consistent. But finally giving an opportunity again, namely considering the situation that the intelligent locking time is possibly faster than the standard time, 5 minutes needs to be compensated, namely 10 minutes is reduced on the basis of 5 minutes, and N is equal to NmaxThe case of (2) is calculated once:
T=Tmmax-10=2019-05-25 10:36
because N is equal to NmaxIn the process, after the intelligent lock time is compensated, the variables of the generating end and the verifying end participating in the HOTP operation are still not completely consistent, and the HOTP result is also not necessarily consistent. This indicates that the reserved authorization code to be verified may have exceeded the validity period, or that there are other errors (e.g., incorrect key factor input when generating the reserved authorization code to be verified results in calculated parameters on both sidesThe number K is not consistent), the verification fails.
The above-described embodiments are merely preferred embodiments of the present invention, and general changes and substitutions by those skilled in the art within the technical scope of the present invention are included in the protection scope of the present invention.