Time-based symmetric encryption algorithm, system and storage medium thereof
By introducing the timestamp and time direction vector A into the AES-GCM algorithm and combining it with the unit time fault tolerance rate Δβ, the problems of AES-GCM counter reuse leakage and TOTP timestamp inconsistency are solved, thereby improving the security and stability of the encryption algorithm.
Patent Information
- Application Number
- CN202411269210.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The existing AES-GCM encryption algorithm has the risk of plaintext leakage due to counter reuse, while the TOTP algorithm has the problem of authentication failure and denial of service due to inconsistent timestamps.
The TOTP algorithm is introduced based on the AES-GCM algorithm. The timestamp is used instead of the counter. The time direction vector A and the unit time fault tolerance rate Δβ are defined to enhance password security and solve the authentication failure problem caused by inconsistent timestamps.
It effectively avoids plaintext leakage caused by counter reuse, improves password security, and solves the denial of service problem caused by inconsistent timestamps in the TOTP algorithm, ensuring the stability and security of the authentication process.
Smart Images

Figure CN119254412B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer algorithm technology, and in particular to a time-based symmetric encryption algorithm, system and storage medium thereof. Background Art
[0002] The frequent occurrence of cybersecurity incidents has led to a long-term focus on information security, necessitating the development of a range of algorithms to protect it. Initially, these algorithms evolved from simple encryption algorithms like MD5 and HASH, to now widely used and considered highly secure algorithms like AES and TOTP. These algorithms are used in a variety of smart devices and terminals, including mobile apps, websites, and machines. To date, password authentication remains the primary and most important line of defense for identity verification.
[0003] AES-GCM encryption algorithm, such as Figure 1 As shown in the figure, the GMAC (Galois Message Authentication Code) feature is added to AES-CTR, which solves the problem that CTR cannot verify the integrity of encrypted messages. As a result, it is widely used in various password encryption scenarios. However, although this algorithm solves the problem of integrity verification of encrypted messages, it still uses the GCT (counter) mode to encrypt passwords. If the counter is reused, there is still a risk of plaintext leakage.
[0004] The TOTP algorithm is a popular encryption algorithm in recent years. Figure 2 As shown, this algorithm uses a timestamp as a password encryption element and adopts a one-time-change concept, which increases password security. However, this algorithm requires a prerequisite: the time of both parties to the authentication must be consistent, or there must be only a very small error (generally within 30 seconds). Otherwise, the authentication will fail and the authentication will be locked, which will lead to denial of service on the authentication side. In real-world scenarios, the best we can do is require that the time of both parties to the authentication be strongly consistent in the initial phase. However, since the clock synchronization strategies of both parties vary from device to device, time inconsistencies and denial of service issues are inevitable. The clock synchronization strategy is determined by the device, and there is no way to require all devices in different industries to use the same clock synchronization strategy.
[0005] In order to further improve the security of the system, this application proposes a solution based on solving the defects of the above two encryption algorithms. Summary of the Invention
[0006] Purpose of the invention: The purpose of the present invention is to provide a time-based symmetric encryption algorithm, system and storage medium thereof, which introduces the idea of a dynamic password that changes once on the basis of the AES-GCM encryption algorithm, enhances the security of password encryption, and defines the concepts of the time direction vector A and the unit time tolerance rate Δβ, thereby solving the problem of denial of service caused by inconsistent timestamps in the TOTP algorithm.
[0007] Technical solution: The time-based symmetric encryption algorithm described in the present invention specifically includes the following steps:
[0008] S1: The authenticated party inputs the initial vector IV, plaintext P and attachment data FC;
[0009] S2: Based on the AES-GCM algorithm, the authenticated and authenticating parties introduce the one-time-transfer (TOTP) algorithm, using a timestamp instead of a counter. After defining the time direction vector A and the unit time error tolerance Δβ, they encrypt the plaintext P using the key K and the encryption function CIPH.
[0010] The time direction vector A is recorded and verified by the authenticator. By default, the time direction vector A is in the A= state. When the authenticator's time is faster than the authenticated party's time, the time direction vector A is in the A+ state. When the authenticator's time is slower than the authenticated party's time, the time direction vector A is in the A- state. The authenticator records the vector A when a time deviation occurs for the first time, and verifies the direction of the time direction vector A each time the password is verified.
[0011] Fault tolerance per unit time T C For password authentication, the current timestamp of the authenticated side; T S In case of password authentication, the current timestamp of the authentication side; T SB It is the timestamp of the last password authentication;
[0012] S3: The authenticated party sends the encrypted ciphertext MH and MAC to the authenticating party for verification and authentication;
[0013] S4: After receiving the information, the authentication side decrypts the ciphertext MH and obtains the plaintext P;
[0014] S5: The authentication side obtains the current system time T S , and perform verification;
[0015] S6: After the authentication side verifies that the authentication is successful, it sends the unit time error tolerance rate Δβ to the authenticated side, which receives and records the unit time error tolerance rate Δβ.
[0016] Preferably, the S2 specifically includes the following steps:
[0017] S2.1: Split the plaintext P into several packets p′1, p′2, …p′ n ,len(p i ')≤256, and record the timestamp T0, T1, T2...T of each packet n , where T0<T1<T2<…<T n ;
[0018] S2.2: Before encrypting the password, the authenticated side corrects the time of the authenticated side, taking the authenticated side as the time stamp, and sets the timestamp after the correction of the authenticated side as T i =T i ′+Δβ*(T C -T CB ),T i ' is the current timestamp of the authenticated side, T CB It is the timestamp of the last successful authentication on the authenticated side;
[0019] S2.3: Use the corrected authenticated time to generate the real-time plaintext packet P i , P i =p i ′&&T i ;
[0020] S2.4: The key K generates the key function H, H = CIPH K (0 256 );
[0021] S2.5: Set the initial vector IV and T i Perform calculations to obtain IV_T i , encrypt IV_T with key K i , get IVT i , IVT i =H(IV, T i ), i∈[0,n];
[0022] S2.6: When i>1, repeat steps 2.6-2.8.
[0023] S2.7: IVT i and P i Perform XOR operation to obtain the intermediate ciphertext W i ,
[0024] S2.8: Use the GMAC algorithm to calculate the additional information FC and obtain M i , M i =MH(FC);
[0025] S2.9: For M i and W i Perform XOR operation to get MHi ,
[0026] S2.10: Splicing MH i …MH n , get the ciphertext MH, with FC n and ITV0 as input parameters, and finally calculate MAC,
[0027] Preferably, in the several groups into which the plaintext P in S2.1 is split, the length of each group is the same, namely, 128 bits, 256 bits or 512 bits.
[0028] As a preference, in said S2.5, the initial vector IV and T i The operations performed include concatenation, addition, and XOR operations.
[0029] Preferably, the decryption process of decrypting the plaintext password in S4 is the same as the algorithm decryption process of AES-GCM.
[0030] Preferably, the specific steps of verification in S5 are:
[0031] S5.1: Current timestamp T on the authentication side S and the corrected timestamp T sent by the authenticated side to the authenticating side i The absolute value of the difference is greater than the maximum error range, that is, |T s -T i |>the maximum value of the error range, the authentication fails, otherwise proceed to the next step;
[0032] S5.2: When calculating password authentication, the current timestamp T on the authentication side S and the current timestamp T of the authenticated side C The actual time direction vector A′ is compared with the direction of the time direction vector A recorded in the authentication side. If they are inconsistent, the authentication fails. Otherwise, proceed to the next step.
[0033] S5.3: Compare the plaintext decrypted in S4 with the plaintext stored on the authentication side. If they are inconsistent, authentication fails. Otherwise, proceed to the next step.
[0034] S5.4: The authentication side calculates and verifies the MAC value. If the MAC values are inconsistent, the authentication fails. Otherwise, proceed to the next step.
[0035] S5.5: Authentication-side calculation T C For password authentication, the current timestamp of the authenticated side, T S In case of password authentication, the current timestamp of the authentication side; T SBIt is the timestamp of the last password authentication and updates T SB =T S .
[0036] Beneficial effects: Compared with the prior art, the present invention has the following significant advantages:
[0037] The present invention is based on the AES-GCM algorithm and the TOTP algorithm. While satisfying the password integrity check, it introduces a timestamp to avoid the problem of password leakage caused by the reuse of the counter, thereby enhancing the security of the password. At the same time, it proposes a time direction vector A and defines a unit time tolerance rate Δβ, solving the problem of denial of service caused by inconsistent timestamps, which is deeply hated in the TOTP algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 Schematic diagram of the AES-GCM algorithm.
[0039] Figure 2 Schematic diagram of the TOTP algorithm.
[0040] Figure 3 Schematic diagram of the algorithm of the present invention.
[0041] Figure 4 It is an interactive schematic diagram of the present invention. DETAILED DESCRIPTION
[0042] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0043] See attached Figures 1 to 4 FIG, the present invention is combined with the implementation in the satellite station control system to encrypt sensitive data, including but not limited to user login password, user identity information, satellite information, device information, etc. In the satellite station control system, the front-end interface of the satellite station control system is regarded as the authenticated side, and the back-end of the satellite station control system is regarded as the authenticating side. In this embodiment, the user login password encryption is taken as an example to specifically illustrate the implementation process of the present invention:
[0044] S1: The front-end of the satellite station control system defines the input initial vector IV and the attachment data FC. When the user logs in, he / she enters the plain text login password P on the front-end interface of the satellite station control system.
[0045] S2: Based on the AES-GCM algorithm, the authenticated and authenticating parties introduce the one-time-to-transfer (TOTP) algorithm, using a timestamp instead of a counter. After defining the time direction vector A and the unit time error tolerance Δβ, they encrypt the plaintext P. The key is K, and the encryption function is CIPH, where:
[0046] The time direction vector A is recorded and verified by the authentication side, and the time direction vector A is by default A=state. When the authentication side time is faster than the authenticated side time, the time direction vector A is A+state. When the authentication side time is slower than the authenticated side time, the time direction vector A is A- state. When the time bias occurs for the first time, the authentication side records the vector A, and the direction of the time direction vector A is verified each time the password is verified.
[0047] Fault tolerance rate per unit time T C T is the current time stamp of the authenticated side when the password is authenticated; S T is the current time stamp of the authentication side when the password is authenticated; SB T is the time stamp of the last password authentication;
[0048] The encryption process specifically includes the following steps:
[0049] S2.1: Split the plaintext login password P into a plurality of groups p'1, p'2, … p'N, len(p'1)≤256, the length of each group is equal and is 256 bits, and record the time stamp T0, T1, T2…TN of each group, wherein T0 n i n n ;
[0050] S2.2: The authenticated side corrects the time of the authenticated side before encrypting the password, and the authenticated side corrects the time stamp T i =T i ′+Δβ*(T C -T CB ), T i ′ is the current time stamp of the authenticated side, and T CB is the time stamp of the last successful authentication of the authenticated side;
[0051] S2.3: Use the corrected time of the authenticated side to generate real-time plaintext groups P i , P i =p′ i &&T i ;
[0052] S2.4: The key K generates a key function H, H=CIPH K (0 256 );
[0053] S2.5: Operate the initial vector IV and T i , including connection, addition and exclusive or operation, to obtain IV_T i , encrypt IV_T i with the key K to obtain IVTi , IVT i =H(IV, T i ), i∈[0,n];
[0054] S2.6: When i>1, repeat steps 2.6-2.8.
[0055] S2.7: IVT i and P i Perform XOR operation to obtain the intermediate ciphertext W i ,
[0056] S2.8: Use the GMAC algorithm to calculate the additional information FC and obtain M i , M i =MH(FC);
[0057] S2.9: For M i and W i Perform XOR operation to get MH i ,
[0058] S2.10: Splicing MH i …MH n , get the ciphertext MH, with FC n and ITV0 as input parameters, and finally calculate MAC,
[0059] S3: The authenticated party sends the encrypted ciphertext MH and MAC to the authenticating party for verification and authentication;
[0060] S4: After receiving the information, the authentication side decrypts the plaintext password. The decryption process is the same as the AES-GCM algorithm decryption process to obtain the plaintext P;
[0061] S5: The authentication side obtains the current system time T S , and perform verification, which specifically includes the following steps:
[0062] S5.1: Current timestamp T on the authentication side S and the corrected timestamp T sent by the authenticated side to the authenticating side i The absolute value of the difference is greater than the maximum error range, that is, |T s -T i |>the maximum value of the error range, the authentication fails, otherwise proceed to the next step;
[0063] S5.2: When calculating password authentication, the current timestamp T on the authentication side S and the current timestamp T of the authenticated side CThe actual time direction vector A′ is compared with the direction of the time direction vector A recorded in the authentication side. If they are inconsistent, the authentication fails. Otherwise, proceed to the next step.
[0064] S5.3: Compare the plaintext decrypted in S4 with the plaintext stored on the authentication side. If they are inconsistent, authentication fails. Otherwise, proceed to the next step.
[0065] S5.4: The authentication side calculates and verifies the MAC value. If the MAC values are inconsistent, the authentication fails. Otherwise, proceed to the next step.
[0066] S5.5: Authentication-side calculation T C For password authentication, the current timestamp of the authenticated side, T S In case of password authentication, the current timestamp of the authentication side; T SB It is the timestamp of the last password authentication and updates T SB =T S .
[0067] S6: After the authentication side verifies that the authentication is successful, it sends the unit time error tolerance rate Δβ to the authenticated side, which receives and records the unit time error tolerance rate Δβ.
[0068] This embodiment also provides a computer storage medium that stores a computer program that can implement the method described above when a processor executes the computer program. The computer-readable medium can be considered to be tangible and non-transitory. Non-limiting examples of non-transitory tangible computer-readable media include non-volatile memory circuits (such as flash memory circuits, erasable programmable read-only memory circuits, or mask read-only memory circuits), volatile memory circuits (such as static random access memory circuits or dynamic random access memory circuits), magnetic storage media (such as analog or digital tapes or hard drives), and optical storage media (such as CDs, DVDs, or Blu-ray discs). The computer program includes processor-executable instructions stored on at least one non-transitory tangible computer-readable medium. The computer program may also include or rely on stored data. The computer program may include a basic input / output system (BIOS) that interacts with the hardware of a special-purpose computer, device drivers that interact with specific devices of the special-purpose computer, one or more operating systems, user applications, background services, background applications, etc.
[0069] Those skilled in the art will appreciate that embodiments of the application can be devised for a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer readable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code thereon.
[0070] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing machine, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams. Figure 1 The means for carrying out the functions specified in the flowchart illustrations and / or block diagrams can be embodied in one or more of the following: Figure 1 a flow or multiple flows and / or blocks
Claims
1. A time-based symmetric encryption algorithm, characterized by: The specific steps include: S1: The authenticated party inputs the initial vector IV, plaintext P and attachment data FC; S2: Based on the AES-GCM algorithm, the authenticated and authenticating parties introduce the one-time-transfer (TOTP) algorithm, using a timestamp instead of a counter. After defining the time direction vector A and the unit time error tolerance Δβ, they encrypt the plaintext P using the key K and the encryption function CIPH. The time direction vector A is recorded and verified by the authenticator. By default, the time direction vector A is in the A= state. When the authenticator's time is faster than the authenticated party's time, the time direction vector A is in the A+ state. When the authenticator's time is slower than the authenticated party's time, the time direction vector A is in the A- state. The authenticator records the vector A when a time deviation occurs for the first time, and verifies the direction of the time direction vector A each time the password is verified. Fault tolerance per unit time T C For password authentication, the current timestamp of the authenticated side; T S For password authentication, the current timestamp on the authentication side; T SB It is the timestamp of the last password authentication; S3: The authenticated party sends the encrypted ciphertext MH and MAC to the authenticating party for verification and authentication; S4: After receiving the information, the authentication side decrypts the ciphertext MH and obtains the plaintext P; S5: The authentication side obtains the current system time T S , and perform verification; S6: After the authentication side verifies that the authentication is successful, it sends the unit time error tolerance rate Δβ to the authenticated side, which receives and records the unit time error tolerance rate Δβ.
2. The time-based symmetric encryption algorithm according to claim 1, wherein: The S2 specifically includes the following steps: S2.1: Split the plaintext P into several packets p1′, p2′, …p′ n ,len(p i ')≤256, and record the timestamp T0, T1, T2...T of each packet n , where T0<T1<T2<…<T n ; S2.2: Before encrypting the password, the authenticated side corrects the time of the authenticated side, taking the authenticated side as the time stamp, and sets the timestamp after the correction of the authenticated side as T i =T i ′+Δβ*(T C -T CB ),T i ' is the current timestamp of the authenticated side, T CB It is the timestamp of the last successful authentication on the authenticated side; S2.3: Use the corrected authenticated time to generate the real-time plaintext packet P i , P i =p i ′&&T i ; S2.4: The key K generates the key function H, H = CIPH K (0 256 ); S2.5: Set the initial vector IV and T i Perform calculations to obtain IV_T i , encrypt IV_T with key K i , get IVT i , IVT i =H(IV, T i ), i∈[0,n]; S2.6: When i>1, execute steps S2.6-S2.8 in a loop; S2.7: IVT i and P i Perform XOR operation to obtain the intermediate ciphertext W i , S2.8: Use the GMAC algorithm to calculate the additional information FC and obtain M i , M i =MH(FC); S2.9: For M i and W i Perform XOR operation to get MH i , S2.10: Splicing MH i …MH n , get the ciphertext MH, with FC n and ITV0 as input parameters, and finally calculate MAC, 3. The time-based symmetric encryption algorithm according to claim 2, wherein: In the several groups into which the plaintext P in S2.1 is split, the length of each group is the same, namely, 128 bits, 256 bits or 512 bits.
4. The time-based symmetric encryption algorithm according to claim 2, wherein: In S2.5, the initial vector IV and T i The operations performed include concatenation, addition, and XOR operations.
5. The time-based symmetric encryption algorithm according to claim 1, wherein: The decryption process of the plaintext password in S4 is the same as the AES-GCM algorithm decryption process.
6. The time-based symmetric encryption algorithm according to claim 1, wherein: The specific steps of verification in S5 are: S5.1: Current timestamp T on the authentication side S and the corrected timestamp T sent by the authenticated side to the authenticating side i The absolute value of the difference is greater than the maximum error range, that is, |T s -T i |>the maximum value of the error range, the authentication fails, otherwise proceed to the next step; S5.2: When calculating password authentication, the current timestamp T on the authentication side S and the current timestamp T of the authenticated side C The actual time direction vector A′ is compared with the direction of the time direction vector A recorded in the authentication side. If they are inconsistent, the authentication fails. Otherwise, proceed to the next step. S5.3: Compare the plaintext decrypted in S4 with the plaintext stored on the authentication side. If they are inconsistent, authentication fails. Otherwise, proceed to the next step. S5.4: The authentication side calculates and verifies the MAC value. If the MAC values are inconsistent, the authentication fails. Otherwise, proceed to the next step. S5.5: Authentication-side calculation T C For password authentication, the current timestamp of the authenticated side, T S For password authentication, the current timestamp on the authentication side; T SB It is the timestamp of the last password authentication and updates T SB =T S .
7. A system for displaying and analyzing vibration signals, characterized in that: The system includes a network interface, a memory, and a processor, wherein: The network interface is used to receive and send signals during the process of sending and receiving information with other external network elements; The memory is used to store computer program instructions that can be executed on the processor; The processor is configured to execute a time-based symmetric encryption algorithm according to any one of claims 1 to 6 when running the computer program instructions.
8. A computer storage medium, characterized in that: The computer storage medium stores a time-based symmetric encryption algorithm, which, when executed by at least one processor, implements the time-based symmetric encryption algorithm described in any one of claims 1 to 6.
Citation Information
Patent Citations
Timestamp based onboarding process for wireless devices
CN112997447A
Timestamp correction method based on system time as cryptographic algorithm initialization vector
CN113242128A