Hybrid encryption and decryption method, electronic device, and storage medium

By organically integrating the national secret algorithm and the post-quantum cryptographic algorithm, and using client keys and client post-quantum keys to encrypt and decrypt the target plaintext, the security issues of the existing encryption system under quantum computing attacks are solved, and compatibility and security in the post-quantum era are achieved.

CN119382960BActive Publication Date: 2025-10-10中电信量子信息科技集团有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411492361.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-10-10
Estimated Expiration
2044-10-24

AI Technical Summary

Technical Problem

Existing classical encryption systems such as RSA, ECC, and SM2 pose huge security risks when facing quantum computing attacks. How to balance the requirements of existing cryptographic systems and provide security capabilities in the post-quantum era is an issue that needs to be addressed urgently.

Method used

A hybrid encryption and decryption method is adopted to organically integrate the national secret algorithm and the post-quantum cryptographic algorithm, and the client key and the client post-quantum key are used to encrypt and decrypt the target plaintext, thereby increasing the ability to resist quantum computing attacks.

Benefits of technology

While meeting the existing security level requirements, it provides security capabilities in the post-quantum era, has strong compatibility, can prevent "store first and then decrypt" attacks, and realize the migration of national encryption algorithms to post-quantum algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119382960B_ABST
    Figure CN119382960B_ABST
Patent Text Reader

Abstract

The application provides a hybrid encryption and decryption method, an electronic device and a storage medium. The method comprises the following steps: receiving an encryption request sent by a first client, encrypting a target plaintext according to a client national cryptographic public key and a client post-quantum public key of a second client to obtain a hybrid encryption ciphertext, and sending the hybrid encryption ciphertext to the first client, so that the first client sends the hybrid encryption ciphertext to the second client. The second client is used for sending a decryption request to a server, the decryption request comprising the hybrid encryption ciphertext, decrypting the hybrid encryption ciphertext according to a client national cryptographic private key and a client post-quantum private key of the second client to obtain the target plaintext, and sending the target plaintext to the second client. The national cryptographic algorithm and the post-quantum cryptographic algorithm are organically fused, the ability to resist quantum computing attacks is increased, the security of the target plaintext is ensured, and the security ability in the post-quantum era can be provided while meeting the existing security level requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data security technology, and in particular to a hybrid encryption and decryption method, an electronic device, and a storage medium. Background Art

[0002] With the advancement of computing power and mathematics, classical encryption systems that rely on computational complexity are facing a significant threat. Quantum algorithms can crack difficult problems such as integer factorization and discrete logarithms. Encryption mechanisms based on classical asymmetric cryptographic algorithms such as RSA, ECC, and SM2 face significant security risks in the post-quantum era.

[0003] At present, the PQC cryptographic algorithm can effectively resist quantum computing attacks and meet the security requirements of the post-quantum era. However, how to balance the requirements of the existing cryptographic system and provide security capabilities in the post-quantum era is an urgent problem that needs to be solved. Summary of the Invention

[0004] In view of this, the embodiments of the present application provide a hybrid encryption and decryption method, electronic device and storage medium, which are compatible with both national secret algorithms and post-quantum cryptographic algorithms, and increase the ability to resist quantum computing attacks, thereby ensuring the security of the target plaintext.

[0005] In a first aspect, an embodiment of the present application provides a hybrid encryption and decryption method, applied to a server, the method comprising:

[0006] receiving an encryption request sent by a first client, wherein the encryption request includes: a target plaintext;

[0007] Encrypt the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain a hybrid encrypted ciphertext;

[0008] Sending the hybrid encrypted ciphertext to the first client, so that the first client sends the hybrid encrypted ciphertext to the second client, and the second client is configured to send a decryption request to the server, wherein the decryption request includes: the hybrid encrypted ciphertext;

[0009] Decrypting the hybrid encrypted ciphertext according to the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext;

[0010] Send the target plaintext to the second client.

[0011] In an optional embodiment, encrypting the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain a hybrid encrypted ciphertext includes:

[0012] encrypt the target plaintext according to the client national secret key to obtain first ciphertext;

[0013] generate a target key and key ciphertext of the target key according to the preset key packaging function and the client post-quantum key;

[0014] generate second ciphertext according to the target key and the first ciphertext;

[0015] generate the hybrid encryption ciphertext according to the first ciphertext, the second ciphertext and the key ciphertext.

[0016] In an optional implementation, the generating second ciphertext according to the target key and the first ciphertext comprises:

[0017] generate a derivative key according to the target key and a preset key derivation function;

[0018] generate the second ciphertext according to the derivative key and the first ciphertext.

[0019] In an optional implementation, the generating a derivative key according to the target key and a preset key derivation function comprises:

[0020] obtain the plaintext length of the target plaintext;

[0021] generate a derivative key according to the target key and the plaintext length and a preset key derivation function.

[0022] In an optional implementation, the first ciphertext is composed of a first spliced ciphertext, a second spliced ciphertext and a third spliced ciphertext; and the generating the second ciphertext according to the derivative key and the first ciphertext comprises:

[0023] performing exclusive or operation on the derivative key and the second spliced ciphertext to obtain the second ciphertext;

[0024] The generating the hybrid encryption ciphertext according to the first ciphertext, the second ciphertext and the key ciphertext comprises:

[0025] splicing the first spliced ciphertext, the second ciphertext, the third spliced ciphertext and the key ciphertext to generate the hybrid encryption ciphertext.

[0026] In an optional implementation, the encryption request further comprises a public key index of the second client; and before the encrypting the target plaintext according to the client national secret key and the client post-quantum key of the second client to obtain the hybrid encryption ciphertext, the method further comprises:

[0027] According to the public key index, the client's national secret public key and the client's post-quantum public key are queried.

[0028] In an optional embodiment, decrypting the hybrid encrypted ciphertext according to the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext includes:

[0029] Parsing the mixed encrypted ciphertext to obtain a first concatenated ciphertext, a second concatenated ciphertext, a third concatenated ciphertext, and the key ciphertext;

[0030] Decrypt the key ciphertext using a preset key decryption function according to the client post-quantum private key to obtain the target key;

[0031] Generate a derived key using a preset key derivation function according to the target key;

[0032] Performing an XOR operation on the derived key and the second ciphertext to obtain a second concatenated ciphertext;

[0033] Obtaining the first ciphertext according to the first concatenated ciphertext, the second concatenated ciphertext, and the third concatenated ciphertext;

[0034] The first ciphertext is decrypted according to the client's national secret private key to obtain the target plaintext.

[0035] In an optional embodiment, the decryption request further includes: a private key index of the second client; and before decrypting the hybrid encrypted ciphertext based on the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext, the method further includes:

[0036] According to the private key index, query the client's national secret private key and the client's post-quantum private key.

[0037] In a third aspect, an embodiment of the present application further provides an electronic device comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory through the bus, and the processor executes the machine-readable instructions to execute any one of the methods described in the first aspect.

[0038] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method described in any one of the first aspects is executed.

[0039] The present application provides a hybrid encryption and decryption method, electronic device, and storage medium. The method includes: receiving an encryption request sent by a first client; encrypting a target plaintext based on a second client's national secret public key and a client's post-quantum public key to obtain a hybrid encrypted ciphertext; sending the hybrid encrypted ciphertext to the first client so that the first client sends the hybrid encrypted ciphertext to the second client; the second client is configured to send a decryption request to a server, the decryption request including the hybrid encrypted ciphertext; decrypting the hybrid encrypted ciphertext based on the second client's national secret private key and a client's post-quantum private key to obtain a target plaintext; and sending the target plaintext to the second client. By organically integrating the national secret algorithm and the post-quantum cryptographic algorithm, the ability to resist quantum computing attacks is increased, the security of the target plaintext is guaranteed, and while meeting existing security level requirements, security capabilities in the post-quantum era can also be provided. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0041] Figure 1 Schematic diagram of the hybrid encryption and decryption method provided in this embodiment Figure 1 ;

[0042] Figure 2 Schematic diagram of the hybrid encryption and decryption method provided in this embodiment Figure 2 ;

[0043] Figure 3 A schematic diagram of a specific national secret encryption process provided in an embodiment of the present application;

[0044] Figure 4 A schematic diagram of a specific hybrid encryption process provided in an embodiment of the present application;

[0045] Figure 5 Schematic diagram of the hybrid encryption and decryption method provided in this embodiment Figure 3 ;

[0046] Figure 6 A schematic diagram of a specific national secret decryption process provided in an embodiment of the present application;

[0047] Figure 7 A schematic diagram of a specific hybrid decryption process provided in an embodiment of the present application;

[0048] Figure 8A schematic diagram of the structure of the hybrid encryption and decryption system provided in an embodiment of the present application;

[0049] Figure 9 A schematic diagram of the structure of a hybrid encryption and decryption device provided in an embodiment of the present application;

[0050] Figure 10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.

[0052] First, let’s explain the professional terms involved in this application:

[0053] Post-Quantum Cryptography (PQC): A branch of cryptography aimed at researching and developing encryption algorithms that are resistant to quantum computing attacks. Based on quantum mechanics, its security is established by physical properties such as the uncertainty principle, quantum non-cloning, and quantum coherence, and has been proven to be unconditionally secure. Furthermore, quantum key distribution technology, based on quantum mechanics, ensures that the key distribution process cannot be effectively eavesdropped due to the non-cloning, uncertainty, and measurement collapse of quantum states. This represents a new generation of cryptographic algorithms that can withstand quantum computer attacks on existing cryptographic algorithms. Traditional public key encryption algorithms (such as RSA, DSA, and ECC) may be vulnerable to cracking in the presence of large-scale quantum computers, as quantum computers have the computing power required to crack traditional encryption algorithms.

[0054] Elliptic Curve Cryptography (ECC): An asymmetric encryption algorithm based on elliptic curve mathematics, whose security is based on the discrete logarithm problem on elliptic curves.

[0055] National secret algorithm: Domestic cryptographic algorithms, mainly SM1, SM2, SM3, and SM4. Among them, SM2 is an ECC elliptic curve asymmetric encryption algorithm. The SM2 algorithm has been widely used in the security field, but the security of these applications faces huge threats from quantum computing.

[0056] To facilitate understanding of the technical solutions provided by the embodiments of the present application, the technical background involved in the present application is described below.

[0057] As application system security gains widespread attention, collaborative encryption is often used for data encryption. Collaborative encryption is a method for protecting data confidentiality by enabling secure data transmission through multi-party collaboration. Collaborative encryption algorithms typically have a public key that is publicly available, and multiple members possess their own private keys. Encryption uses the public key to perform operations on data, while decryption requires the collaboration of multiple members to decrypt the plaintext data.

[0058] With the improvement of computer capabilities and the advancement of mathematics, classical encryption systems that rely on computational complexity pose a huge threat. Quantum algorithms can crack difficult problems such as integer factorization and discrete logarithms. Encryption mechanisms based on classic asymmetric cryptographic algorithms such as RSA, ECC, and SM2 face huge security risks in the post-quantum era.

[0059] The PQC cryptographic algorithm can effectively resist quantum computing attacks and meet the security requirements of the post-quantum era. However, the PQC cryptographic algorithm also suffers from a lack of effective security proof and an inability to meet existing security assessment standards. Therefore, how to balance the requirements of existing cryptographic systems with the security capabilities of the post-quantum era is an urgent problem that needs to be solved.

[0060] Based on this, this application organically integrates the national secret algorithm and the post-quantum cryptographic algorithm, and uses client keys and client post-quantum keys to encrypt and decrypt the target plaintext, thereby increasing the ability to resist quantum computing attacks and ensuring the security of the target plaintext. While meeting the existing security level requirements, it can also provide security capabilities in the post-quantum era. Moreover, it can be compatible with both the national secret algorithm and the post-quantum cryptographic algorithm at the same time, and has strong compatibility.

[0061] Figure 1 Schematic diagram of the hybrid encryption and decryption method provided in this embodiment Figure 1 , the execution subject of this embodiment may be a server.

[0062] like Figure 1 As shown, the method may include:

[0063] S101: Receive an encryption request sent by a first client.

[0064] The target plaintext is the plaintext to be sent by the first client. The first client is the sending client and the second client is the receiving client. To ensure data security, the first client can send an encryption request to the server. The encryption request includes: the target plaintext. Accordingly, the server receives the encryption request sent by the first client.

[0065] It is worth noting that the user can input an encryption operation for the target plaintext through the first client, and the first client sends an encryption request to the server in response to the encryption operation.

[0066] S102. Encrypt the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain a hybrid encrypted ciphertext.

[0067] Among them, the client's national secret public key is the public key corresponding to the national secret algorithm generated in advance for the second client, and the national secret algorithm can be SM2. The client's post-quantum public key is the public key corresponding to the post-quantum cryptographic algorithm generated in advance for the second client.

[0068] The server obtains the client's national secret public key and the client's post-quantum public key, and encrypts the target plaintext according to the client's national secret public key and the client's post-quantum public key to obtain a hybrid encrypted ciphertext. That is to say, the server uses a hybrid encryption method of the national secret algorithm and the post-quantum cryptographic algorithm to encrypt the target plaintext to obtain a hybrid encrypted ciphertext.

[0069] In an optional embodiment, the encryption request further includes: a public key index of the second client. In step S102, before encrypting the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain the hybrid encrypted ciphertext, the method may further include:

[0070] According to the public key index, query the client's national secret public key and the client's post-quantum public key.

[0071] Among them, the server stores multiple pairs of national secret public and private keys (i.e. key pairs) and multiple pairs of post-quantum public and private keys. The encryption request also includes: the public key index of the second client, and the public key index includes: the national secret public key index and the post-quantum public key index. The server queries the stored multiple pairs of national secret public and private keys and multiple pairs of post-quantum public and private keys based on the public key index to determine the client national secret public key and client post-quantum public key of the second client.

[0072] S103: Send the hybrid encrypted ciphertext to the first client, so that the first client sends the hybrid encrypted ciphertext to the second client.

[0073] The server sends the hybrid encryption ciphertext to the first client, and the first client can send the hybrid encryption ciphertext to the second client. When the second client receives the hybrid encryption ciphertext, the second client can send a decryption request to the server, and the decryption request includes the hybrid encryption ciphertext.

[0074] It is worth noting that the user can input a sending operation for the hybrid encryption ciphertext through the first client, and the first client sends the hybrid encryption ciphertext to the second client in response to the sending operation.

[0075] In addition, the user can also input a decryption operation for the hybrid encryption ciphertext through the second client, and the second client sends a decryption request to the server in response to the decryption operation.

[0076] S104, according to the client national secret key and the client post quantum private key of the second client, the hybrid encryption ciphertext is decrypted to obtain the target plaintext.

[0077] Among them, the client national secret key is the private key corresponding to the national secret algorithm generated in advance for the second client, and the client post quantum private key is the private key corresponding to the post quantum algorithm generated in advance for the second client.

[0078] The server obtains the client national secret key and the client post quantum private key, and decrypts the hybrid encryption ciphertext according to the client national secret key and the client post quantum private key to obtain the target plaintext, that is, the hybrid encryption ciphertext is decrypted by using the national secret algorithm and the post quantum algorithm to obtain the target plaintext.

[0079] In an optional implementation, the decryption request further includes a private key index of the second client; before the step S104 of decrypting the hybrid encryption ciphertext according to the client national secret key and the client post quantum private key of the second client to obtain the target plaintext, the method can further include:

[0080] According to the private key index, the client national secret key and the client post quantum private key are queried.

[0081] Among them, the server stores multiple pairs of national secret public and private keys and multiple pairs of post quantum public and private keys, and the decryption request further includes a private key index of the second client, the private key index includes a national secret private key index and a post quantum private key index, and the server queries the stored multiple pairs of national secret public and private keys and multiple pairs of post quantum public and private keys according to the private key index to determine the client national secret key and the client post quantum private key of the second client.

[0082] S105, the target plaintext is sent to the second client.

[0083] The server sends the target plaintext decrypted to the second client, so that the second client can receive the target plaintext from the first client.

[0084] In this embodiment, by organically integrating the national secret algorithm and the post-quantum cryptographic algorithm, the client key and the client post-quantum key are used to encrypt and decrypt the target plaintext, thereby increasing the ability to resist quantum algorithms on the basis of the existing national secret algorithm.

[0085] Figure 2 Schematic diagram of the hybrid encryption and decryption method provided in this embodiment Figure 2 ,like Figure 2 As shown, in an optional embodiment, the above step S102, encrypting the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain the hybrid encrypted ciphertext, may include:

[0086] S201. Encrypt the target plaintext according to the client's national secret public key to obtain a first ciphertext.

[0087] According to the client's national secret public key, the target plaintext is encrypted to obtain the first ciphertext. The client's national secret public key is denoted as PB, and the first ciphertext is denoted as C.

[0088] The generation process of the first ciphertext can be found in Figure 3 , the target plaintext is the bit string M, the plaintext length is the bit length denoted as klen, Figure 3 A schematic diagram of a specific national secret encryption process provided in an embodiment of the present application is as follows: Figure 3 As shown, the following steps are included:

[0089] Step 1: Generate a random number k, calculate the elliptic curve point C1=[k]G=(x1, y1) based on the random number k, and convert the data of C1 into a bit string.

[0090] Where G is the n-th order point on the elliptic curve.

[0091] Step 3. Calculate [k]P B =(x2,y2).

[0092] Step 4: Calculate t = KDF(x2||y2, klen).

[0093] KDF is a key derivation function based on a digest function used by SM2, which is used to derive another key based on a password. x2||y2 means concatenating x2 and y2.

[0094] Step 5. Calculation

[0095] It means that the XOR operation of M and t is performed to obtain C2.

[0096] Step 6: Calculate C3 = Hash(x2||M||y2).

[0097] Hash uses the SM3 algorithm, and x2||M||y2 means concatenating x2, M, and y2.

[0098] Step 7: First ciphertext C=C1||C2||C3.

[0099] C1||C2||C3 means that the first ciphertext C is obtained by concatenating C1, C2, and C3, and C1, C2, and C3 respectively represent the first concatenated ciphertext, the second concatenated ciphertext, and the third concatenated ciphertext.

[0100] S202: Generate a target key and a key ciphertext of the target key based on the client's post-quantum public key using a preset key encapsulation function.

[0101] The preset key encapsulation function is used to generate the target key and encrypt the target key according to the client's post-quantum public key to obtain the key ciphertext of the target key, where the client's post-quantum public key is denoted as P BPQC , for example, it can be the ML-KEM algorithm public key, the target key is recorded as key, and the key ciphertext is recorded as C4.

[0102] A preset key encapsulation function is used to generate a target key, and the target key is encrypted according to the client's post-quantum public key to obtain a key ciphertext, wherein the length of the target key can be, for example, 32 bytes.

[0103] S203: Generate a second ciphertext according to the target key and the first ciphertext.

[0104] A second ciphertext is generated based on the target key and the first ciphertext, and the second ciphertext is denoted as C′2.

[0105] In an optional implementation, the above step S203, generating the second ciphertext according to the target key and the first ciphertext, may include:

[0106] Generate a derived key using a preset key derivation function based on the target key;

[0107] A second ciphertext is generated according to the derived key and the first ciphertext.

[0108] The preset key derivation function is used to derive another key from a key. Based on the target key, the preset key derivation function is used to generate a derived key corresponding to the target key, and the second ciphertext is generated based on the derived key and the first ciphertext. The derived key is denoted as t′.

[0109] See also Figure 3The first ciphertext C is composed of the first concatenated ciphertext C1, the second concatenated ciphertext C2 and the third concatenated ciphertext C3. The second ciphertext is obtained by performing an XOR operation on the derived key and the second concatenated ciphertext. The second ciphertext is recorded as

[0110] In an optional embodiment, generating a derived key based on the target key using a preset key derivation function may include: obtaining the plaintext length of the target plaintext; and generating a derived key based on the target key and the plaintext length using a preset key derivation function.

[0111] Get the plaintext length of the target plaintext, denoted as klen, and use the preset key derivation function according to the target key and the plaintext length to generate the derived key corresponding to the target key. The length of the derived key is consistent with the plaintext length, that is, kle n .

[0112] S204: Generate a mixed encrypted ciphertext according to the first ciphertext, the second ciphertext and the key ciphertext.

[0113] The first concatenated ciphertext, the second ciphertext, the third concatenated ciphertext and the key ciphertext are concatenated to generate a mixed encrypted ciphertext, where the mixed encrypted ciphertext is denoted as C′, where C′=C1||C′2||C3||C4.

[0114] In this embodiment, by organically integrating the national secret algorithm and the post-quantum cryptographic algorithm, the target plaintext is encrypted using the client key and the client post-quantum key. On the basis of the existing national secret algorithm, the ability to resist the quantum algorithm is increased, and the encrypted ciphertext space is small. It is only necessary to add the post-quantum ciphertext data to the existing national secret ciphertext data to complete the hybrid encryption. In addition, the compatibility is strong, and the ciphertext data structure of the existing national secret algorithm (i.e., the first ciphertext) is maintained. By encrypting the ciphertext data structure, the "store first and then decrypt" attack can be prevented, thereby realizing the migration of the ciphertext data structure of the national secret algorithm to the post-quantum algorithm. The migration operation is simple and efficient.

[0115] The following combination Figure 4 The hybrid encryption method provided in this application is described, wherein the key encapsulation function is recorded as Encapsulate (abbreviated as Encap), for example, it can be the ML-KEM algorithm key encapsulation function, SM2En c It is the encryption function of the national secret algorithm. Figure 4 A schematic diagram of a specific hybrid encryption process provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the following steps are included:

[0116] Step 1: Enter the client's national secret public key PB and the target plaintext M, and use the client's national secret public key P BEncrypt the target plaintext M to obtain the first ciphertext C, C = SM2Enc (P B , M), the structure of C is C1||C2||C3.

[0117] Step 2: Enter the client's post-quantum public key P BPOC And use the key encapsulation function to generate the target key key of 32 bytes and the key ciphertext C4, which is expressed as (key, C4) = Encap (P BPQC , 32).

[0118] Step 3: Use the target key key as the seed to derive a derived key t′ of length klen, where t′=KDF(key, klen).

[0119] Step 4: XOR the second concatenated ciphertext C2 with t′ to obtain the second ciphertext C′2.

[0120] Step 5: Concatenate the first concatenated ciphertext C1, the second ciphertext C′2, the third concatenated ciphertext C3, and the key ciphertext C4 to obtain a mixed encrypted ciphertext C′, where C′=C1||C′2||C3||C4.

[0121] Figure 5 Schematic diagram of the hybrid encryption and decryption method provided in this embodiment Figure 3 ,like Figure 5 As shown, in an optional embodiment, the above step S104, decrypting the hybrid encrypted ciphertext according to the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext, may include:

[0122] S301 , parsing the mixed encrypted ciphertext to obtain a first concatenated ciphertext, a second ciphertext, a third concatenated ciphertext, and a key ciphertext.

[0123] The mixed encrypted ciphertext is parsed to obtain a first concatenated ciphertext, a second ciphertext, a third concatenated ciphertext and a key ciphertext.

[0124] S302. Decrypt the key ciphertext using a preset key decryption function based on the client's post-quantum private key to obtain the target key.

[0125] Among them, the key decryption function is used to decrypt the key ciphertext into the target key. According to the client's post-quantum private key, the preset key decryption function is used to decrypt the key ciphertext to obtain the target key. Among them, the client's post-quantum private key is denoted as S BPQC , for example, it can be the private key of the ML-KEM algorithm, and the target key is recorded as key.

[0126] S303: Generate a derived key based on the target key using a preset key derivation function.

[0127] Get the plaintext length of the target plaintext, denoted as klen. Based on the target key and the plaintext length, use the preset key derivation function to generate a derived key corresponding to the target key. The length of the derived key is consistent with the plaintext length, that is, klen.

[0128] S304 . Perform an XOR operation on the derived key and the second ciphertext to obtain a second concatenated ciphertext.

[0129] The derived key and the second ciphertext are XORed to obtain the second concatenated ciphertext, which is denoted as C′2.

[0130] S305 : Obtain a first ciphertext according to the first concatenated ciphertext, the second concatenated ciphertext, and the third concatenated ciphertext.

[0131] The first concatenated ciphertext, the second concatenated ciphertext and the third concatenated ciphertext are concatenated to obtain a first ciphertext, which is denoted as C=C1||C2||C3, where C1, C2 and C3 represent the first concatenated ciphertext, the second concatenated ciphertext and the third concatenated ciphertext respectively.

[0132] S306. Decrypt the first ciphertext according to the client's national secret private key to obtain the target plaintext.

[0133] According to the client's national secret private key, the first ciphertext is decrypted to obtain the target plaintext M. The client's national secret private key is recorded as S B .

[0134] The process of decrypting the first ciphertext can be found in Figure 6 , Figure 6 A schematic diagram of a specific national secret decryption process provided in an embodiment of the present application is shown as follows: Figure 6 As shown, the following steps are included:

[0135] Step 1. Take out C1, C2, and C3 from C.

[0136] Step 2: Calculate [S B ]C1=(x2,y2).

[0137] Step 3: Calculate t = KDF(x2||y2, klen).

[0138] Step 4. Calculation

[0139] Step 5. Calculate u = Hash(x2||M||y2). If u≠C3, report an error and exit.

[0140] In this embodiment, by organically integrating the national secret algorithm and the post-quantum cryptographic algorithm, the hybrid encrypted ciphertext is decrypted, and the ability to resist quantum algorithms is increased on the basis of the existing national secret algorithm.

[0141] The following combination Figure 7 The hybrid decryption process provided in this application is described. The key decapsulation function is recorded as Decapsulate (abbreviated as Decap), which can be, for example, the key decapsulation function of the ML-KEM algorithm or the decryption function of the SM2Dec national secret algorithm. Figure 7 A schematic diagram of a specific hybrid decryption process provided in an embodiment of the present application is shown as follows: Figure 7 As shown, the following steps are included:

[0142] Step 1: parse the mixed ciphertext C' to obtain the first concatenated ciphertext C1, the second ciphertext C'2, the third concatenated ciphertext C3, and the key ciphertext C4.

[0143] Step 2. Enter the client's post-quantum private key S BPQC And the key ciphertext C4 and use the preset key decapsulation function to decrypt C4 to obtain the target key key, key = Decap (S BPQC , C4)

[0144] Step 3: Use the target key key as the seed to derive a derived key t′ of length klen, where t′=KDF(key, klen).

[0145] Step 4: XOR the second ciphertext C′2 with the derived key t′ to obtain the second concatenated ciphertext C2.

[0146] Step 5: Concatenate the first ciphertext C1, the second ciphertext C2, and the third ciphertext C3 to obtain the first ciphertext C, C=C1||C2||C3, and use the client's national secret private key S B Decrypt the first ciphertext C to obtain the target plaintext M, M = SM2Dec(S B , C).

[0147] Figure 8 A schematic diagram of the structure of the hybrid encryption and decryption system provided in the embodiment of the present application is shown as follows: Figure 8 As shown, the system includes: a first client 501, a server 502 and a second client 503. The first client 501 sends an encryption request to the server 502, so that the server 502 encrypts the target plaintext to obtain a mixed encrypted ciphertext. The first client 501 sends the mixed encrypted ciphertext to the second client 503. The second client 503 sends a decryption request to the server 502, so that the server decrypts the mixed encrypted ciphertext to obtain the target plaintext, and sends the target plaintext to the second client 503.

[0148] Figure 9 This is a structural diagram of a hybrid encryption and decryption device provided in an embodiment of the present application, which can be integrated into a server.

[0149] like Figure 9 As shown, the device may include:

[0150] The receiving module 601 is configured to receive an encryption request sent by a first client, where the encryption request includes: a target plaintext;

[0151] An encryption module 602 is configured to encrypt the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain a hybrid encrypted ciphertext;

[0152] The sending module 603 is configured to send the hybrid encrypted ciphertext to the first client, so that the first client sends the hybrid encrypted ciphertext to the second client, and the second client is configured to send a decryption request to the server, wherein the decryption request includes: the hybrid encrypted ciphertext;

[0153] A decryption module 604 is configured to decrypt the hybrid encrypted ciphertext based on the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext;

[0154] The sending module 603 is further configured to send the target plaintext to the second client.

[0155] In an optional implementation, the encryption module 602 is specifically configured to:

[0156] Encrypt the target plaintext according to the client's national secret public key to obtain the first ciphertext;

[0157] Based on the client's post-quantum public key, a preset key encapsulation function is used to generate the target key and the target key's key ciphertext;

[0158] Generate a second ciphertext based on the target key and the first ciphertext;

[0159] A mixed encrypted ciphertext is generated according to the first ciphertext, the second ciphertext and the key ciphertext.

[0160] In an optional implementation, the encryption module 602 is specifically configured to:

[0161] According to the target key, a predetermined key derivation function is used to generate a derived key;

[0162] A second ciphertext is generated according to the derived key and the first ciphertext.

[0163] In an optional implementation, the encryption module 602 is specifically configured to:

[0164] Get the plaintext length of the target plaintext;

[0165] According to the target key and the plaintext length, a preset key derivation function is used to generate a derived key.

[0166] In an optional embodiment, the first ciphertext is composed of a first concatenated ciphertext, a second concatenated ciphertext, and a third concatenated ciphertext; the encryption module 602 is specifically configured to:

[0167] Performing an XOR operation on the derived key and the second concatenated ciphertext to obtain a second ciphertext;

[0168] The first concatenated ciphertext, the second ciphertext, the third concatenated ciphertext and the key ciphertext are concatenated to generate a mixed encrypted ciphertext.

[0169] In an optional embodiment, the device further comprises:

[0170] The query module 605 is used to query the client's national secret public key and the client's post-quantum public key according to the public key index.

[0171] In an optional implementation, the decryption module 604 is specifically configured to:

[0172] Parsing the mixed encrypted ciphertext to obtain the first concatenated ciphertext, the second ciphertext, the third concatenated ciphertext and the key ciphertext;

[0173] According to the client's post-quantum private key, the preset key decryption function is used to decrypt the key ciphertext to obtain the target key;

[0174] Generate a derived key using a preset key derivation function based on the target key;

[0175] Performing an XOR operation on the derived key and the second ciphertext to obtain a second concatenated ciphertext;

[0176] Obtaining a first ciphertext according to the first concatenated ciphertext, the second concatenated ciphertext, and the third concatenated ciphertext;

[0177] The first ciphertext is decrypted according to the client's national secret private key to obtain the target plaintext.

[0178] In an optional implementation, the decryption request further includes: a private key index of the second client; the query module 605 is further configured to:

[0179] According to the private key index, query the client's national secret private key and the client's post-quantum private key.

[0180] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference can be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0181] Figure 10 A structural schematic diagram of an electronic device provided in an embodiment of the present application is shown in FIG. 7. Figure 10 As shown in FIG. 7, the device can include a processor 701, a memory 702, and a bus 703. The memory 702 stores machine readable instructions executable by the processor 701. When the electronic device is running, the processor 701 communicates with the memory 702 through the bus 703. The processor 701 executes the machine readable instructions to perform the above method.

[0182] The present application also provides a computer readable storage medium, which stores a computer program. When the computer program is run by a processor, the processor executes the above method.

[0183] In the embodiments of the present application, when the computer program is run by the processor, the processor can also execute other machine readable instructions to perform other methods as described in the embodiments. For details of the method steps and principles, refer to the description of the embodiments, which will not be described in detail here.

[0184] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There can be another division manner in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some communication interfaces. It can be electrical, mechanical or in other forms.

[0185] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units. That is, they can be located in one place, or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.

[0186] In addition, each functional unit in the embodiments provided in the present application can be integrated into one processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.

[0187] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0188] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are only used to distinguish the description and are not to be understood as indicating or implying relative importance.

[0189] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The scope of protection of the present application is not limited thereto. Although the present application has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present application, or make equivalent replacements for some of the technical features thereof. However, these modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A hybrid encryption and decryption method, characterized in that: Applied to a server, the method includes: receiving an encryption request sent by a first client, wherein the encryption request includes: a target plaintext; Encrypt the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain a hybrid encrypted ciphertext; Sending the hybrid encrypted ciphertext to the first client, so that the first client sends the hybrid encrypted ciphertext to the second client, and the second client is configured to send a decryption request to the server, wherein the decryption request includes: the hybrid encrypted ciphertext; Decrypting the hybrid encrypted ciphertext according to the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext; Sending the target plaintext to the second client; The method of encrypting the target plaintext according to the client national secret public key and the client post-quantum public key of the second client to obtain a hybrid encrypted ciphertext includes: Encrypt the target plaintext according to the client's national secret public key to obtain a first ciphertext; Generate a target key and a key ciphertext of the target key using a preset key encapsulation function according to the client post-quantum public key; Generate a derived key using a preset key derivation function according to the target key; generating a second ciphertext based on the derived key and the first ciphertext; generating the mixed encrypted ciphertext according to the first ciphertext, the second ciphertext, and the key ciphertext; The first ciphertext is composed of a first concatenated ciphertext, a second concatenated ciphertext, and a third concatenated ciphertext; and generating the second ciphertext based on the derived key and the first ciphertext includes: Performing an XOR operation on the derived key and the second concatenated ciphertext to obtain the second ciphertext; The generating the hybrid encrypted ciphertext according to the first ciphertext, the second ciphertext, and the key ciphertext includes: Concatenate the first concatenated ciphertext, the second ciphertext, the third concatenated ciphertext, and the key ciphertext to generate the mixed encrypted ciphertext; The decrypting the hybrid encrypted ciphertext according to the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext includes: Parsing the mixed encrypted ciphertext to obtain a first concatenated ciphertext, a second ciphertext, a third concatenated ciphertext, and a key ciphertext; Decrypt the key ciphertext using a preset key decryption function according to the client post-quantum private key to obtain the target key; Generate a derived key using a preset key derivation function according to the target key; Performing an XOR operation on the derived key and the second ciphertext to obtain a second concatenated ciphertext; Obtaining a first ciphertext according to the first concatenated ciphertext, the second concatenated ciphertext, and the third concatenated ciphertext; The first ciphertext is decrypted according to the client's national secret private key to obtain the target plaintext.

2. The method according to claim 1, characterized in that The step of generating a derived key based on the target key using a preset key derivation function includes: Obtaining the plaintext length of the target plaintext; A derived key is generated according to the target key and the plaintext length using a preset key derivation function.

3. The method according to claim 1, characterized in that The encryption request further includes: a public key index of the second client. Before encrypting the target plaintext based on the client national secret public key and the client post-quantum public key of the second client to obtain the hybrid encrypted ciphertext, the method further includes: According to the public key index, the client's national secret public key and the client's post-quantum public key are queried.

4. The method according to claim 1, wherein The decryption request also includes: a private key index of the second client; and before decrypting the hybrid encrypted ciphertext based on the client national secret private key and the client post-quantum private key of the second client to obtain the target plaintext, the method further includes: According to the private key index, query the client's national secret private key and the client's post-quantum private key.

5. An electronic device, characterized in that: include: A processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and the processor executes the machine-readable instructions to perform the method according to any one of claims 1 to 4.

6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is executed.

Citation Information

Patent Citations

  • Communication channel encrypting, decrypting, and establishing method, device, memory, and terminal

    CN109792451A

  • A real-time perception hybrid encryption and decryption method and device for regulation and control operation data

    CN109936450A