CN114465804B - Instruction encryption and decryption method capable of resisting replay attack - Google Patents

Instruction encryption and decryption method capable of resisting replay attack Download PDF

Info

Publication number
CN114465804B
CN114465804B CN202210142930.5A CN202210142930A CN114465804B CN 114465804 B CN114465804 B CN 114465804B CN 202210142930 A CN202210142930 A CN 202210142930A CN 114465804 B CN114465804 B CN 114465804B
Authority
CN
China
Prior art keywords
encryption
instruction
value
ciphertext
initial value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210142930.5A
Other languages
Chinese (zh)
Other versions
CN114465804A (en
Inventor
杨剑
罗锋
王代强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guizhou Furunde Cultural Industry Development Co ltd
Original Assignee
Guizhou Furunde Cultural Industry Development Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guizhou Furunde Cultural Industry Development Co ltd filed Critical Guizhou Furunde Cultural Industry Development Co ltd
Priority to CN202210142930.5A priority Critical patent/CN114465804B/en
Publication of CN114465804A publication Critical patent/CN114465804A/en
Application granted granted Critical
Publication of CN114465804B publication Critical patent/CN114465804B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/002Countermeasures against attacks on cryptographic mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic
    • H04L63/1458Denial of Service
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/03Protecting confidentiality, e.g. by encryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/12Detection or prevention of fraud
    • H04W12/121Wireless intrusion detection systems [WIDS]; Wireless intrusion prevention systems [WIPS]
    • H04W12/122Counter-measures against attacks; Protection against rogue devices

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses an instruction encryption method capable of resisting replay attack, which comprises the following steps: synchronizing an initial value R with a decryption party i I is the instruction encryption times and the initial value R i Each time of synchronization is different; by an initial value R i Key K and instruction Step i Co-generation of ciphertext I i . The method solves the problem that the prior art is very easy to be used by an attacker to steal message data in a channel by using special equipment to implement replay attack.

Description

Instruction encryption and decryption method capable of resisting replay attack
Technical Field
The invention relates to an instruction encryption and decryption method capable of resisting replay attack, belonging to the technical field of encryption.
Background
With the development of society and economy, more and more instruments and devices issue messages and control commands by using plaintext instructions (hereinafter referred to as "instructions"), and remote medical treatment can be realized by remotely controlling remote devices such as unmanned aerial vehicles, unmanned automobiles and the like. Before sending the instructions, the sender and the receiver have otherwise agreed to the specific meaning represented by each instruction, which may be represented in particular by a number, a short letter, or by some specific character. In general, transmitting instructions can realize the advantages of low communication cost and high efficiency.
The development of communication technology, especially in the context of 5G, has faced a significant security problem when many devices are connected to the internet, while the devices are conveniently controlled remotely by instructions. Whether it is a wired network or a wireless network, it is easy for the instruction to be stolen during the instruction transmission process, or for the attacker to implement replay attack or insertion attack, so that the instruction is unsafe during the instruction transmission process, which is a potential safety hazard for the instruction transmission.
Therefore, in many instruments and devices, there is a risk of applying a cryptographic technique to cope with possible information leakage, and the instruction is encrypted by using a cryptographic algorithm, where the cryptographic algorithm includes two major types, i.e., a symmetric cryptographic algorithm including foreign DES, AES, and domestic SM4 algorithms, and an asymmetric cryptographic algorithm including RSA, ECC, and SM2 cryptographic algorithms issued by national cryptographic administration. Because the used instruction is limited and repeated, the cryptographic algorithm is also fixed, and the result of each encryption for a specific instruction is the same, so that an attacker can easily steal message data in a channel by using special equipment to implement replay attack.
In addition, the common cryptographic algorithm is mainly used for encrypting a large amount of data, the computing amount of the cryptographic algorithm is large, a certain communication overhead is increased, and the efficiency is low in an application scene with high real-time requirements.
Disclosure of Invention
The invention aims to solve the technical problems that: an instruction encryption and decryption method capable of resisting replay attack is provided to overcome the defects of the prior art.
The technical scheme of the invention is as follows:
first aspect:
the invention provides an instruction encryption method capable of resisting replay attack, which comprises the following steps:
synchronizing an initial value R with a decryption party i I is the instruction encryption times and the initial value R i Each time of synchronization is different;
by an initial value R i Key K and instruction Step i Co-generation of ciphertext I i
Preferably, when i=0, the initial value R i The generation method of the method comprises the following steps:
s01_1, generating a first random number Rand 1 Let R 0 =Rand 1 Setting a first cycle number G 1
S01_2, judge G 1 If G is a value of 1 >0 executing step S01_3, otherwise jumping to step S01_6;
S01_3、G 1 =G 1 -1, wherein G to the right of the equal sign 1 G for the last time this step is performed 1 Is a value of (2);
s01_4 if R 0 Cannot be f 1 Integer division, R 0 =R 0 *r 1 +K, wherein R to the right of the equal sign 0 For R at the last time of executing this step 0 Take the value r 1 For the first encryption parameter, K is a key, f 1 Is equal to r 1 Integer of K interstitium;
if R is 0 Can be f 1 Integer division, R 0 =R 0 /f 1 Wherein R to the right of the equal sign 0 For R at the last time of executing this step 0 Taking a value;
s01_5, jump to step s01_2;
s01_6, complete initial value R i And (5) generating.
Preferably, said r 1 =3。
Preferably, the ciphertext I i The generation method of the method comprises the following steps:
s02_0, i=0I i Is R 0 Otherwise set I i The final ciphertext is generated for the last encryption;
s02_1, judgment instruction Step i If Step is taken i >0 then executing step S02_2, otherwise jumping to step S02_9;
S02_2、Step i =Step i -1, step to the right of the equal sign i Step for the last time this Step was performed i Is a value of (2);
s02_3, set the second cycle number G 2
S02_4, judge G 2 If G is a value of 2 >0 then executing step S02_5, otherwise jumping to step S02_9;
S02_5、G 2 =G 2 -1, wherein G to the right of the equal sign 2 G for the last time this step is performed 2 Is a value of (2);
s02_6 if I i Cannot be f 2 Integer division, I i =I i *r 2 +K, wherein I to the right of the equal sign i For I at the time of last execution of this step i Take the value r 2 For the second encryption parameter, K is the key, f 2 Is equal to r 2 Integer of K interstitium;
if I i Can be f 2 Integer division, I i =I i /f 2 Wherein I to the right of the equal sign i For I at the time of last execution of this step i Taking a value;
s02_7, jump to step s02_4;
s02_8, jump to step s02_1;
s02_9, complete ciphertext I i And (5) generating.
Further, the method further comprises: the encryption party will t 1 The secondary retransmission request is automatically converted into a primary resynchronization request.
Specifically, the resynchronization request is: resetting the encryption number i to 0, requesting the encryptor to regenerate R 0 Ciphertext is regenerated and transmitted.
Second aspect:
the invention also provides an instruction decryption method capable of resisting replay attack, which comprises the following steps:
s03_1, receiving ciphertext I sent by the encryption party i
S03_2, loading the same key K as the encryption party, synchronizing the initial value R with the encryption party i I is the instruction encryption times and the initial value R i Each time of synchronization is different;
s03_3. traversing the encryption side instruction, and passing through the key K and the initial value R i Generating encryption instructions for the instructions of the encryption party, and jumping to the step S03_4 when each encryption instruction is generated;
s03_4 for encrypting instruction I 'generated in step s03_3' i And ciphertext I i In contrast, if ciphertext I i And the encryption instruction I 'generated in the step S03_3' i If the bit error rate is smaller than or equal to the set value SER, taking the instruction corresponding to the encrypted instruction which is the same as the ciphertext in the step S03_2 as the decrypted instruction, and jumping to the stepStep s03_6; if ciphertext I i And all the encryption instructions I 'generated in step S03_3' i If the bit error rate is larger than the set value SER, the step S03-3 is skipped until the command traversal of the encryption party is completed;
s03_5, a resending request is sent to an encryption party;
s03_6, complete decryption.
Further, the method for calculating the error rate in step s03_4 is as follows:
ciphertext I i And encryption instruction I' i Is decomposed into separate numbers;
ciphertext I i And encryption instruction I' i A bit number A of the larger median;
ciphertext I i And encryption instruction I' i Respectively carrying out one-to-one comparison on the values of the digits corresponding to the decomposed digits, and solving the digits B with different comparison results;
the bit error rate P, p=b/a is found.
Preferably, the method for generating the encryption instruction in the step s03_3 includes the following steps:
s03_3_0, encryption instruction I 'when i=0' i Initial value R sent for encryption method 0 Otherwise, setting an encryption instruction I' i For the encrypted instruction I 'after the last decryption success' i-1
S03_3_1, determination instruction Step i If Step is taken i >0 then step s03_3_2, else jump to step s03_3_9;
S03_3_2、Step i =Step i -1, step to the right of the equal sign i Step for the last time this Step was performed i Is a value of (a).
S03_3_3, setting a second cycle number G 2
S03_3_4, judgment G 2 If G is a value of 2 >0 then executing step S02_5, otherwise jumping to step S02_8;
S03_3_5、G 2 =G 2 -1, wherein G to the right of the equal sign 2 G for the last time this step is performed 2 Is a value of (2);
s03_3_6, if I' i Cannot be f 2 Integer division, I' i =I′ i *r 2 +K, wherein I 'to the right of the equal sign' i For the encrypted instruction I 'at the last time of executing this step' i Take the value r 2 For the second encryption parameter, K is the key, f 2 Is equal to r 2 Integer of K interstitium;
if I' i Can be f 2 Integer division, I' i =I′ i /f 2 Wherein I 'to the right of the equal sign' i For I 'at the last time this step was performed' i Taking a value;
s03_3_7, jump to step s03_3_4;
s03_3_8, jump to step s03_3_1;
s03_3_9, complete encryption instruction I' i And (5) generating.
Further, in the step s03_5, if the decrypting side sends the retransmission request beyond t 2 The secondary terminates the communication and allows the decryption party to execute the preset instructions.
The beneficial effects of the invention are as follows: according to the invention, the initial value is added when the encryption party encrypts the command, the initial value and the secret key are used together, and the initial value is synchronized with the decryption party, so that the repeated ciphertext cannot appear after the limited command is encrypted by the encryption algorithm under the condition that the encryption algorithm is unchanged, the result of each encryption of the same command is different, and an attacker is difficult to steal the ciphertext in a channel to implement replay attack.
The invention traverses the command of the encrypting party by synchronizing the initial value with the encrypting party during decryption, generates the encrypting command by utilizing the key and the initial value, obtains the error rate corresponding to the encrypting command and the ciphertext received from the encrypting party one by one, and finds the command corresponding to the encrypting command with the error rate smaller than the set value, thereby realizing the decryption of the ciphertext. Under the condition that the cryptographic algorithm is unchanged, the decryption party can decrypt the ciphertext corresponding to the received different instructions each time, so that an attacker cannot easily implement replay attack even if stealing the ciphertext transmitted in the channel.
Compared with the existing ciphertext generation method, the ciphertext generation method has the advantages that most of operations are computer shift operations, and the calculation efficiency is high.
Even if decryption is unsuccessful, the invention can also send a resending request and send a resynchronization request to the encryption party, identify DDOS attack and execute a preset instruction, so that the system is not damaged or suffers further attack, and simultaneously, the consumption is reduced.
Drawings
FIG. 1 is a flow chart of a method according to an embodiment of the invention.
Detailed Description
The technical scheme in the embodiment of the invention has the following overall thought:
the encryption party and the decryption party synchronize initial values, and the characteristic that the initial values are different every time of synchronization is utilized to encrypt the limited instruction without repeated ciphertext, so that an attacker is prevented from stealing the ciphertext in a channel to implement replay attack.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Embodiment one:
referring to fig. 1, in order to solve the problem that in the existing encryption technology, there is a limited repetition of instruction ciphertext, and it is very easy for an attacker to use a dedicated device to steal message data in a channel and implement replay attack, from the perspective of an encryption party, an instruction encryption method capable of resisting replay attack is adopted in this embodiment, and the method includes:
synchronizing an initial value R with a decryption party i I is the instruction encryption times and the initial value R i Each time of synchronization is different;
by an initial value R i Key K and instruction Step i Co-generation of ciphertext I i
The instructions encrypted in this embodiment include, but are not limited to: signals in a signal carrier capable of carrying information, such as radio signals, electrical signals, acoustic signals, and optical signals.
By adding the initial value when the encryption party encrypts, the initial value and the secret key encrypt the instruction together and synchronize the initial value with the decryption party, so that the limited instruction can not generate repeated ciphertext after being encrypted by the encryption algorithm under the condition that the encryption algorithm is unchanged, the ciphertext generated by each encryption of the same instruction is different, and an attacker is difficult to steal the ciphertext in a channel to implement replay attack.
To reduce the initial value R i Thereby further reducing the possibility of replay attacks, in a preferred version of this embodiment, the initial value R is when i=0 i The generation method of the method comprises the following steps:
s01_1, generating a first random number Rand 1 Let R 0 =Rand 1 Setting a first cycle number G 1
S01_2, judge G 1 If G is a value of 1 >0 executing step S01_3, otherwise jumping to step S01_6;
S01_3、G 1 =G 1 -1, wherein G to the right of the equal sign 1 G for the last time this step is performed 1 Is a value of (2);
s01_4 if R 0 Cannot be f 1 Integer division, R 0 =R 0 *r 1 +K, wherein R to the right of the equal sign 0 For R at the last time of executing this step 0 Take the value r 1 For the first encryption parameter, K is a key, f 1 Is equal to r 1 Integer of K interstitium;
if R is 0 Can be f 1 Integer division, R 0 =R 0 /f 1 Wherein R to the right of the equal sign 0 For R at the last time of executing this step 0 Taking a value;
s01_5, jump to step s01_2;
s01_6, complete initial value R i And (5) generating.
Here G 1 Can be understood as a security level
f 1 Preferably, it can be set to 2.
The method for generating the ciphertext in this embodiment may adopt an encryption algorithm in the prior art, but in order to improve encryption efficiency and reduce calculation amount, so that the present invention may be applied to a place with small data size but high real-time requirement, such as an instruction, where in the preferred scheme of this embodiment, the ciphertext I i The generation method of the method comprises the following steps:
s02_0, i=0I i Is R 0 Otherwise set I i The final ciphertext is generated for the last encryption;
s02_1, judgment instruction Step i If Step is taken i >0 then executing step S02_2, otherwise jumping to step S02_9;
S02_2、Step i =Step i -1, step to the right of the equal sign i Step for the last time this Step was performed i Is a value of (2);
s02_3, set the second cycle number G 2
S02_4, judge G 2 If G is a value of 2 >0 then executing step S02_5, otherwise jumping to step S02_9;
S02_5、G 2 =G 2 -1, wherein G to the right of the equal sign 2 G for the last time this step is performed 2 Is a value of (2);
s02_6 if I i Cannot be f 2 Integer division, I i =I i *r 2 +K, wherein I to the right of the equal sign i For I at the time of last execution of this step i Take the value r 2 For the second encryption parameter, K is the key, f 2 Is equal to r 2 Integer of K interstitium;
if I i Can be f 2 Integer division, I i =I i /f 2 Wherein I to the right of the equal sign i For I at the time of last execution of this step i Taking a value;
s02_7, jump to step s02_4;
s02_8, jump to step s02_1;
s02_9, complete ciphertext I i And (5) generating.
Preferably, f herein 2 Preferably can be set as 2, r 2 =3。
In order to prove that the encryption method has the advantage of high calculation efficiency, the following description is made by the pseudo code encrypted by the instruction, and the logic of the pseudo code is consistent with that of the ciphertext generation method.
The following is a pseudo code for ciphertext generation:
f herein 2 |I i Representation I i Can be f 2 The whole of the method is divided into two parts,representation I i Cannot be f 2 And (5) integer division.
Here I i Is the initial value, is generated by the encryption party for the first time, and is the ciphertext finally generated by the last encryption after that, G 2 For the second number of cycles, it can be understood as a security level.
Compared to symmetric and asymmetric encryption algorithms:
the idea of symmetric cryptography is scrambling and diffusion, and various algorithms, such as round key addition, byte substitution, sub-key generation, etc., are used in the process of scrambling and scrambling, and are not easy to simplify. The asymmetric cryptographic algorithm generally uses the big digital power modular operation in the number theory, and the calculation time is relatively long. In the encryption method, multiplication and one addition used in the if statement can be decomposed into n bits shifted left and one addition; in the while statement, the division operation may be translated into a right shift of n bits and an addition. Because the left shift operation and the right shift operation (collectively referred to as shift operation) have high calculation efficiency in the computer, the scheme can reduce the calculation time and improve the calculation efficiency through the shift operation.
It is worth mentioning that this preferred scheme still has the advantage that the security is high. To demonstrate this, it is illustrated by the following analysis.
Here, the initial value (or the last ciphertext I i-1 ) Under the action of the secret key K, ciphertext I is generated i
In general, assume that an instruction Step that requires encryption i Is 2 (Step) i A value of 2 means I i Multiplied by r 2 Plus the sum of K divided by f 2 2 times to the n-th power), where n 1 And n 2 Is the execution statement "I i =I i /f 2 "number of times, let G 2 The number of =1 is:
assume that the result of the whole equation is ciphertext I i I.e. return value I in pseudo code i Then the formula (1) can be simplified as:
(2) The formula two sides mod K (namely the key K) at the same time can be obtained by simplifying:
similarly, assume that an encrypted instruction Step is required i Is 3 (Step) i A value of 3 means I i Multiplied by r 2 Plus the sum of K divided by f 2 3 times to the n-th power) of G 2 =1, similar to above. Then it is possible to obtain:
similar to the (1) (2) (3) simplification steps, (4) two sides of the simplified model are simultaneously mod K, and the simplified model can be obtained:
further, if the instruction Step is to be encrypted i 10000, the simplified method can be obtained:
in general, if the instruction to be encrypted is Step i Then the formula (6) may be changed to:
let e=x×step if g=x i Then the following steps are obtained:
note that in equation (8), I is entered i-1 Is the initial value or the last ciphertext, r 2 Is statement I i ←I i *r 2 R in +K 2 ,Step i Is the instruction of the current transmission (namely the object to be protected), I i Is ciphertext generated by the encryption, f 2 Is a programAnd f 2 |I i F of (f) 2 ,n 1 ,n 2 ,n 3 …n Stepi Is to execute the statement while f each time 2 |I i K is a key, thus it can be seen that even if an eavesdropper otherwise obtains the I transmitted in the channel i-1 、I i Without knowing the key K, the instruction Step cannot be calculated i Because this can be reduced to discrete logarithmic problems, discreteLogarithmic problems are world-accepted mathematical problems, and some cryptographic algorithms (e.g., elGamal digital signature schemes) are designed using discrete mathematical problems. In other words, if an eavesdropper or attacker based on some collectedCiphertext (ciphertext)To obtain the instruction, the discrete logarithm problem is solved, which is almost impossible, in order to obtain the key K.
Thus, the ciphertext generated by the present encryption algorithm may be demonstrated to be secure by the above analysis.
In order to verify the effectiveness of the encryption algorithm, the applicant carried out experiments on several instructions by the above encryption algorithm, the experimental results are shown in tables 1 and 2:
table 1 ciphertext transmitted at a second cycle number of 8
Table 2 ciphertext transmitted at a second cycle number of 8
In this scheme, except for the first encryption, the initial value used each time thereafter is the last ciphertext. Therefore, after each instruction is encrypted, the length of the generated ciphertext is consistent, the ciphertext generated by each instruction is different, and even if an eavesdropper steals the ciphertext transmitted on the channel, the instruction cannot be restored under the condition that the eavesdropper does not know the secret key, so that secret communication is realized. Secondly, even the same instruction, after encryption, the generated ciphertext is completely different, so that the aim of resisting replay attack is fulfilled. It should be noted that, the initial value, the key, the first cycle number and the second cycle number in the present patent and the instruction to be encrypted are all set according to the actual needs, the present patent does not limit the value range, and the contents listed in the present table are intended to further reflect the use effect represented by the present patent.
To ensure thatThe system can efficiently decrypt and avoid communication interruption caused by DDOS attack, and the method further comprises the following steps: the encryption party will t 1 The secondary retransmission request is automatically converted into a primary resynchronization request. T herein 1 Is a preset value and is a positive integer greater than 0.
Specifically, the resynchronization request is: resetting the encryption number i to 0, requesting the encryptor to regenerate R 0 Ciphertext is regenerated and transmitted.
Embodiment two:
referring to fig. 1, in order to solve the problem that in the prior art of encryption, there is a repetition of limited instruction ciphertext, and it is very easy for an attacker to use a dedicated device to steal message data in a channel and implement replay attack, in view of a decryption party, an instruction decryption method capable of resisting replay attack is adopted in this embodiment, and the method includes the following steps:
s03_1, receiving ciphertext I sent by the encryption party i
S03_2, loading the same key K as the encryption party, synchronizing the initial value R with the encryption party i I is the instruction encryption times and the initial value R i Each time of synchronization is different;
s03_3. traversing the encryption side instruction, and passing through the key K and the initial value R i Generating encryption instructions for the instructions of the encryption party, and jumping to the step S03_4 when each encryption instruction is generated;
s03_4 for encrypting instruction I 'generated in step s03_3' i And ciphertext I i In contrast, if ciphertext I i And the encryption instruction I 'generated in the step S03_3' i Compared with the bit error rate smaller than or equal to the set value SER, taking the instruction corresponding to the encrypted instruction which is the same as the ciphertext in the step S03_2 as a decrypted instruction, and jumping to the step S03_6; if ciphertext I i And all the encryption instructions I 'generated in step S03_3' i If the bit error rate is larger than the set value SER, the step S03-3 is skipped until the command traversal of the encryption party is completed;
s03_5, a resending request is sent to an encryption party;
s03_6, complete decryption.
When decrypting, the encryption party command is traversed by synchronizing the initial value with the encryption party, the encryption command is generated by utilizing the key and the initial value, the error rate corresponding to the encryption command and the ciphertext received from the encryption party is obtained one by one, and the command corresponding to the encryption command with the error rate smaller than the set value is found, so that the ciphertext is decrypted. Under the condition that the cryptographic algorithm is unchanged, the decryption party can decrypt the ciphertext corresponding to the received different instructions each time, so that an attacker is difficult to steal the ciphertext in the channel to implement replay attack.
Under normal conditions, the voltage of a signal is changed by decay in the transmission process of a communication channel, so that the signal is destroyed in transmission, and an error code is generated. Noise, pulses caused by alternating current or lightning, transmission equipment failures, and other factors can cause errors (e.g., a transmitted signal of 1 and a received signal of 0; and vice versa) to cause communication interruption. In order to avoid this, further, the method for calculating the error rate in step s03_4 is as follows:
ciphertext I i And encryption instruction I' i Is decomposed into separate numbers;
ciphertext I i And encryption instruction I' i A bit number A of the larger median;
ciphertext I i And encryption instruction I' i Respectively carrying out one-to-one comparison on the values of the digits corresponding to the decomposed digits, and solving the digits B with different comparison results;
the bit error rate P, p=b/a is found.
The method and the device can still normally decrypt the encryption instruction under the condition of the set bit error rate, and avoid communication interruption caused by too high bit error rate due to too large interference noise or weak signal. The present solution thus enhances the stability of the system.
In this embodiment, the same encryption algorithm as the encryption party is adopted, so as to improve encryption efficiency and reduce calculation amount, so that the present invention can be applied to a place where the data amount of the instruction is small but the real-time requirement is high, preferably, the method for generating the encryption instruction in step s03_3 includes the following steps:
s03_3_0, encryption instruction I 'when i=0' i Initial value R sent for encryption method 0 Otherwise, setting an encryption instruction I' i For the encrypted instruction I 'after the last decryption success' i-1
S03_3_1, determination instruction Step i If Step is taken i >0 then step s03_3_2, else jump to step s03_3_9;
S03_3_2、Step i =Step i -1, step to the right of the equal sign i Step for the last time this Step was performed i Is a value of (a).
S03_3_3, setting a second cycle number G 2
S03_3_4, judgment G 2 If G is a value of 2 >0 then executing step S02_5, otherwise jumping to step S02_8;
S03_3_5、G 2 =G 2 -1, wherein G to the right of the equal sign 2 G for the last time this step is performed 2 Is a value of (2);
s03_3_6, if I' i Cannot be f 2 Integer division, I' i =I′ i *r 2 +K, wherein I 'to the right of the equal sign' i For the encrypted instruction I 'at the last time of executing this step' i Take the value r 2 For the second encryption parameter, K is the key, f 2 Is equal to r 2 Integer of K interstitium;
if I' i Can be f 2 Integer division, I' i =I′ i /f 2 Wherein I 'to the right of the equal sign' i For I 'at the last time this step was performed' i Taking a value;
s03_3_7, jump to step s03_3_4;
s03_3_8, jump to step s03_3_1;
s03_3_9, complete encryption instruction I' i And (5) generating.
The decryption method has the advantages of high calculation efficiency and good security, and the proving process is consistent with the encryption method in the first implementation example.
In addition, since the encryptor needs to consume larger computing resources each time the encryptor generates the initial value through the random number, the communication efficiency is reduced, and in the embodiment, after the decryptor receives the initial value sent by the first encryptor, the decryptor does not generate the initial value through encryption, but directly uses the ciphertext generated by the last instruction encryption as the initial value, thereby greatly reducing the cost of computing resources.
In order to avoid the system being damaged or being subject to further attack and reduce consumption, further in this embodiment, in the step s03_5, if the decryptor sends out a resynchronization request exceeding t 2 The secondary terminates the communication and allows the decryption party to execute the preset instructions. T herein 2 Is a positive integer greater than 0.
Even if decryption is unsuccessful, a resending request and a resynchronization request can be sent to the encryption party, DDOS attack is identified and a preset instruction is executed, so that the system is not damaged or suffers further attack, and consumption is reduced.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, hard disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, 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 flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable medium that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable medium produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing is a further detailed description of the invention in connection with the preferred embodiments, and it is not intended that the invention be limited to the specific embodiments described. It will be apparent to those skilled in the art that several simple deductions or substitutions may be made without departing from the spirit of the invention, and these should be considered to be within the scope of the invention.

Claims (7)

1. A method of encrypting instructions against replay attacks, the method comprising:
synchronizing an initial value R with a decryption party i I is the instruction encryption times and the initial value R i Each time of synchronization is different;
by an initial value R i Key K and instruction Step i Co-generation of ciphertext I i
When i=0, the initial value R i The generation method of the method comprises the following steps:
s01_1, generating a first random numberRand 1 Let R 0 =Rand 1 Setting a first cycle number G 1
S01_2, judge G 1 If G is a value of 1 >0 then step s01_3 is executed, otherwise step is skipped
S01_6;
S01_3、G 1 =G 1 -1, wherein G to the right of the equal sign 1 G for the last time this step is performed 1 Is a value of (2);
s01_4 if R 0 Cannot be f 1 Integer division, R 0 =R 0 *r 1 +K, wherein R to the right of the equal sign 0 For R at the last time of executing this step 0 Take the value r 1 For the first encryption parameter, K is a key, f 1 Is equal to r 1 Integer of K interstitium;
if R is 0 Can be f 1 Integer division, R 0 =R 0 /f 1 Wherein R to the right of the equal sign 0 For R at the last time of executing this step 0 Taking a value;
s01_5, jump to step s01_2;
s01_6, complete initial value R i Generating;
the ciphertext I i The generation method of the method comprises the following steps:
s02_0, i=0I i Is R 0 Otherwise set I i The final ciphertext is generated for the last encryption;
s02_1, judgment instruction Step i If Step is taken i >0 then executing step S02_2, otherwise jumping to step S02_9;
S02_2、Step i =Step i -1, step to the right of the equal sign i Step for the last time this Step was performed i Is a value of (2);
s02_3, set the second cycle number G 2
S02_4, judge G 2 If G is a value of 2 >0 then step s02_5 is executed, otherwise step is skipped
S02_9;
S02_5、G 2 =G 2 -1, wherein G to the right of the equal sign 2 G for the last time this step is performed 2 Is a value of (2);
s02_6 if I i Cannot be f 2 Integer division, I i =I i *r 2 +K, wherein I to the right of the equal sign i For I at the time of last execution of this step i Take the value r 2 For the second encryption parameter, K is the key, f 2 Is equal to r 2 Integer of K interstitium;
if I i Can be f 2 Integer division, I i =I i /f 2 Wherein I to the right of the equal sign i For I at the time of last execution of this step i Taking a value;
s02_7, jump to step s02_4;
s02_8, jump to step s02_1;
s02_9, complete ciphertext I i And (5) generating.
2. An instruction encryption method capable of resisting replay attack according to claim 1, wherein the following steps are performed
r 1 =3。
3. The method of encrypting instructions against replay attacks according to claim 1 or 2, characterized in that it further comprises: the encryption party will t 1 The secondary retransmission request is automatically converted into a primary resynchronization request.
4. A method of encrypting instructions against replay attacks according to claim 3, wherein the re-synchronisation request is: resetting the encryption number i to 0, requesting the encryptor to regenerate R 0 Ciphertext is regenerated and transmitted.
5. A method of decrypting instructions against replay attacks, the method comprising the steps of:
s03_1, receiving ciphertext I sent by the encryption party i
S03_2, loading and encrypting partyThe same key K, synchronizing with the encryption party the initial value R i I is the instruction encryption times and the initial value R i Each time of synchronization is different;
s03_3. traversing the encryption side instruction, and passing through the key K and the initial value R i Generating encryption instructions for the instructions of the encryption party, and jumping to the step S03_4 when each encryption instruction is generated;
s03_4. the encryption instruction I generated in step S03_3 i ' ciphertext I i In contrast, if ciphertext I i And step (c)
Encryption instruction I generated in S03_3 i The 'bit error rate is smaller than or equal to the set value SER', the steps are performed
Taking an instruction corresponding to the encrypted instruction which is the same as the ciphertext in S03_2 as a decrypted instruction, and jumping to the step S03_6; if ciphertext I i And all the encryption instructions I generated in step S03_3 i If the' bit error rate is larger than the set value SER, the step S03-3 is skipped until the command traversal of the encryption party is completed;
s03_5, a resending request is sent to an encryption party;
s03_6, finishing decryption;
the method for generating the encryption instruction in the step S03_3 comprises the following steps:
s03_3_0, encrypting instruction I when i=0 i ' initial value R sent for encryption method 0 Otherwise, setting encryption instruction I i ' is the encrypted instruction I after the last decryption success i-1
S03_3_1, determination instruction Step i If Step is taken i If > 0, executing step S03_3_2, otherwise jumping to step S03_3_9;
S03_3_2、Step i =Step i -1, step to the right of the equal sign i Step for the last time this Step was performed i Is a value of (2);
s03_3_3, setting a second cycle number G 2
S03_3_4, judgment G 2 If G is a value of 2 If the value is more than 0, executing the step S02_5, otherwise, jumping to the step S02_8;
S03_3_5、G 2 =G 2 -1, wherein G to the right of the equal sign 2 G for the last time this step is performed 2 Is a value of (2);
s03_3_6, if I' i Cannot be f 2 Integer division, I' i =I′ i *r 2 +K, wherein I 'to the right of the equal sign' i For the encrypted instruction I 'at the last time of executing this step' i Take the value r 2 For the second encryption parameter, K is the key, f 2 Is equal to r 2 Integer of K interstitium;
if I' i Can be f 2 Integer division, I' i =I′ i /f 2 Wherein I 'to the right of the equal sign' i For I 'at the last time this step was performed' i Taking a value;
s03_3_7, jump to step s03_3_4;
s03_3_8, jump to step s03_3_1;
s03_3_9, complete encryption instruction I' i And (5) generating.
6. The method for decrypting the command capable of resisting the replay attack according to claim 5, wherein the method for calculating the error rate in step s03_4 is as follows:
ciphertext I i And encryption instruction I' i Is decomposed into separate numbers;
ciphertext I i And encryption instruction I' i A bit number A of the larger median;
ciphertext I i And encryption instruction I' i Respectively carrying out one-to-one comparison on the values of the digits corresponding to the decomposed digits, and solving the digits B with different comparison results;
the bit error rate P, p=b/a is found.
7. The method of claim 5, wherein in step s03_5, if the decryptor sends a retransmission request exceeding t 2 The secondary terminates the communication and allows the decryption party to execute the preset instructions.
CN202210142930.5A 2022-02-16 2022-02-16 Instruction encryption and decryption method capable of resisting replay attack Active CN114465804B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210142930.5A CN114465804B (en) 2022-02-16 2022-02-16 Instruction encryption and decryption method capable of resisting replay attack

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210142930.5A CN114465804B (en) 2022-02-16 2022-02-16 Instruction encryption and decryption method capable of resisting replay attack

Publications (2)

Publication Number Publication Date
CN114465804A CN114465804A (en) 2022-05-10
CN114465804B true CN114465804B (en) 2024-03-26

Family

ID=81413235

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210142930.5A Active CN114465804B (en) 2022-02-16 2022-02-16 Instruction encryption and decryption method capable of resisting replay attack

Country Status (1)

Country Link
CN (1) CN114465804B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102437912A (en) * 2012-01-06 2012-05-02 厦门博鼎智文传媒科技有限公司 Digital rights management method based on N RSA (Rivest Shamir Adleman) encryption algorithms based on chaotic algorithm
CN102983964A (en) * 2012-12-28 2013-03-20 大唐微电子技术有限公司 method and device for improving digital encryption standard resisting differential power analysis
CN103607276A (en) * 2013-12-05 2014-02-26 桂林电子科技大学 Grouping encryption method based on random functions and resisting to known plaintext cipher attacks
CN106778251A (en) * 2015-11-20 2017-05-31 北京计算机技术及应用研究所 Prevent the password authentication method of Replay Attack
CN109510703A (en) * 2018-11-23 2019-03-22 北京海泰方圆科技股份有限公司 A kind of data encryption/decryption method and device
CN110536294A (en) * 2019-08-07 2019-12-03 山东大学 A kind of method that inverse attack obtains GMR-2 encryption satellite communication key
CN111586000A (en) * 2020-04-28 2020-08-25 北京物资学院 Full-proxy homomorphic re-encryption transmission system and operation mechanism thereof
CN111835509A (en) * 2020-05-20 2020-10-27 成都盛拓源科技有限公司 Anti-loss one-way encryption method and device based on hash function and password

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102437912A (en) * 2012-01-06 2012-05-02 厦门博鼎智文传媒科技有限公司 Digital rights management method based on N RSA (Rivest Shamir Adleman) encryption algorithms based on chaotic algorithm
CN102983964A (en) * 2012-12-28 2013-03-20 大唐微电子技术有限公司 method and device for improving digital encryption standard resisting differential power analysis
CN103607276A (en) * 2013-12-05 2014-02-26 桂林电子科技大学 Grouping encryption method based on random functions and resisting to known plaintext cipher attacks
CN106778251A (en) * 2015-11-20 2017-05-31 北京计算机技术及应用研究所 Prevent the password authentication method of Replay Attack
CN109510703A (en) * 2018-11-23 2019-03-22 北京海泰方圆科技股份有限公司 A kind of data encryption/decryption method and device
CN110536294A (en) * 2019-08-07 2019-12-03 山东大学 A kind of method that inverse attack obtains GMR-2 encryption satellite communication key
CN111586000A (en) * 2020-04-28 2020-08-25 北京物资学院 Full-proxy homomorphic re-encryption transmission system and operation mechanism thereof
CN111835509A (en) * 2020-05-20 2020-10-27 成都盛拓源科技有限公司 Anti-loss one-way encryption method and device based on hash function and password

Also Published As

Publication number Publication date
CN114465804A (en) 2022-05-10

Similar Documents

Publication Publication Date Title
CN107196763B (en) SM2 algorithm collaborative signature and decryption method, device and system
US10104048B2 (en) Method and system for secure key generation over an insecure shared communication medium
CN113259329B (en) Method and device for data careless transmission, electronic equipment and storage medium
US8670563B2 (en) System and method for designing secure client-server communication protocols based on certificateless public key infrastructure
CN112165443B (en) Multi-key information encryption and decryption method, device and storage medium
CN113271209B (en) Trustable public key encryption system and method based on non-interactive zero-knowledge proof
CN113225371A (en) Electric power Internet of things terminal control instruction encryption and decryption system and method
CN111478911A (en) Instant messaging encryption method adopting lightweight key exchange algorithm
CN114499857A (en) Method for realizing data correctness and consistency in big data quantum encryption and decryption
EP3010173B1 (en) Key storage device, key storage method, and program therefor
CA2742530C (en) Masking the output of random number generators in key generation protocols
CN114465804B (en) Instruction encryption and decryption method capable of resisting replay attack
CN113162765B (en) Trustable public key encryption system and method based on non-interactive key agreement
CN112149166B (en) Unconventional password protection method and intelligent bank machine
CN110365482B (en) Data communication method and device
CN111131158A (en) Single byte symmetric encryption and decryption method, device and readable medium
CN110784480A (en) Data transmission method, system, equipment and storage medium
CN114710359B (en) Industrial network dynamic key management method and industrial network encryption communication method
US7327845B1 (en) Transmission of encrypted messages between a transmitter and a receiver utilizing a one-time cryptographic pad
CN114422114B (en) Time-controlled encryption method and system based on multi-time server
CN117615471A (en) FPGA-based wireless communication data security transmission system and method
CN116248270A (en) Plaintext encryption method, plaintext encryption device, electronic equipment and storage medium
CN117714207A (en) Encryption method for intelligent control system of power transformation and distribution
CN117394985A (en) Communication method, system, equipment and medium for encrypting electric power information
CN116455553A (en) Ciphertext database configuration file encryption and decryption methods and devices

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant