Time-based symmetric encryption algorithm and system and storage medium thereof
By introducing timestamps and fault tolerance into the AES-GCM algorithm, the counter reuse risk of AES-GCM algorithm and the timestamp inconsistency of TOTP algorithm are solved, and higher password encryption security and system reliability are achieved.
Patent Information
- Application Number
- CN202411269210.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-09-11
AI Technical Summary
The AES-GCM encryption algorithm has the risk of counter reuse leading to plaintext leaks, while the TOTP algorithm fails to authenticate and denies service due to inconsistent timestamps.
Based on the AES-GCM algorithm, the TOTP algorithm is introduced, using a time stamp instead of the counter, and the time direction vector A and the fault tolerance of unit time Δβ are defined, which enhances password encryption security and solves the authentication failure caused by inconsistent timestamps. .
It effectively avoids the risk of password leakage caused by counter reuse, and solves the authentication failure problem caused by inconsistent timestamps in the TOTP algorithm, improving the security of passwords and system reliability.
Smart Images

Figure CN119254412A_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 network security incidents has led to people's long-term concern about information security, and a series of algorithms to protect information security have also emerged. From some simple encryption algorithms at the beginning, such as MD5 algorithm and HASH algorithm, to encryption algorithms that are widely used and considered to have a relatively high security level, such as AES encryption algorithm and TOTP algorithm, these algorithms are used in various smart devices and smart terminals such as mobile apps, web sites, and machine equipment. So far, password authentication is still the main and most important line of defense for identity authentication.
[0003] AES-GCM encryption algorithm, such as Figure 1 As shown in FIG, 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 the 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 in the figure, the algorithm uses the timestamp as the element of password encryption and adopts the idea of changing the password once, which increases the security of the password. However, the algorithm needs to be based on a premise: the time of the two authentication parties must be consistent, or there is only a very small error (generally within 30 seconds), otherwise it will cause the authentication to fail and be locked, which will lead to the problem of denial of service on the authentication side. In the actual usage scenario, the most we can do is to require the time of the two authentication parties to be strongly consistent in the initial stage, but because the clock synchronization strategies of both parties are different due to different devices, it is inevitable that the time inconsistency will lead to the problem of denial of service. The clock synchronization strategy is determined by the device, and we have 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, the present 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, defines the concepts of a time direction vector A and a unit time tolerance rate Δβ, and solves 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 side and the authenticating side introduce the one-time-to-transformation TOTP algorithm, use the timestamp instead of the counter, and encrypt the plaintext P after defining the time direction vector A and the unit time fault tolerance rate Δβ. The key is K and the encryption function is CIPH.
[0010] The time direction vector A is recorded and verified by the authentication side. The time direction vector A defaults to the A= state. When the time on the authentication side is faster than the time on the authenticated side, the time direction vector A is in the A+ state; when the time on the authentication side is slower than the time on the authenticated side, the time direction vector A is in the A- state. When the time deviation occurs for the first time, the authentication side records the vector A and verifies the direction of the time direction vector A each time when verifying the password.
[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 side sends the encrypted ciphertext MH and MAC to the authenticating side 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 fault tolerance rate Δβ to the authenticated side, and the authenticated side receives and records the unit time fault tolerance rate Δβ.
[0016] Preferably, the S2 specifically comprises 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, and the timestamp after the authentication side correction is 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, execute steps 2.6-2.8 in a loop;
[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, which is 128 bits, 256 bits or 512 bits.
[0028] Preferably, in 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 of 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 of 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: The plaintext decrypted in S4 is compared with the plaintext stored on the authentication side. If they are inconsistent, the 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 SBis 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, a timestamp is introduced to avoid the password leakage problem caused by the reuse of the counter, thereby enhancing the security of the password. At the same time, a time direction vector A is proposed and a unit time tolerance rate Δβ is defined, thereby solving the problem of denial of service caused by inconsistent timestamps in the TOTP algorithm, which is deeply hated. 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 is further described below in conjunction with 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 encryption of the user login password is taken as an example to specifically describe the implementation process of the present invention:
[0044] S1: The front end of the satellite station control system defines the input of the initial vector IV and the attachment data FC. When the user logs in, he / she enters the plain text login password P in the front end interface of the satellite station control system;
[0045] S2: The authenticated side and the authenticating side introduce the one-time-to-transformation TOTP algorithm based on the AES-GCM algorithm, use a timestamp instead of a counter, and encrypt the plaintext P after defining the time direction vector A and the unit time fault tolerance rate Δβ. 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. The time direction vector A defaults to the A= state. When the time on the authentication side is faster than the time on the authenticated side, the time direction vector A is in the A+ state; when the time on the authentication side is slower than the time on the authenticated side, the time direction vector A is in the A- state. When the time deviation occurs for the first time, the authentication side records the vector A and verifies the direction of the time direction vector A each time when verifying the password.
[0047] 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;
[0048] The encryption process specifically includes the following steps:
[0049] S2.1: Split the plaintext login password P into several groups p′1, p′2, …p′ n ,len(p′ i )≤256, the length of each packet is equal and 256 bits, and the timestamp T0, T1, T2…T of each packet is recorded n , where T0<T1<T2<…<T n ;
[0050] S2.2: Before encrypting the password, the authenticated side corrects the time of the authenticated side, and the timestamp after the authentication side correction is 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;
[0051] S2.3: Use the corrected authenticated time to generate the real-time plaintext packet P i , P i =p′ i &&T i ;
[0052] S2.4: The key K generates the key function H, H = CIPH K (0 256 );
[0053] S2.5: Set the initial vector IV and T i Perform operations, including concatenation, addition, and XOR operations, to obtain IV_T i , encrypt IV_T with key K i , get IVTi , IVT i =H(IV, T i ), i∈[0,n];
[0054] S2.6: When i>1, execute steps 2.6-2.8 in a loop;
[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 side sends the encrypted ciphertext MH and MAC to the authenticating side 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 of 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 of 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: The plaintext decrypted in S4 is compared with the plaintext stored on the authentication side. If they are inconsistent, the 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 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 fault tolerance rate Δβ to the authenticated side, and the authenticated side receives and records the unit time fault tolerance rate Δβ.
[0068] The present embodiment also provides a computer storage medium, which stores a computer program, and the method described above can be implemented when the processor executes the computer program. The computer readable medium can be considered to be tangible and non-temporary. Non-limiting examples of non-temporary 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), etc. The computer program includes processor executable instructions stored on at least one non-temporary 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, a device driver that interacts with a specific device of a special-purpose computer, one or more operating systems, user applications, background services, background applications, etc.
[0069] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0070] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
Claims
1. A time-based symmetric encryption algorithm, characterized in that: 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 side and the authenticating side introduce the one-time-to-transformation TOTP algorithm, use the timestamp instead of the counter, and encrypt the plaintext P after defining the time direction vector A and the unit time fault tolerance rate Δβ. The key is K and the encryption function is CIPH. The time direction vector A is recorded and verified by the authentication side. The time direction vector A defaults to the A= state. When the time on the authentication side is faster than the time on the authenticated side, the time direction vector A is in the A+ state; when the time on the authentication side is slower than the time on the authenticated side, the time direction vector A is in the A- state. When the time deviation occurs for the first time, the authentication side records the vector A and verifies the direction of the time direction vector A each time when verifying the password. Fault tolerance per unit time T C In case of 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; S3: The authenticated side sends the encrypted ciphertext MH and MAC to the authenticating side 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 fault tolerance rate Δβ to the authenticated side, and the authenticated side receives and records the unit time fault tolerance rate Δβ.
2. A time-based symmetric encryption algorithm according to claim 1, characterized in that: 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, and the timestamp after the authentication side correction is 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 XOR operation is performed to obtain 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. A time-based symmetric encryption algorithm according to claim 2, characterized in that: In the above-mentioned S2.1, the plaintext P is split into several groups, and the length of each group is the same, which is 128 bits, 256 bits or 512 bits.
4. A time-based symmetric encryption algorithm according to claim 2, characterized in that: In S2.5, the initial vector IV and T i The operations performed include concatenation, addition, and XOR operations.
5. A time-based symmetric encryption algorithm according to claim 1, characterized in that: The decryption process of decrypting the plaintext password in S4 is the same as the algorithm decryption process of AES-GCM.
6. A time-based symmetric encryption algorithm according to claim 1, characterized in that: The specific steps of verification in S5 are: S5.1: Current timestamp T of 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 of 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: The plaintext decrypted in S4 is compared with the plaintext stored on the authentication side. If they are inconsistent, the 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 In case of password authentication, the current timestamp of the authentication side; T SB 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 comprises 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 used to execute a time-based symmetric encryption algorithm according to any one of claims 1-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, and when the time-based symmetric encryption algorithm is executed by at least one processor, the time-based symmetric encryption algorithm described in any one of claims 1-6 is implemented.
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
Cross-domain dynamic password identity security authentication system and method
CN116232634A
Timestamp-based encryption and authentication method, timestamp-based encryption and authentication system, and computer device
WO2020155794A1
