Data transmission protection method based on combination of HMAC-MD5 algorithm and key pre-distribution
By combining the HMAC-MD5 algorithm and key pre-allocation in internode data transmission, partial key information is hidden, and the problem of network security compromise caused by key leakage is solved, achieving higher communication security and lower attack risk.
Patent Information
- Application Number
- CN202411416640.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-10-11
AI Technical Summary
In the prior art, when data transmission between nodes is transmitted, key leakage can easily lead to the security of the entire network being damaged. After the attacker captures the key information, he can obtain the key data of other nodes and break through multiple communication links.
The data transmission protection method based on the HMAC-MD5 algorithm combined with key pre-allocation is adopted. Through the one-way characteristics of the key pre-allocation and hash function, some key information of the node is hidden to reduce the number of key leakage.
It effectively reduces the possibility of attackers destroying other network links, improves the security of node communications, and reduces the probability of other communication links being breached after the communication node is captured.
Smart Images

Figure CN119628824A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data encryption transmission protection, and in particular relates to a data transmission protection method based on an HMAC-MD5 algorithm combined with key pre-distribution. Background Art
[0002] When communicating between nodes, encryption keys and decryption keys are usually used. Whether it is symmetric encryption or asymmetric encryption, the security of the key directly determines the security of the information transmitted between nodes. Before transmitting information, encrypting the data and encrypting the stored key information can ensure that even if an attacker captures some sensor nodes and obtains the key information, the secure communication between other nodes will not be damaged on a large scale.
[0003] Communication between nodes is vulnerable to capture and intrusion by attackers, leading to multiple security threats such as information leakage, data tampering, information eavesdropping, and denial of service attacks. That is, once an attacker captures key information, he may obtain key data of other nodes, thereby breaking multiple communication links. Communication nodes themselves are also vulnerable to multiple security threats such as information leakage, eavesdropping, deception, imitation, and denial of service attacks.
[0004] Therefore, it is extremely necessary to strengthen the research on data transmission security between communication nodes. Ensuring the security of data transmission between communication nodes is an issue that deserves great attention. Summary of the invention
[0005] In view of the shortcomings of the prior art, the present invention proposes a data transmission protection method based on the HMAC-MD5 algorithm combined with key pre-distribution. The core of this method is to use key pre-distribution and the one-way characteristics of the Hash function to hide part of the key information of the node to a certain extent, that is, to reduce the number of node key leaks, thereby reducing the possibility of attackers damaging other links in the network, thereby improving the security of node communication.
[0006] To achieve the above object, the present invention provides a data transmission protection method based on the HMAC-MD5 algorithm combined with key pre-distribution, characterized in that it at least comprises the following steps: The key pre-distribution scheme is combined with the HMAC-MD5 algorithm based on symmetric cryptography and integrated into the key pre-distribution management scheme based on the hash mechanism; that is, before the data information participates in the communication encryption transmission, the key held by the node is pre-loaded, and the one-way characteristics of the hash function are used to hide part of the node's key information; The steps for combining the hash-based key pre-distribution with the encryption algorithm are as follows: The first step: obtain the number of keys S required between communication nodes from the randomly generated keys in the key pool to meet the needs of communication nodes; The second step: randomly assign the number of keys m in the key pool to the sender node and the receiver node to ensure that the keys of different nodes are not repeated; The third step: confirm the connectivity conditions between nodes, that is, ensure that both parties need to reach the same minimum number of keys q; then determine whether the number of identical keys in the nodes of both parties reaches the required q value. If so, the same q keys can be taken from the same keys and spliced into one key in the same order before communication can be carried out; The fourth step: confirm the node identifiers of both parties that need to be transmitted; The fifth step: confirm the modulus parameter L value in the key preloading; The sixth step: if the sender's node identifier modulo L is less than the receiver's node identifier modulo L, the sender needs to perform | Node sender % L - Node receiver % L | additional hash loading before performing the HMAC-MD5 encryption operation of the information; The seventh step: obtain the encryption key, and follow the steps of the HMAC-MD5 encryption algorithm to write the program.
[0007] Furthermore, in the seventh stage, according to the process of HMAC-MD5 encryption algorithm, the steps of programming operation are as follows: Step 1: Add 0 after the key. This operation is used to get a string of 64 bytes. If the key exceeds 64 bytes, use the MD5 operation of the key to replace the original key, and then add 0 after it to reach 64 bytes.
[0008] Step 2: XOR the string generated in the first step with ipad (0x36) to generate an istring.
[0009] Step 3: Add data after the istring in step 2.
[0010] Step 4: Perform MD5 operation on the data stream istring generated in step 3.
[0011] Step 5: Perform the xor operation on the string generated in the first step and opad (0x5c) to get the ostring string.
[0012] Step 6: Add the result of step 4, istring, to the end of ostring in step 5.
[0013] Step 7: Perform MD5 operation on the data stream ostring generated in step 6 to output the result.
[0014] The above integration can finally obtain the information data for transmission after HMAC-MD5 encryption.
[0015] The present invention adopts the above technical solution, combines the key pre-distribution scheme with the HMAC-MD5 algorithm based on symmetric cryptography, and integrates it into the key pre-distribution management scheme based on the hash mechanism; that is, before the data information participates in the communication encryption transmission, the key held by the node is pre-loaded, and the one-way characteristics of the hash function are used to hide part of the key information of the node to a certain extent; in this way, even if the attacker obtains the key data between the transmission nodes, the impact on the transmission between other nodes will be limited to a small range. It has at least the following beneficial effects: 1. Before transmitting information, encrypt the information data. By adding key pre-distribution based on the one-way characteristics of the hash function, the stored key information is encrypted and managed. In this way, even if an attacker captures some nodes and obtains their key information, the secure transmission between the remaining nodes will not be destroyed on a large scale.
[0016] 2. Setting the optimal number of keys, the minimum connection key value, and the modulus parameters can effectively reduce the probability of the communication link being hacked. That is, the main advantage is to effectively reduce the probability of other communication links being hacked after the communication node is captured.
[0017] 3. Enhanced security protection makes HMAC more reliable and secure in practical applications, and can effectively prevent common attack methods, such as length extension attacks and selected ciphertext attacks. Standardization and widespread application support make HMAC one of the de facto standards in secure communications, providing a stable and reliable message authentication solution for various security protocols and applications.
[0018] 4. HMAC introduces the concept of a universal message authentication code based on a hash function. Traditional MAC algorithms usually rely on specific symmetric encryption algorithms, such as DES or AES, while HMAC achieves a more general and flexible design by leveraging the wide applicability and security of hash functions.
[0019] 5. The length extension attack problem of traditional MAC is taken into consideration, and the ability to resist attacks is improved by introducing multiple uses of the key in the hash function input (through internal and external hashing). BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 is a flow chart of the data transmission protection method of the present invention; Figure 2 The communication link between the communication nodes of the present invention is schematically shown in FIG. Figure 1 ; Figure 3 The communication link between the communication nodes of the present invention is schematically shown in FIG. Figure 2 . DETAILED DESCRIPTION
[0022] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0023] like Figure 1 , Figure 2 and Figure 3 As shown, this embodiment provides a data transmission protection method based on the HMAC-MD5 algorithm combined with key pre-distribution, characterized in that it includes at least the following steps: The key pre-distribution scheme is combined with the HMAC-MD5 algorithm based on symmetric cryptography and integrated into the key pre-distribution management scheme based on the hash mechanism; that is, before the data information participates in the communication encryption transmission, the key held by the node is pre-loaded, and the one-way characteristics of the hash function are used to hide part of the node's key information; The steps for combining the hash-based key pre-distribution with the encryption algorithm are as follows: The first step: obtain the number of keys S required between communication nodes from the randomly generated keys in the key pool to meet the needs of communication nodes; The second step: randomly assign the number of keys m in the key pool to the sender node and the receiver node to ensure that the keys of different nodes are not repeated; The third step: confirm the connectivity conditions between nodes, that is, ensure that both parties need to reach the same minimum number of keys q; then determine whether the number of identical keys in the nodes of both parties reaches the required q value. If so, the same q keys can be taken from the same keys and spliced into one key in the same order before communication can be carried out; The fourth step: confirm the node identifiers of both parties that need to be transmitted; The fifth step: confirm the modulus parameter L value in the key preloading; The sixth step: if the sender's node identifier modulo L is less than the receiver's node identifier modulo L, the sender needs to perform | Node sender % L - Node receiver % L | additional hash loading before performing the HMAC-MD5 encryption operation of the information; The seventh step: obtain the encryption key, and follow the steps of the HMAC-MD5 encryption algorithm to write the program.
[0024] Furthermore, in the seventh stage, according to the process of HMAC-MD5 encryption algorithm, the steps of programming operation are as follows: Step 1: Add 0 after the key. This operation is used to get a string of 64 bytes. If the key exceeds 64 bytes, use the MD5 operation of the key to replace the original key, and then add 0 after it to reach 64 bytes.
[0025] Step 2: XOR the string generated in the first step with ipad (0x36) to generate an istring.
[0026] Step 3: Add data after the istring in step 2.
[0027] Step 4: Perform MD5 operation on the data stream istring generated in step 3.
[0028] Step 5: Perform the xor operation on the string generated in the first step and opad (0x5c) to get the ostring string.
[0029] Step 6: Add the result of step 4, istring, to the end of ostring in step 5.
[0030] Step 7: Perform MD5 operation on the data stream ostring generated in step 6 to output the result.
[0031] The above integration can finally obtain the information data for transmission after HMAC-MD5 encryption.
[0032] Implementation case: Figure 2As shown in the figure, suppose there are seven communication nodes that can communicate now, the node identifiers are node[i], [i=1,2,3,4,5,6,7], and the key pool S contains six keys K1, K2, K3, K4, K5, and K6. The minimum number of keys q that can successfully communicate is set to 1, and the key ring m=2, that is, each node has 2 keys. Node[1-7] has keys and communication links between nodes (such as: Figure 2 ): like Figure 3 As shown, if key preloading is not performed, assuming that communication node 4 and node 2 want to connect for communication, they have a common key K5, and can communicate normally with the help of key K5. However, if the attacker captures communication node 2 and communication node 4, resulting in the leakage of keys K5, K6, and K2 of communication node node2 and communication node node4, this will affect the normal communication between communication nodes 1 and 5, 5 and 6, 3 and 7, and 2 and 3, that is, these four communication links will be breached. If the keys stored in the nodes before the network deployment are first preloaded through the hash function, assuming the modulus parameter L=5, after the key preloading using the q-composite scheme, node1 has the keys: h1(K1), h1(K2), node2 has the keys: h2(K2), h2(K5), node3 has the keys: h3(K2), h3(K6), node4 has the keys: h4(K5), h4(K6), node5 has the keys: h0(K2), h0(K5), node6 has the keys: h1(K5), h1(K6), node7 has the keys: h2(K1), h2(K6). Communication links between communication nodes (such as: Figure 3 ): At this time, the attacker has captured the communication nodes node4 and node2, resulting in the leakage of the keys h4(K5), h4(K6), h2(K2), and h2(K5). At this time, only the link between communication nodes 2 and 3 is affected, because the enemy can use the captured key h2(K2) to calculate h3(K2) through hash calculation; the other three communication links between communication nodes 1 and 5, 5 and 6, and 3 and 7 are not affected. This is all due to the unidirectional advantage of the hash function. The enemy has no way to use backtracking to calculate h(K5) from h4(K5) or h2(K5), nor can it calculate h3(K6) and h(K2) from h4(K6) and h2(K2). Therefore, preloading the key before sending a message to the communication node can effectively reduce the probability of the communication node being captured and other communication links being breached.
[0033] The present invention adopts a specific technical solution, which is to integrate the key pre-distribution scheme with the HMAC-MD5 algorithm based on symmetric cryptography, and cleverly embed it into the key pre-distribution management framework based on the hash mechanism. Specifically, before the data information formally participates in the process of communication encryption transmission, the keys held by each node will be loaded in advance, and with the help of the inherent unidirectional characteristics of the hash function, part of the key information of the node will be concealed. This is intended to control the potential threat to the communication links between other nodes within a limited range even if the attacker successfully intercepts the key data between the transmission nodes.
[0034] Compared with the prior art, the core advantage of the present invention is that it significantly reduces the risk of the entire communication network being fully penetrated due to the capture of individual communication nodes.
[0035] The benefits achieved by this embodiment include but are not limited to: 1. Data integrity protection: By using the HMAC mechanism, combined with the dual role of the key and the hash function, strict verification of data integrity during data transmission and storage is achieved to ensure that the data is not tampered with or damaged.
[0036] 2. Authentication function: HMAC also has the ability to verify the identity of the message sender. By combining the message content with a specific key and using a hash function to generate a unique authentication code, the recipient can easily confirm whether the source of the message is as expected.
[0037] 3. Replay attack defense: Since HMAC incorporates dynamic elements such as timestamps or random numbers, it is difficult for attackers to use captured authentication codes to carry out replay attacks, thereby effectively improving the system's protection capabilities.
[0038] 4. Easy implementation and high performance: The design concept of HMAC focuses on simplicity and efficiency, which is particularly suitable for resource-constrained environments such as embedded systems or IoT devices, providing strong support for communication security in these areas.
[0039] 5. Strong compatibility of hash functions: HMAC can be seamlessly integrated with a variety of recognized secure hash functions (such as SHA-256, SHA-3, etc.), further enhancing its security performance and building a more solid line of defense for the encryption protection of communication data.
[0040] Although the embodiments of the present invention have been shown and described above, it will be appreciated that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, substitute and vary the above embodiments within the scope of the present invention.
Claims
1. A data transmission protection method based on the HMAC-MD5 algorithm combined with key pre-distribution, characterized in that: At least the following steps are included: The key pre-distribution scheme is combined with the HMAC-MD5 algorithm based on symmetric cryptography and integrated into the key pre-distribution management scheme based on the hash mechanism; that is, before the data information participates in the communication encryption transmission, the key held by the node is pre-loaded, and the one-way characteristics of the hash function are used to hide part of the key information of the node; The steps for combining the hash-based key pre-distribution with the encryption algorithm are as follows: The first step: obtain the number of keys S required between communication nodes from the randomly generated keys in the key pool to meet the needs of communication nodes; The second step: randomly assign the number of keys m in the key pool to the sender node and the receiver node to ensure that the keys of different nodes are not repeated; The third step: confirm the connectivity conditions between nodes, that is, ensure that both parties need to reach the same minimum number of keys q; then determine whether the number of identical keys in the nodes of both parties reaches the required q value. If so, the same q keys can be taken from the same keys and spliced into one key in the same order before communication can be carried out; The fourth step: confirm the node identifiers of both parties that need to be transmitted; The fifth step: confirm the modulus parameter L value in the key preloading; The sixth step: if the sender's node identifier modulo L is less than the receiver's node identifier modulo L, the sender needs to perform | Node sender % L - Node receiver % L | additional hash loading before performing the HMAC-MD5 encryption operation of the information; The seventh step: obtain the encryption key, and follow the steps of the HMAC-MD5 encryption algorithm to write the program.
2. The method according to claim 1, characterized in that: In the seventh stage, according to the process of HMAC-MD5 encryption algorithm, the steps of program writing operation are as follows: Step 1: Add 0 to the end of the key. This operation is used to get a 64-byte string. If the key exceeds 64 bytes, use the MD5 operation of the key to replace the original key, and then add 0 to the end to reach 64 bytes. Step 2: XOR the string generated in the first step with ipad (0x36) to generate an isring; Step 3: Add data after the istring in step 2; Step 4: Perform md5 operation on the data stream isring generated in step 3; Step 5: Perform xor operation on the string generated in the first step and opad (0x5c) to get the ostring string; Step 6: Add the result of step 4, istring, to the end of ostring in step 5; Step 7: Perform MD5 operation on the data stream ostring generated in step 6 to output the result; The above integration can finally obtain the information data for transmission after HMAC-MD5 encryption.
Citation Information
Patent Citations
Electric power material coding optimization method based on hash algorithm
CN110889595A
Secret key protection method and device based on HMAC algorithm, equipment and storage medium
CN114584291A
In-vehicle network communication method based on identity information
CN117714055A
Data encryption and decryption method and device, electronic equipment and storage medium
CN118264426A
Key pre-sharing safety pilot model based on polynomial set in mobile self-organizing network
CN1925490A
