Hybrid encryption and decryption method, electronic equipment and storage medium
By combining the national secret algorithm with the post -quantum password algorithm, and using the client key and the post -quantum key to decrypt, the security problem of the post -quantum era anti -quantum computing attack is solved, and the existing technologies are compatible and provided new security. The effect of ability.
Patent Information
- Application Number
- CN202411492361.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-24
AI Technical Summary
The existing technology is difficult to take into account the requirements of the existing cryptographic system and provide security capabilities to resist quantum computing attacks in the post-quantum era.
By organically fusion of the national secret algorithm and the rear quantum password algorithm, the client key and the client posterior quantum key are decrypted to make the target clearly decrypt, generate a hybrid encryption text, and decrypt through the server to ensure that the data is in the transmission process Safety.
Increased the ability to resist quantum computing attacks, ensure the security of the target, and compatible with the existing national secret algorithm and post -quantum password algorithm to meet the needs of existing security levels and provide the security capabilities of the quantum era.
Smart Images

Figure CN119382960A_ABST
Abstract
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 improvement of computer capabilities and the progress of mathematics, the classical encryption system that relies on computational complexity has become a huge threat. Quantum algorithms can crack problems such as integer factorization and discrete logarithms. Encryption mechanisms based on classical asymmetric cryptographic algorithms such as RSA, ECC, and SM2 face huge 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, so as to be compatible with both national secret algorithms and post-quantum cryptographic algorithms, increase the ability to resist quantum computing attacks, and ensure the security of the target plaintext.
[0005] In a first aspect, an embodiment of the present application provides a hybrid encryption and decryption method, which is applied to a server, and the method includes:
[0006] Receiving an encryption request sent by a first client, wherein the encryption request includes: a target plaintext;
[0007] 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 mixed 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 used 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] The target plaintext is sent to the second client.
[0011] In an optional implementation, 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 public key to obtain a first ciphertext;
[0013] Generate a target key and a key ciphertext of the target key according to the client post-quantum public key using a preset key packaging function;
[0014] Generate a second ciphertext according to the target key and the first ciphertext;
[0015] The mixed encrypted ciphertext is generated according to the first ciphertext, the second ciphertext and the key ciphertext.
[0016] In an optional implementation, generating a second ciphertext according to the target key and the first ciphertext includes:
[0017] According to the target key, a derived key is generated using a preset key derivation function;
[0018] The second ciphertext is generated according to the derived key and the first ciphertext.
[0019] In an optional implementation, the generating a derived key according to the target key using a preset key derivation function includes:
[0020] Obtaining the plaintext length of the target plaintext;
[0021] A derived key is generated according to the target key and the plaintext length using a preset key derivation function.
[0022] In an optional implementation, the first ciphertext is composed of a first concatenated ciphertext, a second concatenated ciphertext, and a third concatenated ciphertext; and generating the second ciphertext according to the derived key and the first ciphertext includes:
[0023] Performing an XOR operation on the derived key and the second concatenated ciphertext to obtain the second ciphertext;
[0024] The generating a mixed encrypted ciphertext according to the first ciphertext, the second ciphertext and the key ciphertext comprises:
[0025] The first concatenated ciphertext, the second ciphertext, the third concatenated ciphertext and the key ciphertext are concatenated to generate the mixed encrypted ciphertext.
[0026] In an optional implementation, the encryption request further includes: a public key index of the second client, and 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 further includes:
[0027] According to the public key index, query the client's national secret public key and the client's post-quantum public key.
[0028] In an optional implementation, 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, the second ciphertext, a third concatenated ciphertext and the key ciphertext;
[0030] According to the client post-quantum private key, a preset key decryption function is used to decrypt the key ciphertext to obtain a target key;
[0031] According to the target key, a derived key is generated using a preset key derivation function;
[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 national secret private key to obtain the target plaintext.
[0035] In an optional implementation, the decryption request further includes: a private key index of the second client; before 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, 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, and 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 comprising: receiving an encryption request sent by a first client, encrypting a target plaintext according to a client national secret public key and a client post-quantum public key of a second client, obtaining 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 used to send a decryption request to the server, the decryption request includes: a hybrid encrypted ciphertext, decrypting the hybrid encrypted ciphertext according to a client national secret private key and a client post-quantum private key of the second client, obtaining 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 the 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 drawings required for use in the embodiments will be briefly introduced below. 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 related drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 Schematic diagram of the hybrid encryption and decryption method provided in the embodiment of the present application Figure 1 ;
[0042] Figure 2 Schematic diagram of the hybrid encryption and decryption method provided in the embodiment of the present application 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 the embodiment of the present application 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 a hybrid encryption and decryption system provided in an embodiment of the present application;
[0049] Fig. 9 A schematic diagram of the structure of a hybrid encryption and decryption device provided in an embodiment of the present application;
[0050] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme 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 part of the embodiments of the present application, rather than all of 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 claimed 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 belong to the scope of protection of the present application.
[0052] First, the professional terms involved in this application are explained:
[0053] Post-Quantum Cryptography (PQC): is a branch of cryptography that aims to study and develop encryption algorithms that resist quantum computing attacks. Based on quantum mechanics, its security is based on physical properties such as the uncertainty principle, quantum non-cloning, and quantum coherence, and has been proven to be unconditionally secure. In addition, quantum key distribution technology based on quantum mechanics ensures that the key distribution process cannot be effectively eavesdropped because of the characteristics of quantum states such as non-cloning, uncertainty, and measurement collapse. It is a new generation of cryptographic algorithms that can resist attacks by quantum computers on existing cryptographic algorithms. Traditional public key encryption algorithms (such as RSA, DSA, and ECC) may be threatened with cracking in the case of large-scale quantum computers because 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 the security of application systems has received widespread attention from the society, collaborative encryption is usually used for data encryption. Collaborative encryption is a method to protect data confidentiality and achieve secure data transmission through multi-party collaboration. Collaborative encryption algorithms usually have a public key for public use, and multiple members have their own private keys. The public key is used to operate on the data during encryption, and multiple members need to collaborate to decrypt the plaintext data during decryption.
[0058] With the improvement of computer capabilities and the progress 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 has problems such as lack of effective security proof and inability to meet the requirements of existing security evaluation standards. Therefore, how to take into account the requirements of the existing cryptographic system and provide security capabilities in the post-quantum era is an urgent problem to be solved.
[0060] Based on this, this application organically integrates the national secret algorithm and the post-quantum cryptographic algorithm, and uses the client key and the client post-quantum key 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, and it can be compatible with both the national secret algorithm and the post-quantum cryptographic algorithm at the same time, with strong compatibility.
[0061] Figure 1 Schematic diagram of the hybrid encryption and decryption method provided in the embodiment of the present application 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 mixed 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, the national secret algorithm can be SM2, and 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. In other words, 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 implementation, the encryption request further includes: a public key index of the second client. In the above 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 according to 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 a hybrid encrypted ciphertext to the first client, and the first client can send the hybrid encrypted ciphertext to the second client, wherein the second client can send a decryption request to the server when receiving the hybrid encrypted ciphertext, wherein the decryption request includes: the hybrid encrypted ciphertext.
[0074] It is worth noting that the user can input a sending operation for the hybrid encrypted ciphertext through the first client, and the first client sends the hybrid encrypted ciphertext to the second client in response to the sending operation.
[0075] In addition, the user may also input a decryption operation for the hybrid encrypted ciphertext through the second client, and the second client sends a decryption request to the server in response to the decryption operation.
[0076] S104. Decrypt 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.
[0077] Among them, the client's national secret public key is the private key corresponding to the national secret algorithm generated in advance for the second client, and the client's post-quantum private key is the private key corresponding to the post-quantum cryptographic algorithm generated in advance for the second client.
[0078] The server obtains the client's national secret private key and the client's post-quantum private key, and decrypts the hybrid encrypted ciphertext based on the client's national secret private key and the client's post-quantum private key to obtain the target plaintext. In other words, the national secret algorithm and the post-quantum cryptographic algorithm are used to decrypt the hybrid encrypted ciphertext to obtain the target plaintext.
[0079] In an optional implementation, the decryption request also includes: a private key index of the second client; in the above step S104, before 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, the method may further include:
[0080] According to the private key index, query the client's national secret private key and the client's post-quantum private key.
[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. The decryption request also includes: the private key index of the second client, and the private key index includes: the national secret private key index and the post-quantum private key index. The server queries the stored multiple pairs of national secret public and private key pairs and multiple pairs of post-quantum public and private key pairs according to the private key index to determine the client national secret private key and client post-quantum private key of the second client.
[0082] S105. Send the target plaintext to the second client.
[0083] The server sends the decrypted target plaintext 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, and the ability to resist the quantum algorithm is increased on the basis of the existing national secret algorithm.
[0085] Figure 2 Schematic diagram of the hybrid encryption and decryption method provided in the embodiment of the present application Figure 2 ,like Figure 2 As shown, in an optional implementation, 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 a 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, such as 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] Among them, 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, and x2||y2 means concatenating x2 and y2.
[0094] Step 5: Calculation
[0095] It means that M and t are XORed to obtain C2.
[0096] Step 6: Calculate C3 = Hash(x2||M||y2).
[0097] Hash is SM3 algorithm, 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 according to the client post-quantum public key using a preset key packaging function.
[0101] The preset key packaging function is used to generate the target key and encrypt the target key according to the client post-quantum public key to obtain the key ciphertext of the target key, where the client post-quantum public key is denoted as P BPQC , for example, it can be the ML-KEM algorithm public key, the target key is denoted as key, and the key ciphertext is denoted as C4.
[0102] A preset key packaging 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 according to 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] According to the target key, a derived key is generated by using a preset key derivation function;
[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 based on a key, and according to the target key, the preset key derivation function is used to generate a derived key corresponding to the target key, and according to the derived key and the first ciphertext, a second ciphertext is generated. 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 implementation, 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 to generate the derived key corresponding to the target key according to the target key and the plaintext length. The length of the derived key is consistent with the plaintext length, that is, klen 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, wherein the mixed encrypted ciphertext is denoted as C′, where C′=C1||C′2||C3||C4.
[0114] In this embodiment, the national secret algorithm and the post-quantum cryptographic algorithm are organically integrated, and 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. Hybrid encryption can be completed by simply adding post-quantum ciphertext data to the existing national secret ciphertext data. 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] Combine the following 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 The key encapsulation function is used to generate a 32-byte target key key and a 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 the embodiment of the present application Figure 3 ,like Figure 5 As shown, in an optional implementation, 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. According to the client's post-quantum private key, a preset key decryption function is used to decrypt the key ciphertext to obtain the target key.
[0125] The key decryption function is used to decrypt the key ciphertext into the target key. According to the client post-quantum private key, the preset key decryption function is used to decrypt the key ciphertext to obtain the target key. The client post-quantum private key is denoted as S BPQC , for example, it can be the ML-KEM algorithm private key, and the target key is recorded as key.
[0126] S303: Generate a derived key according to the target key using a preset key derivation function.
[0127] The plaintext length of the target plaintext is obtained, denoted as klen. According to the target key and the plaintext length, a preset key derivation function is used 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 , performing 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 subjected to an XOR operation 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 by 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, such as 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, the national secret algorithm and the post-quantum cryptographic algorithm are organically integrated and the hybrid encrypted ciphertext is decrypted to increase the ability to resist the quantum algorithm on the basis of the existing national secret algorithm.
[0141] Combine the following Figure 7 The hybrid decryption process provided by this application is described. Among them, the key decapsulation function is recorded as Decapsulate (abbreviated as Decap), for example, it can be the key decapsulation function of the ML-KEM algorithm and the decryption function of the SM2Dec national encryption algorithm. Figure 7 A schematic diagram of a specific hybrid decryption process provided in an embodiment of the present application, such as 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 quantum private key S BPQC and the key ciphertext C4 and use the preset key decapping 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: Perform an XOR operation on the second ciphertext C′2 and 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 in FIG. 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] Fig. 9 This is a schematic diagram of the structure of a hybrid encryption and decryption device provided in an embodiment of the present application, which can be integrated in a server.
[0149] like Fig. 9 As shown, the device may include:
[0150] The receiving module 601 is used to receive an encryption request sent by a first client, where the encryption request includes: a target plaintext;
[0151] The encryption module 602 is used 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 mixed encrypted ciphertext;
[0152] The sending module 603 is used 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 used to send a decryption request to the server, wherein the decryption request includes: the hybrid encrypted ciphertext;
[0153] A decryption module 604 is used to decrypt 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;
[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] According to the client's national secret public key, the target plaintext is encrypted to obtain the first ciphertext;
[0157] According to the client's post-quantum public key, a preset key packaging function is used to generate a target key and a key ciphertext of the target key;
[0158] Generate a second ciphertext according to 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 derived key is generated by using a preset key derivation function;
[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 implementation, 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 used 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 a first concatenated ciphertext, a second ciphertext, a third concatenated ciphertext and a 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] According to the target key, a derived key is generated by using a preset key derivation function;
[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 also includes: a private key index of the second client; the query module 605 is further used 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 may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0181] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Fig.10 As shown, the device may 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, and the processor 701 executes the machine-readable instructions to perform the above method.
[0182] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the above method.
[0183] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated 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 merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0185] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] In addition, each functional unit in the embodiments provided in the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may 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, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods 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 protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A hybrid encryption and decryption method, characterized in that: Applied to a server, the method comprises: 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 mixed 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 used 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; The target plaintext is sent to the second client.
2. The method according to claim 1, characterized in that: 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 mixed encrypted ciphertext includes: Encrypt the target plaintext according to the client national secret public key to obtain a first ciphertext; Generate a target key and a key ciphertext of the target key according to the client post-quantum public key using a preset key packaging function; Generate a second ciphertext according to the target key and the first ciphertext; The mixed encrypted ciphertext is generated according to the first ciphertext, the second ciphertext and the key ciphertext.
3. The method according to claim 2, characterized in that The step of generating a second ciphertext according to the target key and the first ciphertext includes: According to the target key, a derived key is generated using a preset key derivation function; The second ciphertext is generated according to the derived key and the first ciphertext.
4. The method according to claim 3, characterized in that The step of generating a derived key according to the target key by 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.
5. The method according to claim 3, characterized in that: The first ciphertext is composed of a first concatenated ciphertext, a second concatenated ciphertext, and a third concatenated ciphertext; and generating the second ciphertext according to 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 a mixed encrypted ciphertext according to the first ciphertext, the second ciphertext and the key ciphertext comprises: The first concatenated ciphertext, the second ciphertext, the third concatenated ciphertext and the key ciphertext are concatenated to generate the mixed encrypted ciphertext.
6. The method according to claim 1, characterized in that The encryption request also includes: a public key index of the second client. 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 also includes: According to the public key index, query the client's national secret public key and the client's post-quantum public key.
7. The method according to claim 1, characterized in that 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; According to the client post-quantum private key, a preset key decryption function is used to decrypt the key ciphertext to obtain a target key; According to the target key, a derived key is generated using a preset key derivation function; 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 national secret private key to obtain the target plaintext.
8. The method according to claim 1, characterized in that The decryption request also includes: a private key index of the second client; before 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, the method also includes: According to the private key index, query the client's national secret private key and the client's post-quantum private key.
9. 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 described in any one of claims 1 to 8.
10. 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 8 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
Key exchange method and system, electronic equipment and storage medium
CN115695003A
Hybrid encryption method and device and storage medium
CN117353899A
Encryption method and device and decryption method and device for fused quantum cryptography
CN118337369A
Cited By
Data communication method based on post-quantum cryptography, electronic equipment and storage medium
CN120880790A
Multi-party quantum homomorphic encryption method based on hybrid encryption mechanism
CN121150908A
A multi-party quantum homomorphic encryption method based on a hybrid encryption mechanism
CN121150908B