Application layer data encryption method and system based on SM4 algorithm and digest verification
By analyzing the information repetition, semantic correlation and sensitivity of plaintext blocks, dynamically adjusting the control parameters of the Logistic chaotic mapping algorithm, combined with SM4 algorithm and digital digest verification, the problem of poor encryption effect of traditional SM4 algorithms in the face of differential attacks and high repetitive plaintext blocks is solved, and data security and integrity are improved.
Patent Information
- Application Number
- CN202510846940.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-06-24
AI Technical Summary
Traditional SM4 algorithms have the risk of data leakage when facing differential attacks, linear attacks and side channel analysis. Especially in the ECB encryption mode, high-repetitive plaintext blocks generate the same ciphertext blocks, and lack dynamic adaptability to data correlation and sensitive information in the plaintext blocks, resulting in poor encryption effects.
By analyzing the information repetition, semantic correlation and information sensitivity in the plaintext block, dynamically adjusting the control parameters of the Logistic chaotic mapping algorithm, encrypting it with the SM4 algorithm, and using the digital digest to verify the integrity of the ciphertext data to generate dynamic S-box and wheel keys.
It enhances the attack resistance of plaintext blocks, reduces the risk of mode leakage in ECB mode, improves the encryption effect of application-level data, and ensures the integrity and security of data transmission through digital digest verification.
Smart Images

Figure CN120378087B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data encryption technology, and in particular to an application layer data encryption method and system based on the SM4 algorithm and digest verification. Background Art
[0002] With the rapid development of information technology, the importance of data encryption in ensuring information security has become increasingly prominent. As a block cipher, the SM4 algorithm has gained widespread application in application-layer data encryption. However, the traditional SM4 algorithm has certain limitations. The S-box and round key generation are based on a fixed mathematical structure, making it vulnerable to attacks such as differential attacks, linear attacks, and side-channel analysis. In particular, in ECB encryption mode, when application-layer data exhibits high repetitiveness, the ciphertext blocks generated from the same plaintext block are highly similar. Attackers can infer the plaintext content through ciphertext statistical characteristics, posing a serious threat to data security. Furthermore, the traditional SM4 algorithm lacks the ability to dynamically adapt to data correlation and sensitive information within plaintext blocks. Because data within different plaintext blocks has different characteristics, traditional encryption methods often employ a unified encryption strategy and strength, making it difficult to adjust the encryption complexity and strength based on the characteristics of the data within each plaintext block. This results in poor encryption effectiveness for application-layer data. Summary of the Invention
[0003] In order to solve the above technical problems, an application layer data encryption method and system based on SM4 algorithm and digest verification are provided to solve the existing problems.
[0004] The solution to the technical problem of this application is to provide an application layer data encryption method and system based on the SM4 algorithm and digest verification, including the following steps:
[0005] In a first aspect, an embodiment of the present application provides an application layer data encryption method based on the SM4 algorithm and digest verification, the method comprising the following steps:
[0006] Obtain the text data to be encrypted in the application layer; divide the text data into multiple plaintext blocks, perform word segmentation on each plaintext block, and obtain each word;
[0007] Analyze the number of characters between two consecutive occurrences of each word in each plaintext block, as well as the correlation between the two consecutive occurrences and the adjacent words, and calculate the information repetition of each plaintext block based on the number of times each word appears in the text data;
[0008] The semantic relevance of each plaintext block is obtained by the co-occurrence of each word and its adjacent words in the text data, as well as the number of sentences contained in each plaintext block.
[0009] Determine the information sensitivity of each plaintext block based on the numbers contained in each plaintext block and the correlation between each word and the preset sensitive words;
[0010] Based on information repetition, semantic relevance and information sensitivity, an adjustment coefficient for each plaintext block is determined; based on the adjustment coefficient, the control parameters of the chaotic mapping algorithm are adjusted to obtain the adjusted control parameters corresponding to each plaintext block. The chaotic mapping algorithm and the SM4 algorithm are combined to encrypt each plaintext block to obtain ciphertext data. The integrity of the ciphertext data during the communication transmission process is verified through digital summary technology.
[0011] Preferably, dividing the text data into a plurality of plaintext blocks includes: encoding the text data, obtaining a byte sequence corresponding to the text data, and dividing the text data into a plurality of plaintext blocks according to the byte sequence.
[0012] Preferably, the calculating of the information duplication of each plaintext block includes:
[0013] Calculate the distance between each occurrence of each word in the text data and the next occurrence within each plaintext block;
[0014] Convert each word in each plaintext block into a word vector when it appears in the text data together with the adjacent words;
[0015] Calculate the correlation between the word vectors of each word in each plaintext block and the next occurrence in the text data, which is recorded as the first correlation;
[0016] Count the frequency of each word in each plaintext block in the text data;
[0017] The information repetition degree is the sum of the product of the frequency, the interval distance and the first correlation of all words in each plaintext block.
[0018] Preferably, obtaining the semantic relevance of each plaintext block includes:
[0019] The words adjacent to the position of each word in the text data in each plaintext block are recorded as neighboring words;
[0020] Selecting the maximum value between the frequency of each word in each plaintext block and the frequency of the adjacent words, and recording it as the highest frequency;
[0021] Counting the number of times each word in each plaintext block and the phrase consisting of the adjacent words co-occur in the text data, which is recorded as the number of co-occurrences;
[0022] Calculating the cumulative sum of the ratios of the co-occurrence counts of all words in each plaintext block to the maximum count; and counting the number of sentences contained in each plaintext block;
[0023] The semantic relevance is the ratio of the cumulative sum to the number of sentences.
[0024] Preferably, determining the information sensitivity of each plaintext block includes:
[0025] Extract all digital groups from text data; based on prior knowledge, pre-build a preset specific format digital library and a preset sensitive word library;
[0026] Calculate the minimum value of the difference between the number of digits of each digit group and the number of digits of all specific types in the digit library of the specific format;
[0027] Calculate the maximum value of the correlation between the word vector of each word in each plaintext block and the word vector of all sensitive words in the sensitive word library, and record it as the second correlation;
[0028] The sum of the second relevance of all words in each plaintext block is recorded as a first sensitivity value;
[0029] If there is a number in each plaintext block, the number group to which the number belongs is obtained, and the result of negative mapping the minimum value of the corresponding number group is used as the second sensitive value of each plaintext block; if there is no number group in each plaintext block, the second sensitive value of each plaintext block is 0;
[0030] The sum of the first sensitivity value and the second sensitivity value is used as the information sensitivity of each plaintext block.
[0031] Preferably, the adjustment coefficient is a normalized result of the product of the information repetition, the semantic relevance and the information sensitivity.
[0032] Preferably, Plaintext blocks correspond to the adjusted control parameters The calculation formula is: ,in, To preset the initial control parameters, is the preset limiting factor, For the The adjustment factor for plaintext blocks, To preset the first value, The preset second value is a value that is smaller than the preset second value.
[0033] Preferably, the obtaining of ciphertext data includes: encrypting each plaintext block based on the adjusted control parameters corresponding to each plaintext block in combination with the chaotic mapping algorithm and the SM4 algorithm, outputting the ciphertext block corresponding to each plaintext block, and splicing the ciphertext blocks of all plaintext blocks corresponding to the text data to obtain ciphertext data.
[0034] Preferably, the integrity of the ciphertext data during the communication transmission process is verified, including: generating a digital summary of the ciphertext data through digital summary technology, the sending end transmitting the generated digital summary together with the ciphertext data, and the receiving end decrypting the ciphertext data and regenerating the digital summary after receiving the ciphertext data, and comparing the newly generated digital summary with the original digital summary to determine the integrity of the ciphertext data.
[0035] In the second aspect, an embodiment of the present application also provides an application layer data encryption system based on the SM4 algorithm and digest verification, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any one of the above-mentioned application layer data encryption methods based on the SM4 algorithm and digest verification.
[0036] This application has at least the following beneficial effects:
[0037] This application calculates the information duplication of each plaintext block by analyzing the repetition of words in the text data in each plaintext block. Its beneficial effect is that it takes into account the similarity between the text information contained in each plaintext block and the text information contained in other plaintext blocks, so as to reflect the possibility that multiple plaintext blocks may generate the same ciphertext block or the similarity of the generated ciphertext blocks, so as to assess the risk of the plaintext block being leaked, and thus the more likely it is to need to strengthen the encryption complexity; secondly, it analyzes the association between adjacent words in each plaintext block each time they appear, and calculates the semantic association of each plaintext block. Its beneficial effect is that it takes into account the plaintext The correlation between words in a block reflects the risk that the plaintext block can be inferred and cracked; further, the digital information or sensitive words contained in each plaintext block are analyzed, and the information sensitivity of each plaintext block is calculated. Its beneficial effect is that it takes into account the sensitivity of the information in the plaintext block, reflects the importance of the information contained in the plaintext block, and evaluates the degree of protection that the plaintext block should require; the adjustment coefficient of each plaintext block is determined, and its beneficial effect is that it evaluates the Logitech encryption algorithm introduced to improve the encryption complexity of the plaintext block by comprehensively considering the repetitiveness, word correlation and sensitivity of each plaintext block. The control parameters of the stic chaotic mapping algorithm are adjusted to avoid multiple plaintext blocks with high repetitiveness from generating similar ciphertexts, reduce the risk of pattern leakage in the ECB mode, weaken the possibility of attackers using context association to crack the key, and enhance the encryption strength of plaintext blocks containing sensitive information; the adjusted control parameters corresponding to each plaintext block are obtained, and each plaintext block is encrypted by combining the Logistic chaotic mapping algorithm and the SM4 algorithm to obtain ciphertext data. Its beneficial effect is that the S-box and round key are dynamically generated by the Logistic chaotic mapping algorithm through the control parameters corresponding to different plaintext blocks, breaking the static mode of the traditional SM4 algorithm that fixes the S-box and key, and then the dynamically generated S-box and round key are encrypted by the SM4 algorithm for each plaintext block, thereby enhancing the anti-attack capability of the plaintext block, reducing the risk of plaintext block leakage, and improving the encryption effect of application layer data; the integrity of the ciphertext data during the communication transmission process is verified through the digital summary technology. Its beneficial effect is that the integrity of the text data of the application layer during the communication transmission process is verified, the possibility of tampering attack on the text data is evaluated, and the security and integrity of data protection are ensured. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The following is a detailed description of the application layer data encryption method based on the SM4 algorithm and digest verification of the present application in conjunction with the accompanying drawings.
[0039] Figure 1 A flowchart of the steps of the application layer data encryption method based on the SM4 algorithm and digest verification provided in an embodiment of the present application;
[0040] Figure 2A flowchart of the steps of the method for obtaining the information duplication degree of each plaintext block provided in an embodiment of the present application;
[0041] Figure 3 A flowchart of the steps of the method for obtaining ciphertext data provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] To make the objectives, technical solutions, and advantages of this application more clearly understood, the following, in conjunction with the accompanying drawings and implementation examples, further describes in detail the application-layer data encryption method and system based on the SM4 algorithm and digest authentication proposed in this application. It should be understood that the specific embodiments described herein are merely for the purpose of explaining this application and are not intended to limit this application.
[0043] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
[0044] See also Figure 1 , which shows a flowchart of the steps of an application layer data encryption method based on the SM4 algorithm and digest authentication provided by an embodiment of the present application, the method comprising the following steps:
[0045] Step 1: Obtain the text data to be encrypted in the application layer.
[0046] The application layer, located at the top of the network protocol stack, serves as the interface between users or applications and the network. It implements data formatting, encryption, and transmission through standardized protocols. In computer communications, application layer data is the business data directly addressed to users or applications, processed by the highest layer of network communications. This data represents the actual information that users or applications need to transmit, such as web page content, file content, and message text. Therefore, the text data to be encrypted is obtained from the application layer.
[0047] At this point, the text data to be encrypted in the application layer is obtained.
[0048] Step 2: Divide the text data into multiple plaintext blocks, perform word segmentation on each plaintext block, and obtain each vocabulary; analyze the number of characters between two adjacent appearances of each vocabulary in each plaintext block in the text data, as well as the correlation between the two adjacent appearances and the adjacent vocabulary, and calculate the information repetition of each plaintext block based on the number of times each vocabulary appears in the text data.
[0049] As a block cipher, the SM4 algorithm's security relies heavily on the nonlinear properties of its S-boxes and the strength of its key expansion algorithm. Traditional S-boxes and key generation are typically based on fixed mathematical structures, exposing them to targeted attacks such as differential and linear attacks. Furthermore, the S-boxes and round keys of the traditional SM4 algorithm are static or semi-static, making them vulnerable to attackers through long-term observation or side-channel analysis. The Logistic Chaos Map algorithm, a chaotic search method, is attracting significant attention for its application in secure communications because the chaotic sequences it generates exhibit a higher degree of arbitrariness, exhibit initial value sensitivity, pseudo-randomness, and ergodicity. Dynamically generating S-boxes or round keys through chaotic mapping significantly increases the nonlinearity of the SM4 algorithm, reducing the vulnerability of data to attacks and cracking.
[0050] The control parameters of the Logistic Chaotic Mapping algorithm will affect the encryption security of the SM4 algorithm. If the control parameters are not selected properly, the ciphertext encrypted by the SM4 algorithm may leak statistical characteristics, increasing the risk of differential or linear attacks. Therefore, it is necessary to select reasonable control parameters, dynamically generate S-boxes or round keys, and then encrypt the text through the SM4 algorithm. Among them, the SM4 algorithm is a block cipher algorithm. Therefore, before encrypting the text data, the text data to be encrypted needs to be divided into blocks, specifically:
[0051] Encode the text data to obtain the byte sequence corresponding to the text data, and divide the text data into multiple plaintext blocks according to the byte sequence;
[0052] In this embodiment, GBK encoding is used to encode text data, wherein GBK encoding is a well-known technology and will not be described in detail here. As other implementation methods, implementers can adopt other methods of existing technologies, such as Unicode encoding, ASCII encoding, etc. This embodiment does not impose any special restrictions on this.
[0053] It should be noted that when using the SM4 algorithm for encryption, the size of a plaintext block is 128 bits, that is, 16 bytes. After GBK encoding, a Chinese character and Chinese punctuation mark each occupy 2 bytes, and English punctuation marks, English letters and numbers each occupy 1 byte. Therefore, the text data is divided into multiple plaintext blocks according to the number of bytes that each plaintext block can accommodate; if the number of bytes of the characters contained in the plaintext block is less than 16 bytes, the PKCS7 padding method is used to fill the plaintext block. Among them, the PKCS7 padding method is a well-known technology and will not be repeated here.
[0054] Perform word segmentation on the text fragments contained in each plaintext block to obtain each vocabulary;
[0055] In this embodiment, the N-gram model is used for word segmentation processing, wherein the N-gram model is a well-known technology and will not be described in detail here. As other implementation methods, the implementer can adopt other methods of the existing technology, such as Jieba word segmentation, etc. This embodiment does not impose any special restrictions on this.
[0056] Secondly, the text data to be encrypted contains multiple sentences. After the plaintext blocks are divided, the text fragments contained in each plaintext block may exist in different sentences, and the characters in the same sentence may also exist in different plaintext blocks. By analyzing the distribution of the words contained in each plaintext block in the original text data, the information repetition is calculated. The step flow chart of the method for obtaining the information repetition of each plaintext block provided in the embodiment of the present application is as follows Figure 2 As shown, specifically:
[0057] Count the frequency of each word in each plaintext block in the text data;
[0058] Calculate the distance between each occurrence of each word in the text data and the next occurrence within each plaintext block;
[0059] Convert each word in each plaintext block into a word vector when it appears in the text data together with the adjacent words;
[0060] In this embodiment, the Word2Vec model is used to obtain word vectors, wherein the Word2Vec model is a well-known technology and will not be described in detail here. As other implementation methods, implementers can adopt other methods of existing technologies, such as the BERT algorithm, etc. This embodiment does not impose any special restrictions on this.
[0061] It should be noted that, for ease of understanding, assume that there are two sentences in a piece of text data: "I love historical ancient poetry, ancient poetry is very artistic. I love programming, programming is very interesting". Assume that the first plaintext block contains the text fragment "I love historical ancient poetry", with 7 characters and 1 Chinese punctuation mark, totaling 16 bytes; secondly, after word segmentation processing, it is: ["I", "love", "history", "ancient poetry"], for the word "love", the first time it appears in the text data is "I love history", and the second time it appears in "I love programming", then the number of characters between the two appearances of the word "love" in the text data is 14, and the number of punctuation marks is 2, so the interval distance is 16; the first time the word "love" appears and the adjacent words form a phrase "I love history", and the second time the word "love" appears and the adjacent words form a phrase "I love programming", and the phrases formed by the word "love" and the adjacent words are converted into word vectors through the Word2Vec model.
[0062] Calculate the correlation between the word vectors of each word in each plaintext block and the next occurrence in the text data, which is recorded as the first correlation;
[0063] In this embodiment, the degree of correlation is calculated by calculating the cosine similarity of the word vectors between each occurrence and the next occurrence of each word in each plaintext block in the text data, wherein the calculation of cosine similarity is a well-known technology and will not be repeated here. As other implementation methods, implementers can adopt other methods of the existing technology, such as the Pearson correlation coefficient, etc., and this embodiment does not impose any special restrictions on this.
[0064] The sum of the products of the frequencies, the interval distances, and the first relevance of all words in each plaintext block is used as the information repetition degree of each plaintext block;
[0065] It should be noted that, the greater the frequency, the more frequently the word appears in the text data, and the greater the possibility that the word is key information in the text data; the greater the interval distance, the more likely the word is divided into different plaintext blocks, and different plaintext blocks may contain the word information; the greater the first correlation, the greater the consistency of the meaning contained in each appearance of the word in the text data, that is, the greater the possibility of consistency of information contained in different plaintext blocks; the greater the repetition of the obtained information, the higher the frequency of repeated appearance of the text fragment information contained in the plaintext block in the text data, and the more likely that other plaintext blocks also contain the same text information. When the SM4 algorithm is used for subsequent encryption, multiple plaintext blocks are more likely to generate the same ciphertext block or the generated ciphertext blocks are more similar, resulting in poor encryption effect on the text data and easier to be cracked by attackers. Therefore, it is necessary to increase the control parameters of the Logistic Chaotic Mapping Algorithm to generate a more complex chaotic sequence to improve the subsequent encryption effect and thus enhance the anti-attack capability.
[0066] At this point, the information duplication of each plaintext block is obtained.
[0067] Step 3: Obtain the semantic relevance of each plaintext block by analyzing the co-occurrence of each word and its adjacent words in each plaintext block in the text data, as well as the number of sentences contained in each plaintext block.
[0068] Furthermore, since each plaintext block contains relatively little information, the number of bytes corresponding to the entire sentence in the text data is generally larger than the number of bytes that can be contained in a plaintext block. For example, for a piece of text data "User number 456789 please keep it safe, password is qwer1234, do not disclose. User number 123456's password has been reset", there are two sentences. The first plaintext block is "User number 456789 please keep it safe, password is", the third plaintext block is "qwer1234, do not disclose", the fourth plaintext block is "disclose. User number 123456's password has been reset". Therefore, the first plaintext block contains part of the information in the sentence "User number 456789 please keep it safe, password is qwer1234, do not disclose", and the fourth plaintext block contains part of the content of both sentences. Therefore, for the content in the same sentence, since the entire sentence has the characteristics of semantic coherence, the lexical information at different positions in the sentence is related. When the attacker cracks the key, the correlation between the information contained in the words can be used to assist in cracking.
[0069] Based on the above analysis, the semantic relevance is calculated by analyzing the association between different words in each plaintext block, specifically:
[0070] The words adjacent to the position of each word in the text data in each plaintext block are recorded as neighboring words;
[0071] Selecting the maximum value between the frequency of each word in each plaintext block and the frequency of the adjacent words, and recording it as the highest frequency;
[0072] Counting the number of times each word in each plaintext block and the phrase consisting of the adjacent words co-occur in the text data, which is recorded as the number of co-occurrences;
[0073] It should be noted that, for ease of understanding, for the word "user", the adjacent word of the word "user" is "number", and the phrase "user number" consisting of the two words appears twice in the text data.
[0074] Count the number of statements contained in each plaintext block;
[0075] It should be noted that a sentence usually ends with a period, question mark, and exclamation mark. Therefore, the positions of the periods, question marks, and exclamation marks in the plaintext block can be counted to obtain the number of sentences contained in each plaintext block.
[0076] Calculating a cumulative sum of ratios of the co-occurrence counts of all words in each plaintext block to the highest co-occurrence count, and using the ratio of the cumulative sum to the number of sentences as the semantic relevance of each plaintext block;
[0077] It should be noted that, the greater the ratio of the number of co-occurrences to the maximum number of times, the more times the two words appear together, and the stronger the correlation between the two words. The greater the number of sentences, the more sentences are contained in the plaintext block, the more complex the semantic structure, the more dispersed the semantic correlation may be, and the correlation between words is relatively low. The greater the obtained semantic correlation, the stronger the semantic correlation between the words contained in the plaintext block, and the easier it is for attackers to use these correlations to crack the key. Therefore, it is more necessary to increase the control parameters of the Logistic chaotic mapping algorithm and generate more complex chaotic sequences to improve the subsequent encryption effect and thus enhance the anti-attack capability.
[0078] At this point, the semantic relevance of each plaintext block is obtained.
[0079] Step 4: Determine the information sensitivity of each plaintext block based on the numbers contained in each plaintext block and the correlation between each word and the preset sensitive words.
[0080] Secondly, if the text data to be encrypted contains digital information, the text containing digital information is more sensitive than the pure log text. Secondly, the text data may also contain sensitive words, such as numbers, account credentials, passwords, etc. These sensitive information require a higher level of protection. Therefore, by analyzing the sensitivity of the word information in each plaintext block and the presence of digital information, the information sensitivity is calculated, specifically:
[0081] Extract all groups of numbers in text data;
[0082] In this embodiment, a regular expression is used to extract the number group in the text data, wherein the regular expression is a well-known technology and will not be described in detail here.
[0083] Based on prior knowledge, a preset specific format digital library and a preset sensitive word library are pre-built;
[0084] It should be noted that the structural characteristics of sensitive numbers are defined based on prior knowledge, and each specific type of digital structure is defined in the specific format digital library. For example, the fixed length of a password is 8 digits, the fixed length of a user number is 6 digits, the fixed length of an ID number is 18 digits, the fixed length of a mobile phone number is 11 digits, and the fixed length of a verification code is 6 digits, etc.; secondly, multiple sensitive words are collected, such as password, number, leakage, payment, card number, amount, address, etc., to construct a sensitive word library.
[0085] Calculate the minimum value of the difference between the number of digits of each digit group and the number of digits of all specific types in the digit library of the specific format;
[0086] In this embodiment, the minimum value of the absolute value of the difference between the number of digits of each digit group and the number of digits of all specific types in the digit format structure library is calculated.
[0087] It should be noted that, for example, for a piece of text data "Please keep the user number 456789 safe, the password is qwer1234, do not disclose it. The password of user number 123456 has been reset", the number of digits in a number group "qwer1234" is 8, and the fixed length of the password in the specific format number library is 8 digits. The difference between the two digits is the smallest, and the minimum value is 0.
[0088] Calculate the maximum value of the correlation between the word vector of each word in each plaintext block and the word vector of all sensitive words in the sensitive word library, and record it as the second correlation;
[0089] In this embodiment, the Word2Vec model is used to obtain word vectors, wherein the Word2Vec model is a well-known technology and will not be described in detail here. Secondly, the degree of relevance is calculated by calculating the maximum value of the cosine similarity between the word vector of each word in each plaintext block and the word vector of all words in the sensitive vocabulary, wherein the calculation of cosine similarity is a well-known technology and will not be described in detail here.
[0090] The sum of the second relevance of all words in each plaintext block is recorded as a first sensitivity value;
[0091] If there is a number in each plaintext block, the number group to which the number belongs is obtained, and the result of negative mapping the minimum value of the corresponding number group is used as the second sensitive value of each plaintext block; if there is no number group in each plaintext block, the second sensitive value of each plaintext block is 0;
[0092] In this embodiment, the specific process of negative mapping is: negative mapping is performed through an exponential function, assuming that the minimum value is recorded as , then The result is taken as the second sensitive value, where is an exponential function with a natural constant as its base.
[0093] It should be noted that, for example, for a piece of text data "Please keep the user number 456789 safe, the password is qwer1234, and do not disclose it. The password of user number 123456 has been reset", the fifth plaintext block is "The password of 56 has been reset". The plaintext block contains the numbers 5 and 6, and these two numbers belong to the number group 123456.
[0094] Taking the sum of the first sensitivity value and the second sensitivity value as the information sensitivity of each plaintext block;
[0095] It should be noted that the greater the second correlation, the more likely the word is a sensitive word, the greater the first sensitivity value, the more sensitive the word information contained in the plaintext block, the greater the second sensitivity value, the more sensitive the digital information contained in the plaintext block, the greater the sensitivity of the obtained information, the more important the information contained in the plaintext block, and the greater the degree of protection should be, that is, the more complex the encryption of the plaintext block by the SM4 algorithm should be, and the control parameters of the Logistic Chaotic Mapping Algorithm should be increased.
[0096] At this point, the information sensitivity of each plaintext block is obtained.
[0097] Step 5: Determine the adjustment coefficient for each plaintext block based on information repetition, semantic relevance, and information sensitivity; adjust the control parameters of the chaotic mapping algorithm based on the adjustment coefficient to obtain the adjusted control parameters corresponding to each plaintext block; combine the chaotic mapping algorithm and the SM4 algorithm to encrypt each plaintext block to obtain ciphertext data; and verify the integrity of the ciphertext data during the communication transmission process through digital summary technology.
[0098] Furthermore, based on the information repetition, the semantic relevance, and the information sensitivity, an adjustment coefficient is determined, specifically:
[0099] The normalized result of the product of the information repetition degree, the semantic relevance degree, and the information sensitivity is used as the adjustment coefficient of each plaintext block;
[0100] In this embodiment, the sigmoid function is used for normalization processing, wherein the sigmoid function is a well-known technology and will not be described in detail here. As other implementation methods, the implementer can adopt other methods of the existing technology, such as the softmax function, the tanh function, etc., and this embodiment does not impose any special restrictions on this.
[0101] It should be noted that the larger the adjustment coefficient is, the more complex the encryption effect is required when encrypting the plaintext block. Therefore, the control parameter of the Logistic Chaotic Mapping Algorithm should be increased. Conversely, the importance of the information of the plaintext block is relatively low, and the control parameter of the Logistic Chaotic Mapping Algorithm can be reduced.
[0102] Secondly, based on the adjustment coefficient, the control parameters of the chaos mapping algorithm are adjusted, specifically:
[0103]
[0104] in, For the The plaintext blocks correspond to the adjusted control parameters, To preset the initial control parameters, is the preset limiting factor, For the The adjustment factor for plaintext blocks, To preset the first value, is a preset second value, wherein the preset first value is smaller than the preset second value;
[0105] In this embodiment, the initial control parameters are preset The value is 3.8, the preset limiting factor The value is 0.2, which controls the adjustment range to avoid excessive adjustment of the control parameters; the first value is preset The value is 0.4, and the second value is preset The value is 0.7. As other implementation methods, the implementer can set it according to actual conditions.
[0106] It should be noted that by setting different control parameters of the chaotic mapping algorithm based on the inconsistency of the importance of the information contained in each plaintext block, the security of the SM4 algorithm is improved and the risk of text data leakage is reduced.
[0107] Based on the adjusted control parameters corresponding to each plaintext block, a chaotic sequence is generated in combination with a Logistic chaotic mapping algorithm. An S-box is dynamically generated using the generated chaotic sequence through a certain mapping relationship. A round key is generated using the chaotic sequence. Each plaintext block is encrypted using the dynamically generated S-box and the round key using the SM4 algorithm, and a ciphertext block corresponding to each plaintext block is output. The ciphertext blocks of all plaintext blocks corresponding to the text data are concatenated to obtain ciphertext data.
[0108] It should be noted that the process of performing chaotic encryption using the Logistic chaotic mapping algorithm and the SM4 algorithm is a well-known technology and will not be described in detail here.
[0109] The flowchart of the method for obtaining ciphertext data provided in the embodiment of the present application is as follows: Figure 3 shown.
[0110] Secondly, in order to ensure the integrity and consistency of text data, digital summary technology is used to generate a digital summary of the ciphertext data. The sender transmits the generated digital summary together with the ciphertext data. After receiving the ciphertext data, the receiver decrypts the ciphertext data and regenerates the digital summary. The newly generated digital summary is compared with the original digital summary to determine whether they are consistent, and then evaluate whether the ciphertext data has been tampered with during the communication transmission process to ensure the security and integrity of the text data in the application layer.
[0111] It should be noted that digital summarization technology is a well-known technology and will not be described in detail here.
[0112] Based on the same inventive concept as the above method, an embodiment of the present application also provides an application layer data encryption system based on the SM4 algorithm and digest verification, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any one of the above-mentioned application layer data encryption methods based on the SM4 algorithm and digest verification.
[0113] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0114] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0115] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the present application. It should be noted that a person skilled in the art can make various modifications and improvements without departing from the spirit of the present application. Therefore, any simple modifications, equivalent variations, and modifications to the above embodiments made in accordance with the technical essence of the present application without departing from the content of the present application's technical solution fall within the scope of protection of the present application's technical solution.
Claims
1. The application layer data encryption method based on SM4 algorithm and digest authentication is characterized by: The method comprises the following steps: Obtain the text data to be encrypted in the application layer; divide the text data into multiple plaintext blocks, perform word segmentation on each plaintext block, and obtain each word; Analyze the number of characters between two consecutive occurrences of each word in each plaintext block, as well as the correlation between the two consecutive occurrences and the adjacent words, and calculate the information repetition of each plaintext block based on the number of times each word appears in the text data; The semantic relevance of each plaintext block is obtained by the co-occurrence of each word and its adjacent words in the text data, as well as the number of sentences contained in each plaintext block. Determine the information sensitivity of each plaintext block based on the numbers contained in each plaintext block and the correlation between each word and the preset sensitive words; Based on information repetition, semantic relevance and information sensitivity, an adjustment coefficient for each plaintext block is determined; based on the adjustment coefficient, the control parameters of the chaotic mapping algorithm are adjusted to obtain the adjusted control parameters corresponding to each plaintext block. The chaotic mapping algorithm and the SM4 algorithm are combined to encrypt each plaintext block to obtain ciphertext data. The integrity of the ciphertext data during the communication transmission process is verified through digital summary technology.
2. The application layer data encryption method based on the SM4 algorithm and digest authentication according to claim 1, characterized in that: The dividing the text data into a plurality of plaintext blocks includes: encoding the text data, obtaining a byte sequence corresponding to the text data, and dividing the text data into a plurality of plaintext blocks according to the byte sequence.
3. The application layer data encryption method based on the SM4 algorithm and digest authentication as claimed in claim 1, characterized in that: Calculating the information duplication of each plaintext block includes: Calculate the distance between each occurrence of each word in the text data and the next occurrence within each plaintext block; Convert each word in each plaintext block into a word vector when it appears in the text data together with the adjacent words; Calculate the correlation between the word vectors of each word in each plaintext block and the next occurrence in the text data, which is recorded as the first correlation; Count the frequency of each word in each plaintext block in the text data; The information repetition degree is the sum of the product of the frequency, the interval distance and the first correlation of all words in each plaintext block.
4. The application layer data encryption method based on the SM4 algorithm and digest authentication as claimed in claim 3, characterized in that: Obtaining the semantic relevance of each plaintext block includes: The words adjacent to the position of each word in the text data in each plaintext block are recorded as neighboring words; Selecting the maximum value between the frequency of each word in each plaintext block and the frequency of the adjacent words, and recording it as the highest frequency; Counting the number of times each word in each plaintext block and the phrase consisting of the adjacent words co-occur in the text data, which is recorded as the number of co-occurrences; Calculating the cumulative sum of the ratios of the co-occurrence counts of all words in each plaintext block to the maximum count; and counting the number of sentences contained in each plaintext block; The semantic relevance is the ratio of the cumulative sum to the number of sentences.
5. The application layer data encryption method based on SM4 algorithm and digest authentication as claimed in claim 1, characterized in that: Determining the information sensitivity of each plaintext block includes: Extract all digital groups from text data; based on prior knowledge, pre-build a preset specific format digital library and a preset sensitive word library; Calculate the minimum value of the difference between the number of digits of each digit group and the number of digits of all specific types in the digit library of the specific format; Calculate the maximum value of the correlation between the word vector of each word in each plaintext block and the word vector of all sensitive words in the sensitive word library, and record it as the second correlation; The sum of the second relevance of all words in each plaintext block is recorded as a first sensitivity value; If there is a number in each plaintext block, the number group to which the number belongs is obtained, and the result of negative mapping the minimum value of the corresponding number group is used as the second sensitive value of each plaintext block; if there is no number group in each plaintext block, the second sensitive value of each plaintext block is 0; The sum of the first sensitivity value and the second sensitivity value is used as the information sensitivity of each plaintext block.
6. The application layer data encryption method based on SM4 algorithm and digest authentication as claimed in claim 1, characterized in that: The adjustment coefficient is a normalized result of the product of the information repetition, the semantic relevance, and the information sensitivity.
7. The application layer data encryption method based on SM4 algorithm and digest authentication according to claim 1, characterized in that: No. Plaintext blocks correspond to the adjusted control parameters The calculation formula is: ,in, To preset the initial control parameters, is the preset limiting factor, For the The adjustment factor for plaintext blocks, To preset the first value, The preset second value is a value that is smaller than the preset second value.
8. The application layer data encryption method based on SM4 algorithm and digest authentication as claimed in claim 1, characterized in that: The obtaining of ciphertext data includes: encrypting each plaintext block based on the adjusted control parameters corresponding to each plaintext block in combination with a chaotic mapping algorithm and an SM4 algorithm, outputting a ciphertext block corresponding to each plaintext block, and splicing the ciphertext blocks of all plaintext blocks corresponding to the text data to obtain ciphertext data.
9. The application layer data encryption method based on SM4 algorithm and digest authentication according to claim 1, characterized in that: The integrity verification of the ciphertext data during the communication transmission process includes: generating a digital summary of the ciphertext data through digital summary technology, the sending end transmitting the generated digital summary together with the ciphertext data, and the receiving end decrypting the ciphertext data after receiving the ciphertext data and regenerating the digital summary, and comparing the newly generated digital summary with the original digital summary to determine the integrity of the ciphertext data.
10. An application layer data encryption system based on the SM4 algorithm and digest authentication, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the application layer data encryption method based on the SM4 algorithm and digest verification as described in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Data encryption method and system based on chaotic block cipher
CN115348101A
DATA ENCRYPTION METHOD WITH CHAOTIC CHANGES OF THE ROUND KEY BASED ON DYNAMIC CHAOS
EA201600099A1