A block cipher side channel collision test method and device based on neural network

Through the packet cipher side channel collision test method based on neural network, the problems of waveform aberration and low signal-to-noise ratio in the prior art are solved, detection accuracy and stability are improved, and efficient key recovery is achieved.

CN114139645BActive Publication Date: 2024-11-05CHINESE PEOPLES LIBERATION ARMY UNIT 63891
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111483645.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-07
Publication Date
2024-11-05
Estimated Expiration
2041-12-07

AI Technical Summary

Technical Problem

The existing neural network side channel analysis method cannot be effective in testing scenarios where the leakage model and leakage location are not known. In addition, traditional side channel collision testing requires accurate selection of leakage points and fully aligned waveforms, making it difficult to deal with waveform aberration and low signaling. The noise ratio leads to lower detection accuracy and stability.

Method used

Using the packet cipher side channel collision test method based on neural network, by selecting the packet cipher algorithm to be tested and two S boxes that can be used for training, collecting energy waveforms and dividing them into collision and non-collision categories, and training the neural network to identify The waveform in the unknown key device is determined whether a collision occurs between the S-boxes, and there is no need to accurately select the leakage point and the fully aligned waveform.

Benefits of technology

It improves the accuracy and stability of detection, can handle misaligned and low signal-to-noise ratio waveforms, reduces implementation difficulty, and enhances the efficiency of key recovery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114139645B_ABST
    Figure CN114139645B_ABST
Patent Text Reader

Abstract

The present invention proposes a block cipher side channel collision test method based on a neural network, comprising: step 1: selecting a block cipher algorithm to be tested and two S boxes that can be used for training, running the block cipher algorithm to be tested through device A with a known key, encrypting multiple different plaintexts, and collecting energy waveforms during the running process; step 2: detecting the energy waveform, and according to the detection result, classifying the energy waveform into two categories of collision and non-collision as a training set; step 3: training a neural network based on the classified waveforms in the training set to obtain a trained neural network; step 4: using device B with an unknown key to encrypt a plaintext through the block cipher algorithm, collecting the energy waveform during the running of the cipher algorithm as a test set; inputting the test set into the trained neural network; step 5: distinguishing each waveform in the test set as a collision type waveform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a block cipher side channel collision test method and device based on a neural network, and in particular to a block cipher side channel collision test method based on a neural network, belonging to the technical field of network security side channel analysis. Background Art

[0002] In recent years, traditional cryptanalysis technology, that is, the technology of analyzing and recovering keys through the plaintext and ciphertext information of normal channels, has been widely studied. However, with the increase in key length and the complexity of cryptographic algorithms, it has become difficult for traditional cryptanalysis technology to efficiently analyze cryptographic algorithms. Compared with traditional cryptanalysis technology, the side channel analysis technology proposed by Kocher in 1996 can directly or indirectly obtain intermediate value information during the operation of the cryptographic algorithm, and can recover longer keys in segments. Side channel analysis technology has extremely high practicality and destructiveness. At present, the encryption algorithms in a large number of encryption devices (such as AES, DES, RSA, etc.) have been tested one after another, which poses a severe challenge to the security of encryption devices.

[0003] As early as 2011, artificial intelligence technology was introduced into the field of side channel analysis, and machine learning algorithms represented by neural networks have been widely studied. Its automatic operation, convenient implementation, intelligent positioning, and accurate judgment have shown great potential. Side channel analysis based on neural networks is based on such a scenario: Assume that the tester has a device B to be tested and a device A with permission to write keys. The two devices are of the same model, and the programs and side information leakage models are the same. Then the tester can write a known key in device A and collect energy waveforms for training; then collect energy waveforms on device B with unknown keys, conduct tests, and recover the keys through the test results.

[0004] Although neural network technology has the characteristics of simple ideas and strong cross-domain universality, there is still a blank in the field of combining neural network technology with collision testing. In a test scenario where the leakage model and leakage location are unknown, the existing neural network side channel analysis method may not work. However, using neural networks for collision detection may achieve good results. Summary of the invention

[0005] In order to solve the above technical problems, the present invention proposes a block cipher side channel collision test method based on a neural network, comprising the following steps:

[0006] Step 1: Select the block cipher algorithm to be tested and two S-boxes that can be used for training, namely S1 and S2; use the known key to run the block cipher algorithm to be tested through device A, encrypt multiple different plaintexts, and collect the energy waveform during the operation;

[0007] Step 2: Detect the energy waveform, and according to the detection result, classify the energy waveform into two categories: collision and non-collision as a training set;

[0008] Step 3: training the neural network based on the classified waveforms in the training set to obtain a trained neural network;

[0009] Step 4: Device B using an unknown key encrypts a plain text by using the block cipher algorithm, collects energy waveforms during the operation of the cipher algorithm as a test set; and inputs the test set into the trained neural network;

[0010] Step 5: Distinguish each waveform in the test set as a collision-type waveform. If the waveform in the test set that exceeds the preset ratio threshold is determined to be a collision, it is considered that a collision has occurred between S1 and S2 during the current plaintext encryption process; otherwise, it is considered that S1 and S2 have not collided.

[0011] In particular, detecting the energy waveform in step 2 includes: whether the output values ​​of S1 and S2 calculated based on the known plaintext and the key are equal; if the output values ​​are equal, the energy waveform is considered to be a collision type; or if the output values ​​are not equal, the waveform is considered to be a non-collision type.

[0012] In particular, step 5 further includes: if the box S1 and the box S2 do not collide, then the plaintext to be encrypted of device B is replaced with other plaintext, and steps 4-5 are repeated until a collision is detected between S1 and S2.

[0013] In particular, in step 1, the block cipher algorithm to be tested is selected as the AES algorithm; the two S1 and S2 that can be used for training are the two S boxes used in the first round of the AES algorithm.

[0014] In particular, the method further comprises: when a collision occurs between S1 and S2 in the S-box, a sequence between an output value of S1 and an output value of S2 is established, thereby establishing a digital association between a key corresponding to S1 and a key corresponding to S2.

[0015] In particular, the method further includes: selecting other S-box combinations, repeating steps 1 to 5, and further detecting whether there is a collision between the S-boxes.

[0016] Particularly, the threshold of the preset ratio is 50%.

[0017] The present invention also proposes a block cipher side channel collision test device based on a neural network, characterized in that the device comprises:

[0018] The waveform acquisition module is used to select the block cipher algorithm to be tested and the two S1 and S2 that can be used for training; the block cipher algorithm to be tested is run through device A with a known key, a plurality of different plaintexts are encrypted, and the energy waveform during the operation is collected;

[0019] A training set generation module, used for detecting the energy waveform and classifying the energy waveform into two categories of collision and non-collision as a training set according to the detection result;

[0020] A neural network training module, used for training a neural network based on the classified waveforms in the training set to obtain a trained neural network;

[0021] A test data acquisition module, used for encrypting a plain text by the block cipher algorithm using the device B with an unknown key, collecting the energy waveform during the operation of the cipher algorithm as a test set; and inputting the test set into the trained neural network;

[0022] The collision result detection module is used to distinguish whether each waveform in the test set belongs to a collision type waveform. If the waveform in the test set exceeding the preset ratio threshold is determined to be a collision, it is considered that a collision has occurred between S1 and S2 during the current plaintext encryption process; otherwise, it is considered that no collision has occurred between S1 and S2.

[0023] The method of the present invention has the following advantages compared with the existing side channel collision test method:

[0024] 1. There is no need to select the leak point precisely.

[0025] In classic side channel testing, collision testing generally requires first accurately identifying the part of the waveform that corresponds to the intermediate value where the collision occurred. With the use of neural networks, there is no need to select key points very accurately. If several irrelevant points are included, the neural network will automatically reduce the weight of these points or reduce them to zero.

[0026] 2. The waveforms do not need to be perfectly aligned.

[0027] Traditional side channel testing has difficulty solving the problem of waveform misalignment, because waveform misalignment will lead to insufficient concentration of information at a single point, making it difficult to obtain good results when doing statistical analysis. However, neural networks can overcome this problem. During the training phase, various samples with misaligned waveforms can be generated for training, so that the neural network has the ability to identify misaligned samples. During the test phase, when misaligned waveforms are input, the neural network can also successfully identify them.

[0028] 3. Compared with traditional collision detection methods, this method greatly improves accuracy and stability, and is easy to implement. When using traditional methods to detect collisions, when the signal-to-noise ratio is too small, the detection accuracy will be greatly reduced, but neural networks can overcome this problem. In the training stage, various samples with low signal-to-noise ratios can be generated for training, so that the neural network has the ability to identify samples with large noise. In the test stage, when a waveform with large noise is input, the neural network can also identify the correct result. Once the neural network is trained and perfected, the difficulty of subsequent implementation is greatly reduced, and it is very easy to implement. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 is a flow chart of the method of the present invention;

[0030] Figure 2 is a collision encryption energy trace diagram of the simulated AES cryptographic algorithm in the embodiment of the method of the present invention;

[0031] Figure 3 It is a non-collision encryption energy trace diagram of the simulated AES cryptographic algorithm in the method embodiment of the present invention. DETAILED DESCRIPTION

[0032] The specific implementation modes of the present invention are described in detail below with reference to the accompanying drawings.

[0033] Taking the AES cryptographic algorithm as an example, the energy waveform of the AES algorithm on a known key device is generated by simulation, and the neural network is trained. Then, the trained neural network is used to identify the energy waveform of the unknown key device generated by simulation, and whether the first two S boxes of the first round of AES collide. Then, the mathematical relationship between the keys corresponding to the two S boxes is obtained, and the S box pair is changed to continue identification, and finally efficient key recovery is achieved. Block cipher algorithms generally have multiple S boxes. Based on side channel analysis technology, we test multiple S boxes in the first round. There are usually two types of test methods: one is to test only one, such as related energy test, template test, neural network side channel analysis, etc.; the other is to test two S boxes at the same time, that is, collision test. This patent tests two S boxes at the same time and uses a neural network to detect collisions.

[0034] When an encryption device runs a cryptographic algorithm, two different inputs are encrypted with an unknown key. If a certain intermediate value of the energy consumption of the two encryption operations is equal, an intermediate value collision occurs. Each collision reduces the difficulty of key search. If some specific collisions can be observed, the key can even be uniquely determined. In practice, in order to detect collisions, it is necessary to identify the part corresponding to the intermediate value of the processing collision in the energy trace, and then it is necessary to determine whether the two corresponding parts are equal.

[0035] To this end, the present invention proposes a block cipher side channel collision test method based on a neural network. The process is as follows: Figure 1 As shown, the following steps are included:

[0036] Step 1: Select the block cipher algorithm to be tested and two S-boxes that can be used for training, namely S1 and S2; use the known key to run the block cipher algorithm to be tested through device A, encrypt multiple different plaintexts, and collect the energy waveform during the operation;

[0037] In the present invention, the block cipher algorithm can be selected to take the AES cipher algorithm as an example. The block cipher algorithm generally has multiple S boxes. Based on the side channel analysis technology, we can choose to test multiple S boxes in the first round. Generally, there are two types of testing methods in this field: one is to test only one, such as correlation energy test, template test, neural network side channel analysis, etc.; the other is to test two S boxes at the same time, that is, collision test.

[0038] First, the first two S1 and S2 of the first round of the block cipher algorithm can be selected. Multiple plaintexts are encrypted using device A with a known key, and energy waveforms during the operation of multiple cipher algorithms are collected.

[0039] The waveforms used in this embodiment are all simulation waveforms. For the first two S1 and S2 of the first round of the AES algorithm, multiple plaintexts encrypted on device A with a known key are simulated and generated, and 1256 energy waveforms are collected during the operation of the cryptographic algorithm.

[0040] Step 2: Detect the energy waveform, and according to the detection result, classify the energy waveform into two categories: collision and non-collision as a training set;

[0041] In this step, the waveforms are divided into collision and non-collision categories according to whether the output values ​​of S1 and S2 calculated by the known plaintext and the key are equal, and each waveform is labeled collision or non-collision. Figure 2 , Figure 3 Specifically, the energy waveform obtained by the AES algorithm under different plaintexts using the known key after S1 and S2 operations can be calculated according to Figure 2 , Figure 3 That is, when the values ​​output by S1 and S2 are the same, it is considered that a collision has occurred, and the two energy waves that appear in the encryption process are marked as collisions; conversely, when the values ​​output by S1 and S2 are different, it is considered that no collision has occurred. In this case, the energy waveform generated in the encryption process is marked as non-collision.

[0042] Step 3: Based on the classified waveforms in the training set, the neural network is trained to obtain a trained neural network; based on the simulated energy waveform generated in step 2, the neural network is trained. In this step, the neural network model in this patent uses an architecture similar to ResNet: shortcuts and BN layers are used. The neural network contains 16 residual blocks, and each residual block contains 2 convolutional layers. The filter layer size of all convolutional layers is 16, and the number of filters is 64k, where k starts from 1 and increases by 1 every 4 residual blocks. Each residual block is downsampled once (factor is 2), so the original input is finally downsampled to 1 / 256 of the original size. When a residual block is downsampled, the shortcut also uses max-pool for downsampling. Before each convolutional layer, we use BN layer and ReLU function. Due to the use of pre-activation, the first and last layers of the network become different. We trained the network from scratch, and the parameters of the convolutional layer were initialized in the same way as ResNet v1. Using the Adam optimizer with default parameters, the best model on the validation set during training is saved for testing.

[0043] Step 4: Use device B with an unknown key to encrypt a plaintext using the block cipher algorithm, and collect the energy waveform during the operation of the cipher algorithm as a test set; input the test set into the trained neural network; In this step, use device B with an unknown key to encrypt a specific plaintext, collect multiple energy waveforms during the operation of the cipher algorithm as a test set, and input the trained neural network; At this time, the block cipher algorithm used is still the AES algorithm, and device B encrypts a plaintext using an unknown key; Still select the first two S1 and S2 in the first round, and obtain the corresponding waveform images to form a test set.

[0044] Step 5: Distinguish each waveform in the test set as a collision-type waveform. If more than a preset proportion of waveforms in the test set are determined to be collisions, it is considered that a collision has occurred between S1 and S2 during the current plaintext encryption process; otherwise, it is considered that no collision has occurred between S1 and S2.

[0045] In this step, a preset threshold ratio can be selected as a basis for determining whether a collision occurs between the two S boxes S1 and S2; for example, 50% can be selected as the preset threshold ratio, that is, if more than 50% of the waveforms in the test set are judged to be collisions, it is considered that a collision has occurred between S1 and S2 in the first round of the current plaintext encryption process; otherwise, it is considered that no collision has occurred between S1 and S2.

[0046] When the detection result between S1 and S2 is that no collision occurs, we can also replace the plaintext to be encrypted by device B with other plaintexts, and repeat steps 4-5 until a collision is detected.

[0047] Based on the collision results, we can further establish the mathematical relationship between the output value of S1 and the output value of S2, and then establish the mathematical relationship between the key corresponding to S1 and the key corresponding to S2, thereby reducing the key search space of the AES algorithm.

[0048] Step 6: Focus on other S-box pairs (such as S1 and S3, S1 and S4, S1 and S5...), repeat steps 1-5, find the collision relationship between other S-box pairs, and continue to reduce the key search space until the key search space is reduced to a practical searchable range (such as 2 to the 8th power), and then test the block cipher algorithm through exhaustive search.

[0049] Focus on other S-box pairs (such as S1 and S3, S1 and S4, S1 and S5...), repeat steps 1-4, find the collision relationship between other S-box pairs, and continue to reduce the key search space until the key search space is reduced to a practical searchable range (such as 2 to the 8th power), and then you can crack the block cipher algorithm through exhaustive search.

[0050] The present invention also proposes a block cipher side channel collision test device based on a neural network, characterized in that the device comprises:

[0051] The waveform acquisition module is used to select the block cipher algorithm to be tested and the two S1 and S2 that can be used for training; the block cipher algorithm to be tested is run through device A with a known key, a plurality of different plaintexts are encrypted, and the energy waveform during the operation is collected;

[0052] A training set generation module, used for detecting the energy waveform and classifying the energy waveform into two categories of collision and non-collision as a training set according to the detection result;

[0053] A neural network training module, used for training a neural network based on the classified waveforms in the training set to obtain a trained neural network;

[0054] A test data acquisition module, used for encrypting a plain text by the block cipher algorithm using the device B with an unknown key, collecting the energy waveform during the operation of the cipher algorithm as a test set; and inputting the test set into the trained neural network;

[0055] The collision result detection module is used to distinguish whether each waveform in the test set belongs to a collision type waveform. If the waveform in the test set exceeding the preset ratio threshold is determined to be a collision, it is considered that a collision has occurred between S1 and S2 during the current plaintext encryption process; otherwise, it is considered that no collision has occurred between S1 and S2.

[0056] Through the above method, we use a neural network to perform a block cipher side channel collision test method, using the method of the present invention. Compared with the existing side channel collision test method, the method of the present invention has the following advantages:

[0057] 1. There is no need to select the leak point precisely.

[0058] In classic side channel testing, collision testing generally requires first accurately identifying the part of the waveform that corresponds to the intermediate value where the collision occurred. With the use of neural networks, there is no need to select key points very accurately. If several irrelevant points are included, the neural network will automatically reduce the weight of these points or reduce them to zero.

[0059] 2. The waveforms do not need to be perfectly aligned.

[0060] Traditional side channel testing has difficulty solving the problem of waveform misalignment, because waveform misalignment will lead to insufficient concentration of information at a single point, making it difficult to obtain good results when doing statistical analysis. However, neural networks can overcome this problem. During the training phase, various samples with misaligned waveforms can be generated for training, so that the neural network has the ability to identify misaligned samples. During the test phase, when misaligned waveforms are input, the neural network can also successfully identify them.

[0061] 3. Compared with the traditional collision detection method, this method greatly improves the accuracy and stability, and is easy to implement. When using the traditional method to detect collisions, when the signal-to-noise ratio is too small, the detection accuracy will be greatly reduced, and the neural network can overcome this problem. In the training stage, various samples with small signal-to-noise ratios can be generated for training, so that the neural network has the ability to identify samples with large noise. In the test stage, when a waveform with large noise is input, the neural network can also identify the correct result. And once the neural network is trained and perfected, the subsequent implementation difficulty is greatly reduced, and it is very easy to implement. Through the description of the above implementation method, the technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0062] In the several embodiments provided in the embodiments of the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0063] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0064] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0065] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks or optical disks.

[0066] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A block cipher side channel collision test method based on neural network, characterized in that: The following steps are involved: Step 1: Select the block cipher algorithm to be tested and two S-boxes that can be used for training, namely S1 and S2; use the known key to run the block cipher algorithm to be tested through device A, encrypt multiple different plaintexts, and collect the energy waveform during the operation; Step 2: Detect the energy waveform, and according to the detection result, classify the energy waveform into two categories: collision and non-collision as a training set; Step 3: training a neural network based on the classified energy waveforms in the training set to obtain a trained neural network; Step 4: Device B using an unknown key encrypts a plaintext using the block cipher algorithm, and collects energy waveforms during the operation of the cipher algorithm as a test set; Inputting the test set into the trained neural network; Step 5: Determine whether each energy waveform in the test set belongs to a collision-type waveform. If the energy waveform in the test set that exceeds the preset ratio threshold is determined to be a collision-type waveform, it is considered that a collision has occurred between the S-box S1 and the S2 during the current plaintext encryption process; otherwise, it is considered that no collision has occurred between the S-box S1 and the S2.

2. The method for side channel collision testing of block ciphers based on neural network according to claim 1, characterized in that: Detecting the energy waveform in step 2 includes: whether the output values ​​of S1 and S2 calculated based on the known plaintext and the key are equal; if the output values ​​are equal, the energy waveform is considered to be a collision type; or if the output values ​​are not equal, the energy waveform is considered to be a non-collision type.

3. The method for side channel collision testing of block ciphers based on neural network according to claim 1, characterized in that: Step 5 further includes: if S1 and S2 do not collide, then the plaintext to be encrypted of device B is replaced with other plaintext, and steps 4-5 are repeated until a collision is detected between S1 and S2.

4. The method for side channel collision testing of block ciphers based on neural network according to claim 1, characterized in that: In step 1, the block cipher algorithm to be tested is selected as the AES algorithm; the two S1 and S2 that can be used for training are the two S boxes used in the first round of the AES algorithm.

5. The method for side channel collision testing of block ciphers based on neural network according to claim 1, characterized in that: The method further includes: when a collision occurs between S1 and S2 in the S box, a sequence between an output value of S1 and an output value of S2 is established, thereby establishing a digital association between a key corresponding to S1 and a key corresponding to S2.

6. The method for side channel collision testing of block ciphers based on neural network according to claim 1, characterized in that The method further includes: selecting other S-box combinations, repeating steps 1 to 5, and further detecting whether there is a collision between the S-boxes.

7. The neural network-based block cipher side channel collision testing method according to claim 1, wherein the threshold of the preset ratio is 50%.

8. A block cipher side channel collision test device based on neural network, characterized in that: The device comprises: The waveform acquisition module is used to select the block cipher algorithm to be tested and two S-boxes S1 and S2 that can be used for training; the block cipher algorithm to be tested is run through device A with a known key to encrypt multiple different plaintexts, and the energy waveform during the operation is collected; A training set generation module, used for detecting the energy waveform and classifying the energy waveform into two categories of collision and non-collision as a training set according to the detection result; A neural network training module, used for training a neural network based on the classified energy waveforms in the training set to obtain a trained neural network; A test data acquisition module, used for encrypting a plain text by the block cipher algorithm using the device B with an unknown key, collecting the energy waveform during the operation of the cipher algorithm as a test set; and inputting the test set into the trained neural network; The collision result detection module is used to determine whether each energy waveform in the test set belongs to a collision-type waveform. If the energy waveform in the test set that exceeds a preset ratio threshold is determined to be a collision-type waveform, it is considered that a collision has occurred between S1 and S2 during the current plaintext encryption process; otherwise, it is considered that no collision has occurred between S1 and S2.

Citation Information

Patent Citations

  • Algorithm recovering method and system based on side channel leakage

    CN105281889A

  • Construction method of side channel attack model, password attack equipment and computer storage medium

    CN112787971A

  • Collision condition predicting system by neural network

    JP1994092199A

  • KR20190064063A