The following describes the implementation of the present invention through specific specific examples. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only illustrative to illustrate the basic concept of the present invention. In the case of no conflict, the following embodiments and the features in the embodiments can be combined with each other.
The embodiment of the present invention performs simulation experiments on a computer with 8.0G memory, 64-bit operating system, Intel(R)CORE(TM)i5-8500, and 3.00GHz processor. The size of the lena graph used by the encryption object is 255×255. Standard lena diagram.
SeeFigure 1~Figure 8 ,figure 1 It is an encryption and decryption method based on physical layer protocol data extraction random number to disturb the characteristic value of physical parameter, such asfigure 1 As shown, the specific encryption and decryption process includes the following steps:
In the first step, after successfully identifying the QRS complex with the characteristic value of the ECG signal, mark the amplitude of the R wave as Ramp , The interval between adjacent QS waves is TQS , Calculate the characteristic value of the electrical signal of the snack, and the corresponding average value of the ECG signal within 4 seconds is the characteristic value of the physical parameter of the ECG signal at that moment PQ. The calculation formula of the characteristic parameter of the ECG signal is:
Among them, n represents the sampling point of the ECG signal.
The second step is to extract random numbers from the physical layer protocol data after the preamble sequence is synchronized, and use the random numbers to generate a disturbance vector as a key parameter to participate in key generation. Key parameter Kpara The calculation formula is:
Among them, d(t) represents the random number of physical layer protocol data generated at time t.
In the third step, in each cycle, the key parameter is subjected to an iteration of Δ≥1 to perturb the characteristic value of the physical parameter to generate a key to generate a key stream Ki. KiThe calculation formula is:
Among them, PQ'(t) is the characteristic value of the physical parameter.
The fourth step, clear text flow Ipi Pass the key K in the key streamiEncryption to generate ciphertext stream Ici , And send to the receiving end through the sending node. The encryption process is:
In the fifth step, the coarse synchronization in the preamble sequence synchronization algorithm is realized by the packet detection algorithm based on the preamble sequence. For the BAN system, its physical layer frame structure is unique, and the autocorrelation function of its m sequence is only There are two values 1 and -1. Therefore, the preamble sequence can be used to estimate the starting position of the data frame, and an appropriate digital matched filter can be designed to calculate the correlation peak value of the input data as the estimated decision threshold.
Where SEr, SEyIt is the square envelope, the specific calculation formula is:
The sixth step, the receiving end receives the ciphertext stream Ici Then, the physical layer protocol data obtained after the preamble sequence synchronization is used to generate a key parameter pair to generate a key pair ciphertext stream Ici Decrypt to get the plaintext stream Ipi.
In the seventh step, when the receiving node fails to decrypt due to the asynchronous key, it will request the data packet again from the sending node. When the sending node receives three consecutive wrong requests for the same data packet, the sending node will re-encrypt the data using the initial key agreed by both parties and resend the data packet to the receiving node. The specific steps are as follows:
Step1: The two parties agree to use the last two digits of the third error request of the receiving node as the bit exchange mode selection, where "00" and "01" represent mode 1, "10" represents mode 2, and "11" represents mode 3. ;
Step2: Both parties agree to use the initial key Kini;
Step3: The two parties agree to use the first 2 bytes of the first frame of the MAC Frame Body after the MAC Frame Body is synchronized as the PRini , And select the bit exchange mode in Step1 to generate the key parameter pair Kini Perform perturbation to generate key stream KiAnd encrypt and send the data;
Step4: The receiving node uses the initial key K agreed by both parties for the received data packetini Generate a new key stream K with the random number generation key parameter of the synchronized physical layer protocol dataiDecrypt the data and record the characteristic value of the physical parameters as PQini To complete the key synchronization.
This experiment analyzes the encryption method through three aspects. On the one hand, it analyzes the correlation between adjacent pixels. The correlation between adjacent pixels reflects the degree of correlation between the pixel values of adjacent positions in the image. A good image encryption method should be able to reduce adjacent pixels. Pixel correlation is as close as possible to zero correlation. Here, adjacent elements including pixels in the horizontal and vertical directions and diagonal directions in the image are used as the research object. The formula for calculating the correlation of adjacent elements is:
Where XiAnd YiRepresents the gray value of two adjacent pixels, and N is the number of pixels.
The correlation comparison of adjacent pixels before and after Lena image encryption is shown in Table 1.
Table 1 Comparison of the correlation between adjacent pixels before and after Lena image encryption
 Correlation coefficient Horizontal Vertical Diagonal The original image 0.9388 0.9633 0.9417 This algorithm is encrypted 0.0004 -0.0002 0.0079
It can be seen from the experimental results that the correlation between the three directions of the original image exceeds 0.9, but after encryption they are reduced to less than 0.01. The results show that the correlation between the pixels of the encrypted image in the three directions has changed greatly. The reduction of the coefficient means that the correlation of the pixels in the original image is severely damaged, and the placement effect of the pixels is more obvious. The relatively small correlation in the result means that the encryption algorithm can better resist analysis attacks.
On the other hand, by directly observing the results before and after encryption, it is not intuitively possible to distinguish the associated information with the original image, and it is impossible to accurately judge the encryption quality. The image pixel position can be visually hidden and the original image information can also be hidden. The result of this makes it indistinguishable, but disorganizing the pixel position does not change the pixel gray value of the image itself. Encryption result through gray histogramFigure 7 Calculation.Figure 8 The gray histograms of the original image and the encrypted image are given.
by comparisonFigure 7 withFigure 8 As a result, the analysis can find that the gray value and distribution of the image before and after encryption have changed greatly. The gray value of the encrypted image presents a better uniform distribution, no obvious feature value is retained, and the pixel value and quantity are more evenly distributed, achieving the target effect.
On the last aspect, differential attack is a relatively common attack method in image encryption algorithms. The attacker makes very small changes to the original image, and then uses the algorithm to encrypt the original image and the changed image separately. By comparing the two Analyze the relationship between the original image and the changed image to decrypt the image encryption algorithm. In order to deal with this attack, the encryption algorithm must have strong resistance to differential attacks, that is, when a certain pixel of the original image is changed, the encrypted image obtained will change in an unpredictable way. The more sensitive the algorithm is to the plaintext, the stronger the ability to resist differential attacks. The pixel change rate (NPCR) and the normalized pixel value (UACI) average change intensity can be used to measure the sensitivity of the algorithm to the plaintext image.
The number of pixel change rates (NPCR) is defined as:
Among them, D(i,j) is the gray value difference between the original and encrypted image in the pixel (i,j).
The number of normalized pixel values (UACI) is defined as:
Where C1(i,j) and C2(i, j) respectively represent the gray value of the original image and the encrypted image in the pixel (i, j).
For an n-bit grayscale image, the expected values of NPCR and UACI can be calculated by the above formulas for calculating the pixel change rate (NPCR) and the number of normalized pixel values (UACI):
When n=8, uNPCR And uUACI They are 99.6094% and 33.4635% respectively. The comparison between the algorithm of the present invention and the theoretical value is shown in Table 2.
Table 2 Comparison table of pixel change rate and normalized pixel value
Calculating the pixel change rate and the normalized pixel value of the encryption result obtained by using the algorithm of the present invention, NPCR and UACI are 99.6066% and 33.5245%, respectively. The expected deviations from the comparison theory are 0.028 and 0.061 respectively. The results show that the pixel change rate and the normalized pixel value of the encryption result using the algorithm of the present invention are very close to the ideal value, which shows that the algorithm is very sensitive to plaintext images and has strong resistance to differential attacks.
The algorithm in the present invention solves the security problem caused by the leakage of the shared key transmission in the symmetric encryption algorithm and the high-complex calculation problem caused by the public and private keys in the asymmetric encryption algorithm, and uses relatively few operations in the symmetric encryption algorithm. Realize lightweight security encryption to ensure the low-power and secure transmission of data between network nodes.
 Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be implemented Modifications or equivalent replacements without departing from the purpose and scope of the technical solution should be covered by the scope of the claims of the present invention.