Data security transmission method and system based on autonomous security interaction protocol

By adopting autonomous security interaction protocols in data transmission, using asymmetric and symmetric encryption algorithms, combined with the identity authentication of trusted third parties, the problem of insufficient security in data transmission in the existing technology is solved, and efficient and secure data transmission is achieved.

CN118784337BActive Publication Date: 2025-04-11WING SHIELD (SHANGHAI) INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411025150.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2024-06-29
Filing Date
2024-07-29
Publication Date
2025-04-11
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

The prior art is difficult to effectively prevent data eavesdropping, tampering and man-in-the-middle attacks during data transmission, and key management is complex and computational overhead is large.

Method used

The data security transmission method based on the autonomous secure interaction protocol is adopted, and the public and private keys are generated through an asymmetric encryption algorithm, and a trusted third party is used to perform identity authentication and key exchange, and the session key is obtained. The data is encrypted through a symmetric encryption algorithm to generate encrypted data packets and message authentication codes.

Benefits of technology

It ensures the authenticity of the identities of both parties in the communication and the confidentiality and integrity of data transmission, avoids the risk of key exchange, and improves security and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118784337B_ABST
    Figure CN118784337B_ABST
Patent Text Reader

Abstract

The present invention provides a data security transmission method and system based on an autonomous security interaction protocol, which relates to the technical field of data transmission, including establishing an identity authentication model for both communicating parties, generating public keys and private keys corresponding to the two communicating parties through an asymmetric encryption algorithm, and performing identity authentication and key exchange through a trusted third party to obtain the session keys of the two communicating parties; generating an encrypted data packet through a symmetric encryption algorithm, and generating a first message authentication code based on the encrypted data packet through a hash function; constructing a complete encrypted message; decrypting the encrypted data packet through a symmetric encryption algorithm to obtain original data, and generating a second message authentication code corresponding to the original data through a hash function based on the original data; performing two rounds of comparison between the first message authentication code and the second message authentication code, and if the two rounds of comparison are consistent, it is confirmed that the data has not been tampered with; if any one of the two rounds of comparison is inconsistent, a security measure is triggered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to data transmission technology, and in particular to a data security transmission method and system based on an autonomous security interaction protocol. Background Art

[0002] With the rapid development and widespread application of the Internet, secure data transmission has become a crucial issue in the modern information society. In various online services, e-commerce, remote office and other scenarios, a large amount of data needs to be exchanged and transmitted between different devices and networks. However, in an open network environment, data faces various security threats during transmission, such as data eavesdropping, tampering, forgery, etc., which seriously threatens user privacy and data security.

[0003] Traditional data security transmission solutions mainly rely on encryption technology to ensure the confidentiality of data by encrypting it. However, traditional encryption technology has some limitations, such as complex key management, high computational overhead, and inability to effectively prevent man-in-the-middle attacks. Summary of the invention

[0004] The embodiments of the present invention provide a data security transmission method and system based on an autonomous security interaction protocol, which can solve the problems in the prior art.

[0005] According to a first aspect of the embodiments of the present invention,

[0006] Provides a data security transmission method based on an autonomous security interaction protocol, including:

[0007] Establish an identity authentication model for both communicating parties, generate the public key and private key corresponding to the two communicating parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session key of the two communicating parties; use the session key to encrypt the data to be transmitted by the two communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generate a first message authentication code based on the encrypted data packet through a hash function;

[0008] The encrypted data packet is concatenated with the first message authentication code to construct a complete encrypted message, which is sent to a trusted third party through a network channel; after receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data;

[0009] The first message authentication code and the second message authentication code are compared twice. If both comparisons are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any one of the two comparisons is inconsistent, the security measures are triggered.

[0010] In an optional embodiment,

[0011] Establish an identity authentication model for both parties in communication, generate the corresponding public and private keys of both parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session keys of both parties in communication, including:

[0012] Based on the elliptic curve cryptography algorithm, the communicating parties use randomly selected elliptic curve parameters and base points to generate their own public and private keys. The private key is used for data encryption and session key decryption, and the public key is used for session key encryption. At the same time, the communicating parties use their identity as part of the public key to generate an identity-based public key.

[0013] The communicating parties submit the identity-based public key and identity identifier to the trusted third party through a secure channel. The trusted third party uses the received identity identifier to verify the true identities of the communicating parties through a two-way authentication protocol and check the matching of the submitted public key and identity identifier.

[0014] After identity authentication is passed, the trusted third party uses the identity identifier as a seed to generate a session key between the communicating parties through a key derivation function, and encrypts the session key using the public keys of the two communicating parties to generate an encrypted session key.

[0015] In an optional embodiment,

[0016] Using the session key, encrypting the data to be transmitted between the communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generating a first message authentication code based on the encrypted data packet through a hash function includes:

[0017] Using the session key, based on a symmetric encryption algorithm, padding processing is performed on the data to be transmitted between the communicating parties, wherein the padding processing calculates the difference between the length of the data to be transmitted and a preset packet length, determines the number of bytes required for padding according to the difference, and adds the required number of bytes for padding at the end of the data to be transmitted, so as to extend the length of the data to be transmitted after padding to an integer multiple of the preset packet length;

[0018] Encrypting the padded data to be transmitted, generating a pseudo-random number sequence of the same length as the padded data to be transmitted based on a symmetric encryption algorithm by using the session key and a randomly generated initial vector, and performing an XOR operation on the pseudo-random number sequence and the padded data to be transmitted to obtain an encrypted data packet, wherein the initial vector is a random value used to ensure the uniqueness of each encryption process;

[0019] Using a key derivation function, generating an internal key and an external key according to the session key, concatenating the internal key with the encrypted data packet to obtain first concatenated encrypted data, and performing a first SHA-256 hash operation on the first concatenated encrypted data to obtain a first hash value;

[0020] The external key is concatenated with the first hash value to obtain second concatenated encrypted data, a second SHA-256 hash operation is performed on the second concatenated encrypted data to obtain a second hash value, and the second hash value is used as a first message authentication code.

[0021] In an optional embodiment,

[0022] Using a key derivation function, generating an internal key and an external key according to the session key, and concatenating the internal key with the encrypted data packet to obtain first concatenated encrypted data includes:

[0023] (K int ,K ext )=KDF(K session ,CTX int ,CTX ext ,L int ,L ext );

[0024] Among them, K int , K ext They represent internal key and external key respectively, KDF() represents key derivation function, K session Indicates the session key, CTX int , CTX ext Represents the context information of the internal key and the external key respectively, L int , L ext Represents the bit length of the internal key and the external key respectively;

[0025] E concat1 =Concat(K int ,E data ,Pad int ,L int );

[0026] Among them, E concat1 represents the first concatenated encrypted data, Concat() represents the concatenation function, K int represents the internal key, E data Indicates encrypted data packets, Pad int , L int They respectively represent the padding data of the internal key and the bit length of the internal key.

[0027] In an optional embodiment,

[0028] After receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data, including:

[0029] The trusted third party extracts the encrypted data packet, the initialization vector, the timestamp and the random number from the complete encrypted message; and dynamically generates a master key based on the session key and the random number using a key derivation function;

[0030] Decrypting and verifying the integrity of the encrypted data packet using the master key and the initial vector based on the authenticated encryption mode of the AES-256 algorithm to obtain the original data;

[0031] A second message authentication code corresponding to the original data is generated based on the original data by using the hash function.

[0032] In an optional embodiment,

[0033] The first message authentication code and the second message authentication code are compared twice. If the two comparisons are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any of the two comparisons is inconsistent, the security measures are triggered, including:

[0034] Respectively generate a first random mask having the same length as the first message authentication code and a second random mask having the same length as the second message authentication code, wherein the first random mask and the second random mask are different;

[0035] Using a constant time comparison function to compare each bit of the first message authentication code and the second message authentication code by a bit-by-bit XOR operation, and accumulating XOR results, and finally determining whether the first message authentication code and the second message authentication code match according to whether the accumulated XOR results are zero;

[0036] If the first round of comparison results in a mismatch, the comparison process is terminated and safety measures are triggered; if the first round of comparison results in a match, the second round of comparison is continued;

[0037] Performing hash operations on the first message authentication code and the second message authentication code based on a pre-selected hash function to determine a first hash value corresponding to the first message authentication code and a second hash value corresponding to the second message authentication code;

[0038] If the first hash value and the second hash value match, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing.

[0039] In the second aspect of the embodiments of the present application,

[0040] Provides a data security transmission system based on an autonomous security interaction protocol, including:

[0041] The first unit is used to establish an identity authentication model for both communicating parties, generate public keys and private keys corresponding to both communicating parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain a session key for both communicating parties; use the session key to encrypt the data to be transmitted by the two communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generate a first message authentication code based on the encrypted data packet through a hash function;

[0042] The second unit is used to concatenate the encrypted data packet with the message authentication code to construct a complete encrypted message, and send it to a trusted third party through a network channel; after receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet through a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data through a hash function based on the original data;

[0043] The third unit is used to perform two rounds of comparison on the first message authentication code and the second message authentication code. If the two rounds of comparison are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any one of the two rounds of comparison is inconsistent, the security measures are triggered.

[0044] According to a third aspect of the embodiments of the present invention,

[0045] An electronic device is provided, comprising:

[0046] processor;

[0047] a memory for storing processor-executable instructions;

[0048] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.

[0049] A fourth aspect of the embodiments of the present invention is:

[0050] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.

[0051] By establishing an identity authentication model for both parties in communication, using an asymmetric encryption algorithm to generate the public and private keys of both parties in communication, and performing identity authentication and key exchange through a trusted third party, the session key of both parties in communication is obtained, thus ensuring the authenticity of the identities of both parties in communication and the confidentiality of data transmission. At the same time, a symmetric encryption algorithm is used to encrypt the data to be transmitted to prevent the data from being eavesdropped or tampered with during transmission.

[0052] By introducing a trusted third party to participate in the identity authentication and key exchange process, the risk of direct key exchange between the two communicating parties is avoided, and the security of identity authentication and key management is improved. As a neutral party, the trusted third party verifies the identities of the two communicating parties to ensure the legitimacy of the two communicating parties and prevent identity forgery and man-in-the-middle attacks.

[0053] The data security transmission method proposed in the present invention has strong versatility and flexibility, and can adapt to different network environments and application scenarios. Through the design of an autonomous security interaction protocol, security parameters and encryption algorithms can be dynamically adjusted according to specific security needs and performance requirements to achieve adaptive data security transmission. The present invention adopts a combination of multiple security mechanisms, including identity authentication, data encryption, integrity verification, etc., to provide multi-level security protection. By encrypting data and generating message authentication codes, even if the data is intercepted during transmission, it is difficult for an attacker to obtain the content of the original data. At the same time, through the verification of message authentication codes, data tampering and destruction can be discovered in a timely manner, triggering corresponding security measures to maximize the protection of data confidentiality and integrity. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 A schematic diagram of a flow chart of a data security transmission method based on an autonomous security interaction protocol according to an embodiment of the present invention;

[0055] Figure 2 It is a structural schematic diagram of a data security transmission system based on an autonomous security interaction protocol according to an embodiment of the present invention. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0058] Figure 1 FIG. 1 is a flow chart of a data security transmission method based on an autonomous security interaction protocol according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0059] S101. Establish an identity authentication model for both communicating parties, generate the public key and private key corresponding to the communicating parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session key of the communicating parties; use the session key to encrypt the data to be transmitted by the communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generate a first message authentication code based on the encrypted data packet through a hash function;

[0060] For example, in order to ensure the authenticity of the identities of both parties in communication and the security of data transmission, it is necessary to first establish a robust identity authentication model. This model is based on an asymmetric encryption algorithm, and achieves identity verification and authentication by generating public and private keys corresponding to both parties in communication. When establishing an identity authentication model, it is necessary to select an appropriate asymmetric encryption algorithm. Common asymmetric encryption algorithms include RSA, ECC (elliptic curve encryption), etc. The RSA algorithm is based on the problem of large integer factorization and has high security, but the computational complexity is high; the ECC algorithm is based on the elliptic curve discrete logarithm problem. Compared with the RSA algorithm, at the same security strength, the ECC algorithm has a shorter key length and higher computational efficiency. Select a suitable asymmetric encryption algorithm based on specific security requirements and performance requirements.

[0061] After selecting an asymmetric encryption algorithm, both parties in communication generate a pair of public and private keys. Taking the RSA algorithm as an example, the key generation process is as follows:

[0062] Select two large prime numbers p and q, calculate N = p*q; calculate the Euler function φ(N) = (p-1)*(q-1);

[0063] Choose an integer e that is less than φ(N) and relatively prime to φ(N) as the public key;

[0064] Calculate the modular inverse element d of e with respect to φ(N) as the private key;

[0065] The public key is (e,N) and the private key is (d,N).

[0066] The two communicating parties independently generate their own public and private key pairs and keep the private key safe; the public key can be made public.

[0067] After the public-private key pair is generated, the communicating parties need to authenticate and exchange keys to ensure the security of the communication. This process requires the participation of a trusted third party (such as a CA).

[0068] The two communicating parties submit their identity information and public keys to a trusted third party, which verifies the identity information and confirms the authenticity of the identity. After the verification, the trusted third party issues a digital certificate to the two communicating parties. The certificate contains the identity information and public key and is signed by the private key of the trusted third party.

[0069] The communicating parties exchange digital certificates and use the public key of a trusted third party to verify the validity of the certificates, thereby confirming the authenticity of the other party's identity.

[0070] On the basis of identity authentication, the two communicating parties use asymmetric encryption algorithms and key exchange protocols (such as Diffie-Hellman key exchange) to negotiate and generate a shared session key. The session key is used for symmetric encryption and message authentication in the subsequent data transmission process. After establishing the identity authentication model and completing the key exchange, the two communicating parties use the session key to encrypt the data to be transmitted and generate a message authentication code to ensure the confidentiality and integrity of the data.

[0071] In the data encryption process, symmetric encryption algorithms are used to encrypt data. Common symmetric encryption algorithms include AES, DES, etc. Compared with asymmetric encryption algorithms, symmetric encryption algorithms have higher computational efficiency and are suitable for encrypting large amounts of data. According to the sensitivity of the data and performance requirements, select the appropriate symmetric encryption algorithm and key length.

[0072] In an optional embodiment,

[0073] Establish an identity authentication model for both parties in communication, generate the corresponding public and private keys of both parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session keys of both parties in communication, including:

[0074] Based on the elliptic curve cryptography algorithm, the communicating parties use randomly selected elliptic curve parameters and base points to generate their own public and private keys. The private key is used for data encryption and session key decryption, and the public key is used for session key encryption. At the same time, the communicating parties use their identity as part of the public key to generate an identity-based public key.

[0075] The communicating parties submit the identity-based public key and identity identifier to the trusted third party through a secure channel. The trusted third party uses the received identity identifier to verify the true identities of the communicating parties through a two-way authentication protocol and check the matching of the submitted public key and identity identifier.

[0076] After identity authentication is passed, the trusted third party uses the identity identifier as a seed to generate a session key between the communicating parties through a key derivation function, and encrypts the session key using the public keys of the two communicating parties to generate an encrypted session key.

[0077] Exemplarily, in an identity authentication model based on Elliptic Curve Cryptography (ECC), both communicating parties first need to select appropriate elliptic curve parameters and a base point. After selecting the elliptic curve parameters and the base point, both communicating parties generate their own public-private key pairs. The private key is a randomly selected integer d, satisfying 0 < d < n, where n is the order of the elliptic curve. The public key is the product of the private key d and the base point G, denoted as P = dG.

[0078] To associate the identity information with the public key, both communicating parties use the identity identifier (such as username, device ID, etc.) as part of the public key. Specifically, the identity identifier is concatenated with the public key P or a hashing operation is performed to generate an identity-based public key PID. The concatenation method can be PID = (ID||P), where || represents the concatenation operation; the hashing operation method can be PID = Hash(ID||P), where Hash is a secure hashing function, such as SHA-256.

[0079] Both communicating parties submit the identity-based public key PID and the identity identifier ID to a trusted third party through a secure channel (such as SSL / TLS). The secure channel ensures the confidentiality and integrity of the data during transmission. After receiving the identity identifier and the public key submitted by both communicating parties, the trusted third party uses a mutual authentication protocol to verify the true identities of both communicating parties. The mutual authentication protocol can be based on a challenge-response mechanism, such as the SSL / TLS handshake protocol based on digital certificates. Both communicating parties need to provide digital certificates issued by the trusted third party, which contain the identity information and the public key and are signed by the private key of the trusted third party. The trusted third party confirms the authenticity of the identities of both communicating parties by verifying the validity and signature of the digital certificate.

[0080] After the identity authentication is passed, the trusted third party checks the matching of the submitted public key and the identity identifier. For the identity-based public key generated by the concatenation method, the trusted third party parses PID, extracts the identity identifier ID and the public key P, and checks whether the extracted identity identifier is consistent with the submitted identity identifier. For the identity-based public key generated by the hashing operation method, the trusted third party recalculates Hash(ID||P) and compares it with the submitted PID to verify its consistency.

[0081] After the identity authentication and the public key verification are passed, the trusted third party uses the identity identifier as a seed and generates a session key between the two communicating parties through a Key Derivation Function (KDF). Common KDFs include HKDF, PBKDF2, etc. Taking HKDF as an example, the generation process of the session key is as follows:

[0082] The identity ID is used as the input seed, and a pseudo-random key (PRK) is generated through the extraction phase of HKDF; the PRK is used as the input, and a session key SK of a specified length is generated through the expansion phase of HKDF.

[0083] In order to protect the confidentiality of the session key, the trusted third party uses the public keys of both parties to encrypt the session key. For party A, the trusted third party uses A's public key PA to encrypt the session key SK and generates an encrypted session key ESK_A; for party B, the trusted third party uses B's public key PB to encrypt the session key SK and generates an encrypted session key ESK_B.

[0084] The encryption process can use an encryption algorithm based on elliptic curves, such as the Elliptic Curve Integrated Encryption Scheme (ECIES). ECIES uses point multiplication operations on elliptic curves to implement encryption, which has high security and efficiency.

[0085] The trusted third party sends the encrypted session keys ESK_A and ESK_B to the communicating parties through a secure channel. After receiving the encrypted session keys, the communicating parties use their own private keys to decrypt and obtain the session key SK. The decryption process is the opposite of the encryption process. The communicating parties use their own private keys to perform point multiplication with the encryption point to obtain the session key.

[0086] Through the above steps, the two communicating parties have completed the identity authentication and session key negotiation, laying a secure foundation for subsequent data transmission. The use of session keys can protect the confidentiality and integrity of data between the two communicating parties and prevent data from being eavesdropped, tampered with or forged during transmission. At the same time, the identity-based public key and two-way authentication protocol ensure the authenticity of the identities of the two communicating parties and prevent identity forgery and man-in-the-middle attacks.

[0087] In an optional embodiment,

[0088] Using the session key, encrypting the data to be transmitted between the communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generating a first message authentication code based on the encrypted data packet through a hash function includes:

[0089] Using the session key, based on a symmetric encryption algorithm, padding processing is performed on the data to be transmitted between the communicating parties, wherein the padding processing calculates the difference between the length of the data to be transmitted and a preset packet length, determines the number of bytes required for padding according to the difference, and adds the required number of bytes for padding at the end of the data to be transmitted, so as to extend the length of the data to be transmitted after padding to an integer multiple of the preset packet length;

[0090] Encrypting the padded data to be transmitted, generating a pseudo-random number sequence of the same length as the padded data to be transmitted based on a symmetric encryption algorithm by using the session key and a randomly generated initial vector, and performing an XOR operation on the pseudo-random number sequence and the padded data to be transmitted to obtain an encrypted data packet, wherein the initial vector is a random value used to ensure the uniqueness of each encryption process;

[0091] Using a key derivation function, generating an internal key and an external key according to the session key, concatenating the internal key with the encrypted data packet to obtain first concatenated encrypted data, and performing a first SHA-256 hash operation on the first concatenated encrypted data to obtain a first hash value;

[0092] The external key is concatenated with the first hash value to obtain second concatenated encrypted data, a second SHA-256 hash operation is performed on the second concatenated encrypted data to obtain a second hash value, and the second hash value is used as a first message authentication code.

[0093] Exemplarily, before the data to be transmitted is encrypted, it is necessary to determine the preset packet length according to the selected symmetric encryption algorithm. Common symmetric encryption algorithms such as AES and DES usually have a packet length of 64 bits, 128 bits or 256 bits. Selecting a suitable packet length can balance security and efficiency. In order to ensure that the length of the data to be transmitted is an integer multiple of the preset packet length, the data to be transmitted needs to be padded.

[0094] After calculating the number of bytes required for padding, the padding bytes are added to the end of the data to be transmitted. The value of the padding bytes can be determined according to the specific padding scheme. Common padding schemes include PKCS7 padding, ISO 10126 padding, etc. The length of the data to be transmitted after padding will be extended to an integer multiple of the preset packet length, which is convenient for subsequent encryption processing.

[0095] In order to ensure the uniqueness of each encryption process, a randomly generated initialization vector (IV) is required to participate in the encryption process. The initialization vector is usually used together with the session key to initialize the state of the encryption algorithm. The length of the initialization vector is the same as the preset packet length and can be generated by a secure random number generator.

[0096] Using the session key and initialization vector, a pseudo-random number sequence of the same length as the padded data to be transmitted is generated based on the selected symmetric encryption algorithm. Taking the AES algorithm as an example, the pseudo-random number sequence generation process is as follows:

[0097] The session key and initial vector are used as inputs of the AES algorithm, and a series of round keys are generated through the key expansion process of the AES algorithm. The padded data to be transmitted is encrypted with the generated round keys to obtain a pseudo-random number sequence of the same length as the padded data to be transmitted.

[0098] Perform an XOR operation on the generated pseudo-random number sequence and the padded data to be transmitted to obtain an encrypted data packet. The XOR operation is reversible, that is, the encryption and decryption processes use the same operation. In order to enhance the security of the message authentication code, a key derivation function (KDF) can be used to derive the internal key and external key from the session key. Common KDFs include HKDF, PBKDF2, etc. Taking HKDF as an example, the derivation process of the internal key and the external key is as follows:

[0099] The session key is used as the input of HKDF, and a pseudo-random key (PRK) is generated through the Extract phase of HKDF; the PRK is used as the input, and an internal key and an external key of a specified length are generated through the Expand phase of HKDF.

[0100] Concatenate the internal key with the encrypted data packet to obtain the first concatenated encrypted data. The concatenation operation can be a simple byte-level concatenation or a specific encoding method such as ASN.1 encoding. Perform a first SHA-256 hash operation on the first concatenated encrypted data to obtain a first hash value. SHA-256 is a secure one-way hash function that can map an input of any length to a fixed-length output of 256 bits. Concatenate the external key with the first hash value to obtain the second concatenated encrypted data. Similarly, the concatenation operation can be a simple byte-level concatenation or a specific encoding method. Perform a second SHA-256 hash operation on the second concatenated encrypted data to obtain a second hash value, and use the second hash value as the first message authentication code.

[0101] Through two hash operations, a first message authentication code is generated to verify the integrity and authenticity of the data. The purpose of the two hash operations is to enhance the security of the message authentication code and prevent the message authentication code from being forged or tampered with. By splicing the encrypted data packet and the message authentication code together, the receiver can verify the confidentiality and integrity of the data at the same time.

[0102] During the data transmission and verification phase, the sender sends the complete encrypted message to the receiver through the network channel. After receiving the encrypted message, the receiver recovers the original data and verifies its integrity and authenticity through the decryption and verification process. The decryption process is the opposite of the encryption process. The receiver uses the session key and initialization vector to decrypt the encrypted data packet through the symmetric decryption algorithm, removes the padding bytes, and obtains the original data to be transmitted.

[0103] In an optional embodiment,

[0104] Using a key derivation function, generating an internal key and an external key according to the session key, and concatenating the internal key with the encrypted data packet to obtain first concatenated encrypted data includes:

[0105] (K int ,K ext )=KDF(K session ,CTX int ,CTX ext ,L int ,L ext );

[0106] Among them, K int , K ext They represent internal key and external key respectively, KDF() represents key derivation function, K session Indicates the session key, CTX int , CTX ext Represents the context information of the internal key and the external key respectively, L int , L ext Represents the bit length of the internal key and the external key respectively;

[0107] E concat1 =Concat(K int ,E data ,Pad int ,L int );

[0108] Among them, E concat1 represents the first concatenated encrypted data, Concat() represents the concatenation function, K int represents the internal key, E data Indicates encrypted data packets, Pad int , L int They respectively represent the padding data of the internal key and the bit length of the internal key.

[0109] This application avoids directly using the session key to calculate the message authentication code by deriving the internal key and the external key from the session key using a key derivation function. The derivation process of the internal key and the external key introduces context information and key length parameters, which increases the randomness and diversity of the key derivation process and improves the security of the derived key. The key derivation function generates internal keys and external keys for different purposes, thereby achieving the versatility of the key. The internal key is used for the first hash operation, and the external key is used for the second hash operation. The scope and function of different keys are isolated, and even if one key is leaked, it will not affect the security of other keys.

[0110] The input parameters of the key derivation function include the session key, context information, and key length, which provides flexibility in the key derivation process. By introducing context information, business-related metadata can be associated with the key derivation process, enhancing the semantics and adaptability of key derivation. By specifying the key length, keys of different lengths can be generated according to security requirements and performance requirements.

[0111] The message authentication code is generated by two hash operations, which enhances the anti-collision and robustness of the message authentication code. The first hash operation introduces the internal key and the encrypted data packet, and the second hash operation introduces the external key and the first hash result. The introduction of multiple hashes and keys improves the message authentication code's collision resistance and ability to resist attacks.

[0112] S102. Concatenate the encrypted data packet and the first message authentication code to construct a complete encrypted message, and send the complete encrypted message to a trusted third party through a network channel; after receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data;

[0113] In an optional embodiment,

[0114] After receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data, including:

[0115] The trusted third party extracts the encrypted data packet, the initialization vector, the timestamp and the random number from the complete encrypted message; and dynamically generates a master key based on the session key and the random number using a key derivation function;

[0116] Decrypting and verifying the integrity of the encrypted data packet using the master key and the initial vector based on the authenticated encryption mode of the AES-256 algorithm to obtain the original data;

[0117] A second message authentication code corresponding to the original data is generated based on the original data by using the hash function.

[0118] For example, after receiving the complete encrypted message, the trusted third party first needs to extract the encrypted data packet from the message. The encrypted data packet is the ciphertext obtained by encrypting the original data using a symmetric encryption algorithm. The extraction process can be parsed according to the structure and format of the complete encrypted message. Usually, the encrypted data packet is located at a specific position of the message or is identified by a specific delimiter.

[0119] The initialization vector is a random value used in the encryption process to ensure the uniqueness of each encryption process. A trusted third party needs to extract the initialization vector from the complete encrypted message for use in the decryption process. The initialization vector is usually transmitted together with the encrypted data packet and can be obtained by parsing the message structure or a specific identifier.

[0120] The timestamp is the time point when the message is generated. It is used to verify the timeliness of the message and prevent replay attacks. The trusted third party needs to extract the timestamp from the complete encrypted message and check the timestamp in the subsequent verification process to ensure the validity of the message. The timestamp can be transmitted as part of the message and obtained by parsing the message structure.

[0121] A random number is a random value generated during the message generation process, which is used to enhance the randomness and unpredictability of the encryption process. The trusted third party needs to extract the random number from the complete encrypted message and use it in the subsequent key derivation process. The random number can be transmitted as part of the message and obtained by parsing the message structure. In order to dynamically generate the master key, the trusted third party needs to use a key derivation function (KDF). Common key derivation functions include HKDF, PBKDF2, etc. Selecting an appropriate key derivation function requires considering factors such as security, efficiency, and standardization.

[0122] The input of the key derivation function includes the session key and the random number. The session key is a symmetric key shared by both parties to protect the confidentiality and integrity of data during the communication process. The random number is a random value extracted from the complete encrypted message to enhance the randomness and unpredictability of the key derivation process.

[0123] Using the key derivation function, the master key is dynamically generated based on the session key and the random number. Taking HKDF as an example, the derivation process of the master key is as follows:

[0124] The session key and random number are used as inputs of HKDF, and a pseudorandom key (PRK) is generated through the Extract phase of HKDF; the PRK is used as input, and a master key of a specified length is generated through the Expand phase of HKDF.

[0125] The trusted third party uses the authenticated encryption mode of the AES-256 algorithm to decrypt and verify the integrity of the encrypted data packet. Authenticated encryption mode is an encryption mode that integrates encryption and integrity verification. Common authenticated encryption modes include GCM (Galois / Counter Mode) and CCM (Counter with CBC-MAC).

[0126] Using the master key and initial vector, the encrypted data packet is decrypted based on the authenticated encryption mode of the AES-256 algorithm. Taking the GCM mode as an example, the decryption process is as follows:

[0127] The master key is used as the key of the AES algorithm, and the initial vector is used as the initial counter value of the GCM mode; the inverse encryption operation of the AES algorithm is used to decrypt the encrypted data packet to obtain the plaintext data and the authentication tag; the decrypted plaintext data is concatenated with the authentication tag to obtain the original data.

[0128] During the decryption process, the authenticated encryption mode also performs integrity verification. The purpose of integrity verification is to ensure that the data has not been tampered with or forged during transmission. Taking the GCM mode as an example, the integrity verification process is as follows:

[0129] During the decryption process, the GCM mode calculates an authentication tag, which is calculated based on the plaintext data, additional data (such as the initial vector) and the master key; the calculated authentication tag is compared with the authentication tag carried in the encrypted data packet. If the two are consistent, the integrity of the data is verified; otherwise, the data may be tampered with or forged.

[0130] The trusted third party uses a hash function to hash the original data and generate a second message authentication code. Common hash functions include SHA-256, SHA-3, etc. Selecting a suitable hash function requires considering factors such as security, efficiency, and standardization.

[0131] Generate a second message authentication code based on the original data through a hash function. The hash operation process is as follows:

[0132] The original data is used as the input of the hash function; the original data is hashed to obtain a hash value of a fixed length; the hash value is used as the second message authentication code. The second message authentication code is used to verify the integrity and authenticity of the original data. By comparing the second message authentication code with the first message authentication code generated by the sender, it can be ensured that the original data has not been tampered with or forged.

[0133] S103. Perform two rounds of comparison on the first message authentication code and the second message authentication code. If both rounds of comparison are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any one of the two rounds of comparison is inconsistent, the security measures are triggered.

[0134] In an optional embodiment,

[0135] The first message authentication code and the second message authentication code are compared twice. If the two comparisons are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any of the two comparisons is inconsistent, the security measures are triggered, including:

[0136] Respectively generate a first random mask having the same length as the first message authentication code and a second random mask having the same length as the second message authentication code, wherein the first random mask and the second random mask are different;

[0137] Using a constant time comparison function to compare each bit of the first message authentication code and the second message authentication code by a bit-by-bit XOR operation, and accumulating XOR results, and finally determining whether the first message authentication code and the second message authentication code match according to whether the accumulated XOR results are zero;

[0138] If the first round of comparison results in a mismatch, the comparison process is terminated and safety measures are triggered; if the first round of comparison results in a match, the second round of comparison is continued;

[0139] Performing hash operations on the first message authentication code and the second message authentication code based on a pre-selected hash function to determine a first hash value corresponding to the first message authentication code and a second hash value corresponding to the second message authentication code;

[0140] If the first hash value and the second hash value match, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing.

[0141] Exemplarily, in order to prevent time side channel attacks, the trusted third party first generates a first random mask of the same length as the first message authentication code when performing message authentication code comparison. The first random mask can be generated using a secure random number generator to ensure the randomness and unpredictability of the mask. Similarly, the trusted third party generates a second random mask of the same length as the second message authentication code. The generation of the second random mask is the same as the first random mask, but it is ensured that the two masks are different to increase the randomness of the comparison process.

[0142] The constant time comparison function is used to compare each bit of the first message authentication code and the second message authentication code and accumulate the XOR results. The implementation steps of the constant time comparison function are as follows:

[0143] Perform bit-by-bit XOR operation on each bit of the first message authentication code and the second message authentication code to obtain an XOR result; perform XOR operation on the XOR result and the corresponding bit of the first random mask to obtain a masked XOR result; accumulate the masked XOR result into a variable as a comparison result; repeat the above steps until all bits are compared; compare the accumulated comparison result with zero, if it is zero, it means that the first message authentication code and the second message authentication code match, otherwise they do not match.

[0144] The constant time comparison function ensures the constant time of the comparison process through bit-by-bit XOR operation and mask operation to prevent time side channel attacks. Based on the comparison results of the constant time comparison function, the trusted third party determines the results of the first round of comparison:

[0145] If the comparison result is a mismatch, the comparison process is terminated and security measures are triggered, such as logging and sending alarms; if the comparison result is a match, the second round of comparison is continued.

[0146] The trusted third party pre-selects a secure hash function for hashing the message authentication code. Common hash functions include SHA-256, SHA-3, etc. The selection of a hash function needs to consider factors such as security, efficiency, and standardization.

[0147] Based on the pre-selected hash function, the trusted third party performs a hash operation on the first message authentication code to obtain a first hash value corresponding to the first message authentication code. The hash operation process is as follows:

[0148] The first message authentication code is used as an input of a hash function; a hash operation is performed on the first message authentication code to obtain a hash value of a fixed length; and the hash value is used as a first hash value.

[0149] Similarly, the trusted third party performs a hash operation on the second message authentication code to obtain a second hash value corresponding to the second message authentication code. The hash operation process is the same as the hash operation of the first message authentication code.

[0150] The trusted third party compares the first hash value with the second hash value:

[0151] If the first hash value and the second hash value match, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if the first hash value and the second hash value do not match, security measures are triggered, such as recording logs, sending alarms, etc.

[0152] If the comparison result of the constant time comparison function is not a match in the first round of comparison, the trusted third party triggers the corresponding security measures:

[0153] Record logs: record the events of inconsistent comparison in the security log, including time, message authentication code, comparison results and other information; send alarms: send alarms to administrators or security monitoring systems to notify of inconsistent comparisons; block data transmission: stop transmitting original data to the application layer to prevent possible data tampering or forgery; start fault recovery mechanism: take corresponding recovery measures according to predefined fault recovery strategies, such as re-requesting data, switching to backup channels, etc.

[0154] Figure 2 FIG. 1 is a structural diagram of a data security transmission system based on an autonomous security interaction protocol according to an embodiment of the present invention. Figure 2 As shown, the system comprises:

[0155] The first unit is used to establish an identity authentication model for both communicating parties, generate public keys and private keys corresponding to both communicating parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain a session key for both communicating parties; use the session key to encrypt the data to be transmitted by the two communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generate a first message authentication code based on the encrypted data packet through a hash function;

[0156] The second unit is used to concatenate the encrypted data packet with the message authentication code to construct a complete encrypted message, and send it to a trusted third party through a network channel; after receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet through a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data through a hash function based on the original data;

[0157] The third unit is used to perform two rounds of comparison on the first message authentication code and the second message authentication code. If the two rounds of comparison are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any one of the two rounds of comparison is inconsistent, the security measures are triggered.

[0158] According to a third aspect of the embodiments of the present invention,

[0159] An electronic device is provided, comprising:

[0160] processor;

[0161] a memory for storing processor-executable instructions;

[0162] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.

[0163] A fourth aspect of the embodiments of the present invention is:

[0164] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.

[0165] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.

[0166] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data security transmission method based on an autonomous security interaction protocol, characterized in that: include: Establish an identity authentication model for both parties in communication, generate the corresponding public and private keys of both parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session keys of both parties in communication; Using the session key, encrypting the data to be transmitted between the communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generating a first message authentication code based on the encrypted data packet through a hash function; Concatenate the encrypted data packet with the first message authentication code to construct a complete encrypted message, and send the complete encrypted message to a trusted third party through a network channel; After receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data; The first message authentication code and the second message authentication code are compared twice. If the two comparisons are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any of the two comparisons is inconsistent, the security measures are triggered, including: Respectively generate a first random mask having the same length as the first message authentication code and a second random mask having the same length as the second message authentication code, wherein the first random mask and the second random mask are different; Using a constant time comparison function to compare each bit of the first message authentication code and the second message authentication code by a bit-by-bit XOR operation, and accumulating XOR results, and finally determining whether the first message authentication code and the second message authentication code match according to whether the accumulated XOR results are zero; If the first round of comparison results in a mismatch, the comparison process is terminated and safety measures are triggered; if the first round of comparison results in a match, the second round of comparison is continued; Performing hash operations on the first message authentication code and the second message authentication code based on a pre-selected hash function to determine a first hash value corresponding to the first message authentication code and a second hash value corresponding to the second message authentication code; If the first hash value and the second hash value match, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing.

2. The method according to claim 1, characterized in that Establish an identity authentication model for both parties in communication, generate the corresponding public and private keys of both parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session keys of both parties in communication, including: Based on the elliptic curve cryptography algorithm, the communicating parties use randomly selected elliptic curve parameters and base points to generate their own public and private keys. The private key is used for data encryption and session key decryption, and the public key is used for session key encryption. At the same time, the communicating parties use their identity as part of the public key to generate an identity-based public key. The communicating parties submit the identity-based public key and identity identifier to the trusted third party through a secure channel. The trusted third party uses the received identity identifier to verify the true identities of the communicating parties through a two-way authentication protocol and check the matching of the submitted public key and identity identifier. After identity authentication is passed, the trusted third party uses the identity identifier as a seed to generate a session key between the communicating parties through a key derivation function, and encrypts the session key using the public keys of the two communicating parties to generate an encrypted session key.

3. The method according to claim 1, characterized in that Using the session key, encrypting the data to be transmitted between the communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generating a first message authentication code based on the encrypted data packet through a hash function includes: Using the session key, based on a symmetric encryption algorithm, padding processing is performed on the data to be transmitted between the communicating parties, wherein the padding processing calculates the difference between the length of the data to be transmitted and a preset packet length, determines the number of bytes required for padding according to the difference, and adds the required number of bytes for padding at the end of the data to be transmitted, so as to extend the length of the data to be transmitted after padding to an integer multiple of the preset packet length; Encrypting the padded data to be transmitted, generating a pseudo-random number sequence of the same length as the padded data to be transmitted based on a symmetric encryption algorithm by using the session key and a randomly generated initial vector, and performing an XOR operation on the pseudo-random number sequence and the padded data to be transmitted to obtain an encrypted data packet, wherein the initial vector is a random value used to ensure the uniqueness of each encryption process; Using a key derivation function, generating an internal key and an external key according to the session key, concatenating the internal key with the encrypted data packet to obtain first concatenated encrypted data, and performing a first SHA-256 hash operation on the first concatenated encrypted data to obtain a first hash value; The external key is concatenated with the first hash value to obtain second concatenated encrypted data, a second SHA-256 hash operation is performed on the second concatenated encrypted data to obtain a second hash value, and the second hash value is used as a first message authentication code.

4. The method according to claim 3, characterized in that Using a key derivation function, generating an internal key and an external key according to the session key, and concatenating the internal key with the encrypted data packet to obtain first concatenated encrypted data includes: (K int ,K ext )=KDF(K session ,CTX int ,CTX ext ,L int ,L ext ); Among them, K int , K ext They represent the internal key and the external key respectively, KDF() represents the key derivation function, K session Indicates the session key, CTX int , CTX ext Represents the context information of the internal key and the external key respectively, L int , L ext Represents the bit length of the internal key and the external key respectively; AND concat1 =Concat(K int ,AND data ,pad int ,THE int ); Among them, E concat1 represents the first concatenated encrypted data, Concat() represents the concatenation function, K int represents the internal key, E data Indicates encrypted data packets, Pad int , L int They respectively represent the padding data of the internal key and the bit length of the internal key.

5. The method according to claim 1, characterized in that After receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data, including: The trusted third party extracts the encrypted data packet, the initialization vector, the timestamp and the random number from the complete encrypted message; and dynamically generates a master key based on the session key and the random number using a key derivation function; Decrypting and verifying the integrity of the encrypted data packet using the master key and the initial vector based on the authenticated encryption mode of the AES-256 algorithm to obtain the original data; A second message authentication code corresponding to the original data is generated based on the original data by using the hash function.

6. A data security transmission system based on an autonomous security interaction protocol, used to implement the method described in any one of claims 1 to 5, characterized in that: include: The first unit is used to establish an identity authentication model for both parties in communication, generate the corresponding public and private keys of both parties through an asymmetric encryption algorithm, and perform identity authentication and key exchange through a trusted third party to obtain the session keys of both parties in communication; Using the session key, encrypting the data to be transmitted between the communicating parties through a symmetric encryption algorithm to generate an encrypted data packet, and generating a first message authentication code based on the encrypted data packet through a hash function; The second unit is used to concatenate the encrypted data packet with the message authentication code to construct a complete encrypted message, and send it to a trusted third party through a network channel; After receiving the complete encrypted message, the trusted third party decrypts the encrypted data packet using a symmetric encryption algorithm based on the session key to obtain the original data, and generates a second message authentication code corresponding to the original data using a hash function based on the original data; The third unit is used to perform two rounds of comparison on the first message authentication code and the second message authentication code. If the two rounds of comparison are consistent, it is confirmed that the data has not been tampered with, and the original data is passed to the application layer for subsequent processing; if any one of the two rounds of comparison is inconsistent, the security measures are triggered.

7. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 5.

8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Information safety algorithm based on energy information gateway in smart power grid

    CN103618610A

  • Lightweight anonymous authentication method suitable for resource-limited equipment

    CN111130758A