Database encryption method and electronic equipment

By processing database data using a layered encryption method, symmetric encryption algorithms are used to encrypt entity data, and PQC public keys are used to encapsulate the keys, the quantum security and performance bottlenecks of database encryption mechanisms are solved, achieving efficient quantum-safe data storage and retrieval.

CN121765747APending Publication Date: 2026-03-31中电信量子信息科技集团有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing database encryption mechanisms face long-term data leakage risks, and the process of upgrading to quantum-resistant security involves large computational overhead, obvious performance bottlenecks, complex key management, and difficulty in dynamically switching encryption algorithms.

Method used

A layered encryption method is adopted, using a symmetric encryption algorithm to encrypt the data field, and using a PQC public key to asymmetrically encapsulate the data encryption key to generate a quantum-resistant index hash value, which is then integrated into encrypted data in a preset storage format.

Benefits of technology

It enhances the database's resistance to quantum attacks, balances the database's high-concurrency query efficiency and performance, and ensures the quantum security of data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121765747A_ABST
    Figure CN121765747A_ABST
Patent Text Reader

Abstract

The invention provides a database encryption method and electronic equipment, and the method comprises the steps: obtaining a predefined global security parameter set which comprises an identifier of an encryption algorithm required by each layer of encryption and a data storage strategy; generating a data encryption key corresponding to each field type in a target data table in the database; according to the global security parameter set and the data encryption key corresponding to each field type, performing hierarchical encryption on the to-be-encrypted data field to obtain encrypted data; and according to the global security parameter set, storing the encrypted data in a database to improve the quantum aggression resistance of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information security technology, and more specifically, to a database encryption method and electronic device. Background Technology

[0002] With the rapid development of quantum computing technology, traditional public-key cryptography is facing unprecedented security threats. Currently, widely used asymmetric encryption algorithms such as Elliptic Curve Cryptography (ECC) are based on the large integer factorization and discrete logarithm problems, which can be efficiently cracked by quantum computers using Shor's algorithm. This leads to a long-term data leakage risk for current database encryption mechanisms under the "harvest now, decrypt later" attack mode.

[0003] At the same time, existing database encryption schemes face challenges in upgrading to quantum-resistant security. Directly applying post-quantum cryptography (PQC) algorithms to process massive amounts of data will bring significant computational overhead and performance bottlenecks. Key management is complex and encryption algorithms are difficult to switch dynamically, resulting in insufficient support for PQC algorithms in database systems.

[0004] Therefore, there is an urgent need for a new database encryption method that can resist quantum computing attacks while also taking into account performance efficiency and system compatibility. Summary of the Invention

[0005] The purpose of this application is to address the shortcomings of the prior art by providing a database encryption method and electronic device to solve the practical problem of the long-term data leakage risk faced by current database encryption mechanisms.

[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a database encryption method, the method comprising: Obtain a predefined global security parameter set, which includes the identifiers of the encryption algorithms required for each layer of encryption and the data storage strategy; Generate data encryption keys corresponding to each field type in the target data table in the database; Based on the global security parameter set and the data encryption keys corresponding to each field type, the data fields to be encrypted are encrypted in layers to obtain the encrypted data. The encrypted data is stored in the database according to the global security parameter set.

[0007] As an optional implementation, the step of performing layered encryption on the data fields to be encrypted in the database based on the global security parameter set and the data encryption keys corresponding to each field type to obtain encrypted data includes: Based on the identifier of the symmetric encryption algorithm in the global security parameter set, the target data encryption key corresponding to the field type of the data field to be encrypted is used to perform symmetric encryption on the data field to be encrypted, and the symmetric encrypted ciphertext is obtained. Based on the identifier of the asymmetric encryption algorithm in the global security parameter set, the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain asymmetric encapsulated ciphertext. Based on the identifiers of the quantum-resistant algorithms in the global security parameter set, generate the quantum-resistant index hash value of the data field to be encrypted; Based on the data storage strategy in the global security parameter set, the encrypted metadata information is determined, and the symmetric encrypted ciphertext, the asymmetric encapsulated ciphertext, the quantum-resistant index hash value, and the encrypted metadata information are integrated into encrypted data in a preset storage format.

[0008] As an optional implementation, the step of symmetrically encrypting the data field to be encrypted using the target data encryption key corresponding to the field type of the data field to be encrypted, based on the identifier of the symmetric encryption algorithm in the global security parameter set, to obtain symmetric encrypted ciphertext, includes: The symmetric encryption algorithm is executed according to the identifier of the symmetric encryption algorithm to determine the target key length of the target data encryption key. A random number of the target key length is generated by a quantum random number generator, and the random number of the target key length is used as the target data encryption key. The data field to be encrypted is divided into multiple data blocks to be encrypted. Using the target data encryption key, each data block to be encrypted is symmetrically encrypted to obtain the ciphertext of each data block, and the ciphertexts of each data block are integrated into the symmetric encrypted ciphertext.

[0009] As an optional implementation, before performing symmetric encryption on each block of data to be encrypted using the target data encryption key, the following steps are included: Determine the cumulative usage duration of the target data encryption key and / or the cumulative number of decryption attempts using the target data encryption key; Based on the cumulative usage time and / or the cumulative decryption count, determine whether to rotate the target data encryption key; If so, a new target data encryption key is derived based on the target data encryption key, the common matrix, and the lattice generator. The new target data encryption key is then used to re-encrypt the data of the field type to which the data to be encrypted belongs, which is already stored in the database.

[0010] As an optional implementation, the step of using the PQC master public key to asymmetricly encapsulate the target data encryption key according to the identifier of the asymmetric encryption algorithm in the global security parameter set, to obtain asymmetric encapsulated ciphertext, includes: The asymmetric encryption algorithm is executed according to the identifier of the asymmetric encryption algorithm to generate a lattice-based PQC master key pair, wherein the PQC master key pair includes a PQC master public key and a PQC master private key; The encapsulation function corresponding to the asymmetric encryption algorithm is called, and the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain the asymmetric encapsulated ciphertext.

[0011] As an optional implementation, generating a quantum-resistant index hash value for the data field to be encrypted based on the quantum-resistant algorithm identifier in the global security parameter set includes: The anti-quantum algorithm is executed according to the identifier of the anti-quantum algorithm, and the anti-quantum hash operation is performed on the data field to be encrypted to extract the feature value of the data field to be encrypted; The feature value of the data field to be encrypted is used as the quantum-resistant index hash value of the data field to be encrypted.

[0012] As an optional implementation, storing the encrypted data in the database according to the global security parameter set includes: Based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value, determine the tree index information of the encrypted data; The encrypted data is stored in the target storage location of the database according to the target storage location indicated by the tree index information.

[0013] As an optional implementation, determining the tree index information of the encrypted data based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value includes: A pointer to the location where the encrypted data will be stored is determined, and an index encryption key is obtained by derivation based on the PQC master private key. The index encryption algorithm is executed according to the identifier of the index encryption algorithm, and the pointer is encrypted using the index encryption key to obtain the encrypted pointer; Based on the quantum-resistant index hash value, the pointer, and the encrypted pointer, the tree index information of the encrypted data is determined, and the tree index information includes internal node information and leaf node information.

[0014] As an optional implementation, the global security parameter set also includes: the identifier of the decryption algorithm corresponding to the encryption algorithm required for each layer of encryption; The method further includes: Receive a database query request, and determine the quantum-resistant index hash value of the data field to be queried based on the database query request and the identifier of the quantum-resistant algorithm in the global security parameter set; Based on the quantum-resistant index hash value of the data field to be queried, the encrypted pointer of the data field to be queried is obtained from the tree index structure, and the encrypted data of the data field to be queried is obtained from the database based on the encrypted pointer of the data field to be queried. Based on the identifiers of each decryption algorithm in the global security parameter set, the encrypted data of the data field to be queried is decrypted in layers to obtain the data field to be queried.

[0015] Secondly, embodiments of this application provide a database encryption device, the device comprising: The acquisition module is used to acquire a predefined global security parameter set, which includes the identifiers of the encryption algorithms required for each layer of encryption and the data storage strategy. The generation module is used to generate data encryption keys corresponding to each field type in the target data table in the database; The encryption module is used to perform layered encryption on the data fields to be encrypted according to the global security parameter set and the data encryption keys corresponding to each field type, so as to obtain encrypted data. The storage module is used to store the encrypted data in the database according to the global security parameter set.

[0016] As an optional implementation, the encryption module is specifically used for: Based on the identifier of the symmetric encryption algorithm in the global security parameter set, the target data encryption key corresponding to the field type of the data field to be encrypted is used to perform symmetric encryption on the data field to be encrypted, and the symmetric encrypted ciphertext is obtained. Based on the identifier of the asymmetric encryption algorithm in the global security parameter set, the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain asymmetric encapsulated ciphertext. Based on the identifiers of the quantum-resistant algorithms in the global security parameter set, generate the quantum-resistant index hash value of the data field to be encrypted; Based on the data storage strategy in the global security parameter set, the encrypted metadata information is determined, and the symmetric encrypted ciphertext, the asymmetric encapsulated ciphertext, the quantum-resistant index hash value, and the encrypted metadata information are integrated into encrypted data in a preset storage format.

[0017] As an optional implementation, the encryption module is specifically used for: The symmetric encryption algorithm is executed according to the identifier of the symmetric encryption algorithm to determine the target key length of the target data encryption key. A random number of the target key length is generated by a quantum random number generator, and the random number of the target key length is used as the target data encryption key. The data field to be encrypted is divided into multiple data blocks to be encrypted. Using the target data encryption key, each data block to be encrypted is symmetrically encrypted to obtain the ciphertext of each data block, and the ciphertexts of each data block are integrated into the symmetric encrypted ciphertext.

[0018] As an optional implementation, the encryption module is also used for: Determine the cumulative usage duration of the target data encryption key and / or the cumulative number of decryption attempts using the target data encryption key; Based on the cumulative usage time and / or the cumulative decryption count, determine whether to rotate the target data encryption key; If so, a new target data encryption key is derived based on the target data encryption key, the common matrix, and the lattice generator. The new target data encryption key is then used to re-encrypt the data of the field type to which the data to be encrypted belongs, which is already stored in the database.

[0019] As an optional implementation, the encryption module is specifically used for: The asymmetric encryption algorithm is executed according to the identifier of the asymmetric encryption algorithm to generate a lattice-based PQC master key pair, wherein the PQC master key pair includes a PQC master public key and a PQC master private key; The encapsulation function corresponding to the asymmetric encryption algorithm is called, and the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain the asymmetric encapsulated ciphertext.

[0020] As an optional implementation, the encryption module is specifically used for: The anti-quantum algorithm is executed according to the identifier of the anti-quantum algorithm, and the anti-quantum hash operation is performed on the data field to be encrypted to extract the feature value of the data field to be encrypted; The feature value of the data field to be encrypted is used as the quantum-resistant index hash value of the data field to be encrypted.

[0021] As an optional implementation, the storage module is specifically used for: Based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value, determine the tree index information of the encrypted data; The encrypted data is stored in the target storage location of the database according to the target storage location indicated by the tree index information.

[0022] As an optional implementation, the storage module is specifically used for: A pointer to the location where the encrypted data will be stored is determined, and an index encryption key is obtained by derivation based on the PQC master private key. The index encryption algorithm is executed according to the identifier of the index encryption algorithm, and the pointer is encrypted using the index encryption key to obtain the encrypted pointer; Based on the quantum-resistant index hash value, the pointer, and the encrypted pointer, the tree index information of the encrypted data is determined, and the tree index information includes internal node information and leaf node information.

[0023] As an optional implementation, the device further includes: The determination module is used to receive a database query request and determine the quantum-resistant index hash value of the data field to be queried based on the database query request and the quantum-resistant algorithm identifier in the global security parameter set. The query module is used to retrieve the encrypted pointer of the data field to be queried from the tree index structure based on the quantum-resistant index hash value of the data field to be queried, and to retrieve the encrypted data of the data field to be queried from the database based on the encrypted pointer of the data field to be queried. The decryption module is used to perform layered decryption of the encrypted data of the data field to be queried based on the identifiers of each decryption algorithm in the global security parameter set, so as to obtain the data field to be queried.

[0024] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the database encryption method described in the first aspect above.

[0025] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the database encryption method described in the first aspect above.

[0026] The beneficial effects of this application are: This application provides a database encryption method and electronic device. It obtains a predefined global security parameter set and generates data encryption keys corresponding to each field type in the target data table of the database. Based on the identifiers of the encryption algorithms required for each layer of encryption in the global security parameter set and the data encryption keys corresponding to each field type, the data fields to be encrypted are layered and encrypted to obtain encrypted data. The encrypted data is then stored in the database according to the data storage strategy in the global security parameter set, facilitating subsequent querying and decryption. Because the entity data of the data fields to be encrypted is encrypted first, and then the data encryption key used to encrypt the entity data is encapsulated, both the entity data of the data fields to be encrypted and the data encryption key used to encrypt the entity data are protected, greatly improving resistance to quantum attacks while maintaining database performance. Attached Figure Description

[0027] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 Flowchart of the database encryption method provided in the embodiments of this application Figure 1 ; Figure 2 Flowchart of the database encryption method provided in the embodiments of this application Figure 2 ; Figure 3 Flowchart of the database encryption method provided in the embodiments of this application Figure 3 ; Figure 4 Flowchart of the database encryption method provided in the embodiments of this application Figure 4 ; Figure 5 Flowchart of the database encryption method provided in the embodiments of this application Figure 5 ; Figure 6 Flowchart of the database encryption method provided in the embodiments of this application Figure 6 ; Figure 7 Flowchart of the database encryption method provided in the embodiments of this application Figure 7 ; Figure 8 Flowchart of the database encryption method provided in the embodiments of this application Figure 8 ; Figure 9 Flowchart of the database encryption method provided in the embodiments of this application Figure 9 ; Figure 10 A module structure diagram of the database encryption device provided in the embodiments of this application; Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0030] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0031] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0032] In the field of information security, with the rapid development of quantum computing technology, traditional public-key cryptography is facing unprecedented security threats. Currently widely used asymmetric encryption algorithms such as ECC can be efficiently cracked by quantum computers using Shor's algorithm, leading to a long-term risk of data leakage for current database encryption mechanisms under the "steal first, decrypt later" attack model. At the same time, existing database encryption schemes face challenges in upgrading to quantum-resistant security. Applying PQC algorithms to process massive amounts of data incurs significant computational overhead and performance bottlenecks. Key management is complex, and the difficulty in dynamically switching encryption algorithms results in insufficient support for PQC algorithms in database systems.

[0033] This application provides a database encryption method to address the aforementioned problems. Through a hierarchical key design, a data encryption key is used to perform efficient symmetric encryption on the data, followed by secure encapsulation of the data encryption key using a PQC public key. Since the computationally intensive PQC asymmetric encryption algorithm is only used to encapsulate the data encryption key, while the encryption of the entity data employs an efficient symmetric encryption algorithm, this method balances quantum security protection with database performance, ensuring both quantum security of data storage and maintaining high concurrency query efficiency of the database.

[0034] Figure 1 Flowchart of the database encryption method provided in the embodiments of this application Figure 1 The subject executing this method can be any electronic device with computing power. For example... Figure 1 As shown, the method includes: S101. Obtain a predefined global security parameter set, which includes the identifiers of the encryption algorithms required for each layer of encryption and the data storage strategy.

[0035] Optionally, a pre-configured or pre-defined global security parameter set is obtained. The encryption algorithm required for each layer of encryption is determined by the identifier of the encryption algorithm required for each layer of encryption in the global security parameter set. The preset storage format of the database is determined by the data storage strategy in the global security parameter set to ensure that the encrypted data can be stored in the database in a standardized manner, which facilitates the subsequent querying and decryption of the encrypted data.

[0036] Among them, the global security parameter set can provide a unified standard for the encryption process of the database, avoiding the mixing of algorithms or chaotic storage formats.

[0037] S102. Generate data encryption keys corresponding to each field type in the target data table in the database.

[0038] Optionally, for each field type in the target data table of the database, an independent data encryption key is generated as the data encryption key corresponding to each field type, which can prevent the leakage of the data encryption key corresponding to a field type from causing the leakage of the entire data.

[0039] Among these features, a Trusted Execution Environment (TEE) can be used to generate data encryption keys corresponding to each field type in the target data table in the database, in order to prevent side-channel attacks and avoid leakage of each data encryption key.

[0040] S103. Based on the global security parameter set and the data encryption keys corresponding to each field type, perform layered encryption on the data fields to be encrypted to obtain the encrypted data.

[0041] Optionally, the encryption algorithm required for each layer of encryption is specified based on the identifier of the encryption algorithm required for each layer of encryption in the global security parameter set. Based on the specified encryption algorithm required for each layer of encryption and the data encryption key corresponding to each field type, the data field to be encrypted is encrypted layer by layer to obtain the encrypted data.

[0042] Layered encryption includes encrypting the entity data of the data field to be encrypted and encapsulating the data encryption key used when encrypting the entity data. This protects both the entity data of the data field to be encrypted and the data encryption key used when encrypting the entity data, further enhancing resistance to quantum attacks.

[0043] S104. Store the encrypted data in the database according to the global security parameter set.

[0044] Optionally, the encrypted data can be stored in the database in accordance with the default storage format specified by the global security parameter centralized data storage strategy, so as to facilitate subsequent querying and decryption of the encrypted data.

[0045] In this embodiment, a predefined global security parameter set is obtained, and data encryption keys corresponding to each field type in the target data table of the database are generated. Based on the identifiers of the encryption algorithms required for each layer of encryption in the global security parameter set and the data encryption keys corresponding to each field type, the data fields to be encrypted are subjected to layered encryption to obtain encrypted data. The encrypted data is then stored in the database according to the data storage strategy in the global security parameter set, facilitating subsequent querying and decryption. Because the entity data of the data fields to be encrypted is encrypted first, and then the data encryption key used to encrypt the entity data is encapsulated, both the entity data of the data fields to be encrypted and the data encryption key used to encrypt the entity data are protected, greatly improving resistance to quantum attacks while maintaining database performance.

[0046] Figure 2 Flowchart of the database encryption method provided in the embodiments of this application Figure 2 ,like Figure 2As shown, in step S103 above, the data fields to be encrypted in the database are encrypted in layers according to the global security parameter set and the data encryption keys corresponding to each field type, resulting in encrypted data, including: S201. Based on the identifier of the symmetric encryption algorithm in the global security parameter set, use the target data encryption key corresponding to the field type of the data field to be encrypted to perform symmetric encryption on the data field to be encrypted, and obtain the symmetric encrypted ciphertext.

[0047] Optionally, the symmetric encryption algorithm to be executed is determined based on the identifier of the symmetric encryption algorithm in the global security parameter set, and the target data encryption key is determined based on the field type of the data field to be encrypted. The field to be encrypted is the field content or value of the data to be encrypted, used to represent the entity data to be encrypted.

[0048] Specifically, the symmetric encryption algorithm to be executed can be AES-256-GCM. Here, Advanced Encryption Standard (AES) is a symmetric key encryption standard, and 256 indicates that the encryption key length is 256 bits. The AES standard allows the use of 128-bit, 192-bit, or 256-bit encryption keys, with 256 bits representing the highest level of security. Galois / Counter Mode (GCM) is an authentication encryption mode for the symmetric encryption algorithm, used for integrity authentication of the data field to be encrypted. The AES-256-GCM symmetric encryption algorithm can simultaneously achieve efficient symmetric encryption and integrity authentication of the data field to be encrypted.

[0049] Encryption key for target data The AES-256-GCM algorithm is used to perform efficient symmetric encryption and integrity authentication on the data field to be encrypted, resulting in symmetric encrypted ciphertext. The symmetric encrypted ciphertext contains the encryption result of the data field to be encrypted and the integrity authentication tag.

[0050] S202. Based on the identifier of the asymmetric encryption algorithm in the global security parameter set, the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain the asymmetric encapsulated ciphertext.

[0051] Optionally, the asymmetric encryption algorithm to be executed is determined based on the identifier of the asymmetric encryption algorithm in the global security parameter set. Specifically, the asymmetric encryption algorithm to be executed can be the CRYSTALS-Kyber algorithm, which is based on a mathematical problem of algebraic lattices to resist attacks from future quantum computers.

[0052] The target data is encrypted using the PQC master public key and the CRYSTALS-Kyber algorithm. Perform asymmetric encapsulation to obtain asymmetric encapsulated ciphertext. Because the encapsulation process only encrypts the key for the target data. It does not involve encapsulating massive amounts of data in the database, thus avoiding the high computational overhead of the CRYSTALS-Kyber algorithm. It balances the performance and efficiency of the database while being quantum resistant.

[0053] S203. Based on the identifier of the quantum-resistant algorithm in the global security parameter set, generate the quantum-resistant index hash value of the data field to be encrypted.

[0054] Optionally, based on the identifier of the quantum-resistant algorithm in the global security parameter set, a quantum-resistant hash operation is performed on the data field to be encrypted to generate a quantum-resistant index hash value for the data field to be encrypted. .

[0055] Specifically, the quantum-resistant algorithm can be the SHA3-256 algorithm, where SHA3-256 is the third-generation Secure Hash Algorithm (SHA for short), and 256 indicates that the length of the output quantum-resistant indexed hash value is 256 bits. Using the SHA3-256 algorithm enhances resistance to quantum collision attacks, making the quantum-resistant indexed hash value... It can withstand quantum collision attacks.

[0056] S204. Based on the data storage strategy in the global security parameter set, determine the encrypted metadata information, and integrate the symmetric encrypted ciphertext, asymmetric encapsulated ciphertext, quantum-resistant index hash value, and encrypted metadata information into encrypted data in a preset storage format.

[0057] Optionally, encrypted metadata information is determined based on the data storage strategy in the global security parameter set, wherein the encrypted metadata information may include a data identifier. Encrypted timestamps The key version number of the target data encryption key and the identifiers of the encryption algorithms required for each layer of encryption. .

[0058] Among them, data identifiers It is a unique identifier for the data field to be encrypted, generated by calculating a quantum-resistant hash value. ,in, Indicates that the quantum-resistant algorithm is algorithm, This indicates the data field to be encrypted.

[0059] Encrypted timestamps This records the current encryption time of the data field to be encrypted, used for lifecycle management of the data field to be encrypted. Specifically, , The current time when the data field to be encrypted was encrypted.

[0060] Key version number of the target data encryption key ,in, Generate a counter value for the key, which is used for key rotation management of the target data encryption key.

[0061] Identifiers of the encryption algorithms required for each layer of encryption ,in, It is the encryption key for encapsulating target data. The asymmetric encryption algorithm used at that time The symmetric encryption algorithm used to encrypt the data field to be encrypted.

[0062] The default storage format can be a composite structure storage format. Symmetrically encrypted ciphertext and asymmetrically encapsulated ciphertext will be stored according to this composite structure storage format. Quantum-resistant index hash value The encrypted metadata information is integrated into encrypted data in a preset storage format.

[0063] Specifically, storing records It is a composite structure.

[0064] .

[0065] in, This is a random initialization vector for symmetric encryption. To add authentication data, For integrity certification labels, For data identifiers, The encryption result of the data field to be encrypted. It is an asymmetric encapsulation of ciphertext. The key version number for encrypting the target data. Identifiers for the encryption algorithms required for each layer of encryption. This is a quantum-resistant index hash value.

[0066] Symmetric encryption ciphertext includes the encryption result of the data field to be encrypted. and integrity certification label Among them, integrity certification label Encryption key for target data The encryption result of the data field to be encrypted and additional authentication data It is obtained by performing a G-HASH hash operation, where G-HASH is the built-in hash function of the AES-256-GCM algorithm.

[0067] In this embodiment, based on the identifier of the symmetric encryption algorithm, the target data encryption key corresponding to the field type of the data field to be encrypted is used to symmetrically encrypt the data field to be encrypted, obtaining symmetric encrypted ciphertext. Based on the identifier of the asymmetric encryption algorithm, the target data encryption key is asymmetrically encapsulated using the PQC master public key, obtaining asymmetric encapsulated ciphertext. Based on the identifier of the quantum-resistant algorithm, a quantum-resistant index hash value is generated for the data field to be encrypted, and according to the data storage strategy, encrypted metadata information is determined. The symmetric encrypted ciphertext, asymmetric encapsulated ciphertext, quantum-resistant index hash value, and encrypted metadata information are integrated into encrypted data in a preset storage format. This achieves multi-layer encryption of the data field to be encrypted, improving the database's resistance to quantum attacks.

[0068] Figure 3 Flowchart of the database encryption method provided in the embodiments of this application Figure 3 ,like Figure 3 As shown, in step S201 above, based on the identifier of the symmetric encryption algorithm in the global security parameter set, the target data encryption key corresponding to the field type of the data field to be encrypted is used to perform symmetric encryption on the data field to be encrypted, resulting in symmetric encrypted ciphertext, including: S301. Execute the symmetric encryption algorithm according to the identifier of the symmetric encryption algorithm, determine the target key length of the target data encryption key, generate a random number of the target key length by the quantum random number generator, and use the random number of the target key length as the target data encryption key.

[0069] Optionally, a symmetric encryption algorithm is executed according to the identifier of the symmetric encryption algorithm, i.e., the AES-256-GCM algorithm is executed.

[0070] Generate target data encryption key At that time, the target data encryption key is determined according to the AES-256-GCM algorithm. If the target key length is 256 bits, a high-quality 256-bit random number is generated in the TEE by a Quantum Random Number Generator (QRNG) to serve as the target data encryption key. QRNG is used to generate completely random numbers that are unpredictable and have no discernible pattern.

[0071] S302. Perform data block processing on the data field to be encrypted to obtain multiple data blocks to be encrypted.

[0072] Optionally, the data field to be encrypted is divided into blocks, and the plaintext message of the data field to be encrypted is divided into blocks. Divided into A fixed-length block of data to be encrypted, each block being 128 bits, to meet the block size requirements of the AES-256-GCM algorithm.

[0073] Specifically, each block of data to be encrypted can be encoded using a padding function. Ensure that each data block to be encrypted is padded to 128 bits.

[0074] S303. Using the target data encryption key, perform symmetric encryption on each data block to be encrypted to obtain the ciphertext of each data block, and integrate the ciphertexts of each data block into a symmetric encrypted ciphertext.

[0075] Optionally, for the data block to be encrypted Using the target data encryption key AES-256-GCM encryption is performed to obtain the ciphertext of the data block, which includes the block encryption result. and block integrity certification label This integrates the ciphertext of each data block into a symmetric encrypted ciphertext.

[0076] Specifically, the encryption result of the data field to be encrypted is determined based on the encryption results of multiple blocks. and integrity certification label The encryption result of the data field to be encrypted and integrity certification label It is integrated into a symmetric encrypted ciphertext.

[0077] Among them, the target data encryption key is used. Treating encrypted data blocks When performing AES-256-GCM encryption, the block encryption result ,in, This indicates that the AES-256-GCM algorithm is used for encryption. Encrypt the target data with a key. For the data block to be encrypted, To initialize a vector randomly, For additional authentication data.

[0078] During the encryption process, a block integrity authentication tag is generated. ,in, This indicates that the G-HASH algorithm is used for hash calculation. Encrypt the target data with a key. For the block encryption result, For additional authentication data.

[0079] In this embodiment, a symmetric encryption algorithm is executed based on the identifier of the symmetric encryption algorithm to determine the target key length of the target data encryption key. A random number of the target key length is generated by a quantum random number generator, and this random number is used as the target data encryption key. The data field to be encrypted is divided into multiple data blocks, and each data block is symmetrically encrypted using the target data encryption key to obtain the ciphertext of each data block. The ciphertexts of each data block are then integrated into a symmetric encrypted ciphertext. This achieves efficient symmetric encryption of the data field to be encrypted, improving encryption efficiency and security.

[0080] Figure 4 Flowchart of the database encryption method provided in the embodiments of this application Figure 4 ,like Figure 4 As shown, in step S303 above, before using the target data encryption key to perform symmetric encryption on each block of data to be encrypted, the following steps are included: S401. Determine the cumulative usage time of the target data encryption key and / or the cumulative number of decryption attempts of the target data encryption key.

[0081] Optionally, the statistical target data encryption key Cumulative usage time and / or target data encryption key Cumulative number of decryption times .

[0082] Among them, the cumulative usage time Encryption key used to characterize target data The number of days used so far can be used to encrypt the target data using a key. The calculation begins from the timestamp generated. Cumulative decryption count. Encryption key used to characterize target data The total number of times it has been used for decryption.

[0083] S402. Determine whether to rotate the target data encryption key based on the cumulative usage time and / or cumulative decryption count.

[0084] Optionally, based on cumulative usage time and / or cumulative decryption count Determine whether the key rotation mechanism has been triggered and whether the target data encryption key should be rotated. .

[0085] Specifically, if the cumulative usage time Exceeding the preset time And / or, if the cumulative number of decryption attempts Exceeding the maximum number of decryption attempts This triggers the key rotation mechanism, requiring the encryption key for the target data to be changed. Rotation is performed. For example, a preset duration is used. It can be 90 days, with a maximum number of decryption attempts. It can be That is, 1 million times.

[0086] S403. If so, then based on the target data encryption key, the common matrix, and the lattice generator, a new target data encryption key is derived, and the new target data encryption key is used to re-encrypt the data of the field type to which the data to be encrypted belongs that is already stored in the database.

[0087] Optionally, if it is determined that an encryption key for the target data is needed. When rotating, the encryption key is based on the target data. From the common matrix A and the lattice basis generator G, a new encryption key for the target data is derived. .

[0088] Specifically, .in, Encrypt the new target data with a key. Zero-knowledge proof, used to prove a new encryption key for target data. Encryption key from target data Legitimate derivative. This refers to the key derivation algorithm in the Module-Lattice-based Key-Encapsulation Mechanism (ML-KEM). , is a common matrix, For lattice basis generator.

[0089] Revoke the target data encryption key And using a new target data encryption key. The re-encryption of data of the field type to which the data to be encrypted belongs, which is already stored in the database, is completed through background transactions.

[0090] In this embodiment, the cumulative usage time and / or cumulative decryption count of the target data encryption key are determined, and a decision is made whether to rotate the target data encryption key based on the cumulative usage time and / or cumulative decryption count. If so, a new target data encryption key is derived based on the target data encryption key, the common matrix, and the lattice generator, and the new target data encryption key is used to re-encrypt data of the field type to which the data to be encrypted belongs, already stored in the database. A key rotation mechanism is established to dynamically reduce the risk of leakage of the target data encryption key through key derivation.

[0091] Figure 5 Flowchart of the database encryption method provided in the embodiments of this application Figure 5 ,like Figure 5 As shown, in step S202 above, based on the identifier of the asymmetric encryption algorithm in the global security parameter set, the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain asymmetric encapsulated ciphertext, including: S501. Execute the asymmetric encryption algorithm according to the identifier of the asymmetric encryption algorithm to generate a lattice-based PQC master key pair, which includes the PQC master public key and the PQC master private key.

[0092] Optionally, an asymmetric encryption algorithm is executed according to the identifier of the asymmetric encryption algorithm, that is, the CRYSTALS-Kyber algorithm is executed to generate a lattice-based PQC master key pair, including the PQC public key (PK) and the PQC private key (SK).

[0093] Specifically, the CRYSTALS-Kyber algorithm is adopted, and a Kyber parameter set with security level 5 (the highest security level, with the strongest resistance to quantum attacks) is selected, based on the modulus. To address the learning difficulty of the Module Learning With Errors (MLWE) problem on an ideal lattice, Kyber.KeyGen is called to generate a PQC master key pair.

[0094] The generated PQC master public key PK is configured in the database encryption service and used to encapsulate the target data encryption key. The generated PQC master private key SK is stored in a certified Hardware Security Module (HSM) to ensure the physical security of the PQC master private key. The PQC master private key SK is used for asymmetric encapsulation of ciphertext. Perform decapsulation.

[0095] S502. Call the encapsulation function corresponding to the asymmetric encryption algorithm, and use the PQC master public key to perform asymmetric encapsulation on the target data encryption key to obtain the asymmetric encapsulated ciphertext.

[0096] Optionally, the wrapper function corresponding to the CRYSTALS-Kyber algorithm can be called, i.e., Kyber.Enc, to encrypt the target data using the PQC master public key PK. Perform asymmetric encapsulation to obtain asymmetric encapsulated ciphertext. .

[0097] Asymmetric Encapsulation Ciphertext ,in, This is the PQC master public key. Encrypt the target data with a key. This is a wrapper function for the CRYSTALS-Kyber algorithm.

[0098] In this embodiment, an asymmetric encryption algorithm is executed based on the identifier of the asymmetric encryption algorithm to generate a lattice-based PQC master key pair, which includes a PQC public key and a PQC private key. The encapsulation function corresponding to the asymmetric encryption algorithm is called, and the target data encryption key is asymmetrically encapsulated using the PQC public key to obtain asymmetric encapsulated ciphertext. By using the computationally intensive PQC asymmetric encryption algorithm only for encapsulating the target data encryption key, and not for encapsulating massive amounts of data in the database, the high computational overhead of the PQC asymmetric encryption algorithm is avoided, thus balancing quantum resistance with database performance and efficiency. By asymmetrically encapsulating the target data encryption key, it gains resistance to quantum attacks, preventing quantum computers from cracking the target data encryption key and causing data leakage.

[0099] Figure 6 Flowchart of the database encryption method provided in the embodiments of this application Figure 6 ,like Figure 6 As shown, in step S203 above, generating a quantum-resistant index hash value for the data field to be encrypted based on the identifier of the quantum-resistant algorithm in the global security parameter set includes: S601. Execute the quantum-resistant algorithm according to the quantum-resistant algorithm identifier, perform quantum-resistant hash operation on the data field to be encrypted, and extract the feature value of the data field to be encrypted.

[0100] Optionally, a quantum-resistant algorithm is executed based on the identifier of the quantum-resistant algorithm; that is, a quantum-resistant hash operation is performed on the data field to be encrypted to extract the feature value of the data field to be encrypted. .

[0101] Specifically, the characteristic value of the data field to be encrypted This indicates that the SHA3-256 algorithm is being executed on the plaintext message of the data field to be encrypted. The first 16 bytes undergo quantum-resistant hashing, and subsequent operations can be performed based on the feature values ​​of the data field to be encrypted. Quickly query / locate the data field to be encrypted in the database.

[0102] S602. Use the feature value of the data field to be encrypted as the quantum-resistant index hash value of the data field to be encrypted.

[0103] Optionally, the feature value of the data field to be encrypted is... Quantum-resistant index hash value as the field to be encrypted Quantum-resistant index hash value Ciphertext indexes are used for building ciphertext indexes in the storage process of subsequent data fields to be encrypted.

[0104] In this embodiment, a quantum-resistant algorithm is executed based on the identifier of the quantum-resistant algorithm. A quantum-resistant hash operation is performed on the data field to be encrypted to extract the feature value of the data field to be encrypted, and the feature value of the data field to be encrypted is used as the quantum-resistant index hash value of the data field to be encrypted. This facilitates the construction of a ciphertext index based on the quantum-resistant index hash value of the data field to be encrypted, thereby improving index security and data query efficiency.

[0105] Figure 7 Flowchart of the database encryption method provided in the embodiments of this application Figure 7 ,like Figure 7 As shown, step S104 above, which stores the encrypted data in the database according to the global security parameter set, includes: S701. Determine the tree index information of the encrypted data based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value.

[0106] Optionally, the tree index information of the encrypted data is determined based on the node format in the B+ tree index structure, according to the identifier of the index encryption algorithm and the quantum-resistant index hash value in the global security parameter set.

[0107] Specifically, the index encryption algorithm can be the AES-128 symmetric encryption algorithm, used to encrypt the pointer to the storage location of the encrypted data.

[0108] S702. Based on the target storage location indicated by the tree index information, store the encrypted data in the target storage location of the database.

[0109] Optionally, the tree index information is parsed to determine the target storage location, and the encrypted data is stored in a composite structure. The data is written to the target storage location of the database in the form of [format].

[0110] Because encrypted data is securely stored in the target location of the database, tree index information and storage records... The mapping relationship takes effect simultaneously, supporting subsequent index queries and improving data query efficiency.

[0111] In this embodiment, the tree index information of the encrypted data is determined based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value. Then, according to the target storage location indicated by the tree index information, the encrypted data is stored in the target storage location of the database. This facilitates subsequent index queries, improves data query efficiency, and prevents data location attacks caused by index leakage through the index encryption algorithm.

[0112] Figure 8 Flowchart of the database encryption method provided in the embodiments of this application Figure 8 ,like Figure 8 As shown, in step S701 above, the tree index information of the encrypted data is determined based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value, including: S801. Determine the pointer to the storage location of the encrypted data, and derive the key based on the PQC master private key to obtain the index encryption key.

[0113] Optionally, the physical storage address of the encrypted data in the database is determined, and a pointer to that physical storage address is generated. And based on the PQC master private key SK, call the key derivation function. Key Derive Function, or KDF for short Perform key derivation to obtain the index encryption key. .

[0114] The index encryption key is derived from the PQC master private key SK using KDF. This can prevent the PQC master private key SK from being directly exposed.

[0115] S802. Execute the index encryption algorithm according to the identifier of the index encryption algorithm, and use the index encryption key to encrypt the pointer to obtain the encrypted pointer.

[0116] Optionally, the index encryption algorithm is executed according to the identifier of the index encryption algorithm, that is, the AES-128 symmetric encryption algorithm is executed, using the index encryption key. pointer Lightweight encryption protection, i.e., protection of pointers. Perform index encryption to obtain the encrypted pointer. .

[0117] Specifically, the encrypted pointer ,in, This indicates that the index is encrypted using the AES-128 symmetric encryption algorithm. For indexing encryption keys, A pointer to the location where the encrypted data will be stored.

[0118] S803. Based on the quantum-resistant index hash value, pointer, and encrypted pointer, determine the tree index information of the encrypted data. The tree index information includes internal node information and leaf node information.

[0119] Optionally, based on the node format in the B+ tree index structure and the quantum-resistant index hash value... ,pointer and encrypted pointer The tree index information of the encrypted data is determined. The B+ tree index structure consists of internal nodes and leaf nodes, with nodes defined by quantum-resistant index hash values. Sort by size.

[0120] Specifically, internal nodes The format is: ,in child node The minimum quantum-resistant index hash value, Pointing to child nodes pointers, leaf nodes The format is: ,in For quantum-resistant index hash values , An encrypted pointer. This is a pointer to the next leaf node.

[0121] Based on the node format in the B+ tree index structure and the quantum-resistant index hash value ,pointer and encrypted pointer This process determines the internal node information and leaf node information of the encrypted data within the B+ tree index structure. The internal node information is used for hierarchical traversal navigation queries, while the leaf node information is used for index queries of the entity data.

[0122] In this embodiment, a pointer to the storage location of the encrypted data is determined, and a key is derived from the PQC master private key to obtain the index encryption key. The index encryption algorithm is then executed according to its identifier, and the pointer is encrypted using the index encryption key to obtain the encrypted pointer. Based on the quantum-resistant index hash value, the pointer, and the encrypted pointer, the tree index information of the encrypted data, including internal node information and leaf node information, is determined. By constructing a ciphertext index with a tree index structure, efficient range queries and precise retrieval in the database are easily achieved.

[0123] As an optional implementation, the global security parameter set also includes: the identifier of the decryption algorithm corresponding to the encryption algorithm required for each layer of encryption.

[0124] Optionally, the decryption algorithm required for each layer of decryption can be determined by identifying the decryption algorithm corresponding to the encryption algorithm required for each layer of encryption in the global security parameter set.

[0125] Figure 9 Flowchart of the database encryption method provided in the embodiments of this application Figure 9 ,like Figure 9 As shown, the method also includes: S901. Receive a database query request and determine the quantum-resistant index hash value of the data field to be queried based on the database query request and the identifier of the quantum-resistant algorithm in the global security parameter set.

[0126] Optionally, the system receives a database query request in the form of Structured Query Language (SQL), parses the database query request, and determines the data fields to be queried.

[0127] Based on the quantum-resistant algorithm identifier, the quantum-resistant algorithm, namely SHA3-256, is executed to extract the feature value of the data field to be queried and use the feature value of the data field to be queried as the quantum-resistant index hash value of the data field to be queried. .

[0128] S902. Based on the quantum-resistant index hash value of the data field to be queried, obtain the encrypted pointer of the data field to be queried from the tree index structure, and retrieve the encrypted data of the data field to be queried from the database based on the encrypted pointer of the data field to be queried.

[0129] Optionally, the quantum-resistant index hash value of the data field to be queried can be used. Using the query index key, an encrypted pointer to the data field to be queried is obtained by traversing multiple levels of nodes in the B+ tree index structure. .

[0130] The index-based decryption algorithm is identified using the identifier in the global security parameter set. The index-based decryption algorithm can be the AES-128 symmetric decryption algorithm. That is, the AES-128 symmetric decryption algorithm is executed using the index encryption key. Encrypted pointer to the data field to be queried Decrypt the index to obtain a pointer to the storage location of the encrypted data of the field to be queried. .

[0131] In other words, a pointer to the storage location of the encrypted data of the data field to be queried. .in, This indicates that the AES-128 symmetric decryption algorithm is used for index decryption. For indexing encryption keys, An encrypted pointer to the data field to be queried.

[0132] Based on a pointer to the storage location of the encrypted data of the field to be queried. It retrieves the encrypted data of the data field to be queried from the database. The encrypted data of the data field to be queried is also stored as a composite structure record. It is stored in the database in the form of [database name].

[0133] S903. Based on the identifiers of each decryption algorithm in the global security parameter set, perform layered decryption on the encrypted data of the data field to be queried to obtain the data field to be queried.

[0134] Optionally, based on the identifiers of each decryption algorithm in the global security parameter set, the encrypted data of the data field to be queried is decrypted in layers within the security boundary of the HSM or TEE to obtain the data field to be queried.

[0135] Specifically, based on the asymmetric encapsulation of ciphertext in the encrypted data of the data field to be queried. The function calls the decapsulation function corresponding to the CRYSTALS-Kyber algorithm, specifically Kyber.Dec, and uses the PQC master private key SK to asymmetrically encapsulate the ciphertext in the encrypted data of the field to be queried. Perform asymmetric decapsulation to obtain the target data encryption key for the data field to be queried. .

[0136] ,in, This is the PQC master private key. The encrypted data of the field to be queried is asymmetrically encapsulated with ciphertext. This is the decapsulation function corresponding to the CRYSTALS-Kyber algorithm.

[0137] Randomly initialize vectors based on the encrypted data of the data field to be queried. Additional authentication data , Encryption results of the data fields to be queried The AES-256-GCM algorithm is used for decryption to obtain the plaintext message of the data field to be queried. Specifically, the plaintext message of the data field to be queried. ,in, This indicates that the AES-256-GCM algorithm is used for decryption. for , The encrypted result of the data field to be queried. 'and for These are the random initialization vector and additional authentication data in the encrypted data of the data field to be queried, respectively.

[0138] During the decryption process, an integrity authentication tag is generated and compared with the integrity authentication tag generated during the encryption of the data field to be queried. This ensures the integrity and security of the encrypted data. If the verification fails, a security warning is triggered. This guarantees the plaintext message of the data field to be queried. It is data that has not been tampered with.

[0139] In this embodiment, the global security parameter set also includes identifiers of decryption algorithms corresponding to the encryption algorithms required for each layer of encryption. It receives database query requests and, based on the database query request and the identifiers of the quantum-resistant algorithms in the global security parameter set, determines the quantum-resistant index hash value of the data field to be queried. Based on the quantum-resistant index hash value of the data field to be queried, it retrieves the encrypted pointer of the data field from the tree index structure, and then obtains the encrypted data of the data field to be queried from the database based on the encrypted pointer. Finally, based on the identifiers of each decryption algorithm in the global security parameter set, it performs layer-by-layer decryption on the encrypted data of the data field to be queried, thus obtaining the data field to be queried. This achieves efficient and secure querying of data in the database, improving data query efficiency and security.

[0140] Based on the same inventive concept, this application also provides a database encryption device corresponding to the database encryption method. Since the principle of the device in this application is similar to that of the database encryption method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0141] Figure 10 A module structure diagram of the database encryption device provided in the embodiments of this application is shown below. Figure 10 As shown, the device includes: The acquisition module 1001 is used to acquire a predefined global security parameter set, which includes the identifiers of the encryption algorithms required for each layer of encryption and the data storage strategy. The generation module 1002 is used to generate data encryption keys corresponding to each field type in the target data table in the database; The encryption module 1003 is used to perform layered encryption on the data fields to be encrypted based on the global security parameter set and the data encryption keys corresponding to each field type, so as to obtain the encrypted data. Storage module 1004 is used to store encrypted data in the database according to a global security parameter set.

[0142] As an optional implementation, the encryption module 1003 is specifically used for: Based on the identifier of the symmetric encryption algorithm in the global security parameter set, the target data encryption key corresponding to the field type of the data field to be encrypted is used to perform symmetric encryption on the data field to be encrypted, and obtain the symmetric encrypted ciphertext. Based on the identifier of the asymmetric encryption algorithm in the global security parameter set, the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain the asymmetric encapsulated ciphertext. Based on the identifiers of the quantum-resistant algorithm in the global security parameter set, generate a quantum-resistant index hash value for the data field to be encrypted; Based on the data storage strategy in the global security parameter set, the encrypted metadata information is determined, and the symmetric encrypted ciphertext, asymmetric encapsulated ciphertext, quantum-resistant index hash value, and encrypted metadata information are integrated into encrypted data in a preset storage format.

[0143] As an optional implementation, the encryption module 1003 is specifically used for: The symmetric encryption algorithm is executed according to the identifier of the symmetric encryption algorithm. The target key length of the target data encryption key is determined. A random number of the target key length is generated by a quantum random number generator, and the random number of the target key length is used as the target data encryption key. The data field to be encrypted is divided into data blocks to obtain multiple data blocks to be encrypted. Using the target data encryption key, each data block to be encrypted is symmetrically encrypted to obtain the ciphertext of each data block, and the ciphertexts of each data block are integrated into a symmetric encrypted ciphertext.

[0144] As an optional implementation, the encryption module 1003 is also used for: Determine the cumulative usage time of the target data encryption key and / or the cumulative number of decryption attempts using the target data encryption key; Determine whether to rotate the encryption key for the target data based on the cumulative usage time and / or cumulative decryption count; If so, a new target data encryption key is derived based on the target data encryption key, the common matrix, and the lattice generator. The new target data encryption key is then used to re-encrypt the data of the field type to which the data to be encrypted belongs, which is already stored in the database.

[0145] As an optional implementation, the encryption module 1003 is specifically used for: The asymmetric encryption algorithm is executed according to the identifier of the asymmetric encryption algorithm to generate a lattice-based PQC master key pair, which includes the PQC master public key and the PQC master private key. Call the encapsulation function corresponding to the asymmetric encryption algorithm, and use the PQC master public key to perform asymmetric encapsulation on the target data encryption key to obtain the asymmetric encapsulated ciphertext.

[0146] As an optional implementation, the encryption module 1003 is specifically used for: The quantum-resistant algorithm is executed according to the identifier of the quantum-resistant algorithm. A quantum-resistant hash operation is performed on the data field to be encrypted to extract the feature value of the data field to be encrypted. Use the feature value of the data field to be encrypted as the quantum-resistant index hash value of the data field to be encrypted.

[0147] As an optional implementation, the storage module 1004 is specifically used for: Based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value, determine the tree index information of the encrypted data; Based on the target storage location indicated by the tree index information, the encrypted data is stored in the target storage location of the database.

[0148] As an optional implementation, the storage module 1004 is specifically used for: Determine the pointer to the location where the encrypted data will be stored, and derive the index encryption key based on the PQC master private key; The index encryption algorithm is executed according to the identifier of the index encryption algorithm, and the pointer is encrypted using the index encryption key to obtain the encrypted pointer; Based on the quantum-resistant index hash value, pointer, and encrypted pointer, the tree index information of the encrypted data is determined. The tree index information includes internal node information and leaf node information.

[0149] As an optional implementation, the device further includes: The determination module 1005 is used to receive database query requests and determine the quantum-resistant index hash value of the data field to be queried based on the database query request and the quantum-resistant algorithm identifier in the global security parameter set. The query module 1006 is used to retrieve the encrypted pointer of the data field to be queried from the tree index structure based on the quantum-resistant index hash value of the data field to be queried, and to retrieve the encrypted data of the data field to be queried from the database based on the encrypted pointer of the data field to be queried. The decryption module 1007 is used to perform layered decryption of the encrypted data of the data field to be queried based on the identifiers of each decryption algorithm in the global security parameter set, so as to obtain the data field to be queried.

[0150] This application also provides an electronic device, such as... Figure 11 The diagram shown is a schematic representation of the structure of an electronic device provided in an embodiment of this application, including a processor 111, a memory 112, and a bus 113. The memory 112 stores machine-readable instructions executable by the processor 111. When the electronic device is running, the processor 111 communicates with the memory 112 via the bus 113, and the processor 111 executes the machine-readable instructions to perform the steps of the database encryption method in the aforementioned embodiment.

[0151] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the database encryption method described in the foregoing embodiments.

[0152] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.

[0153] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as 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 this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.

[0154] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. A database encryption method, characterized in that, include: Obtain a predefined global security parameter set, which includes the identifiers of the encryption algorithms required for each layer of encryption and the data storage strategy; Generate data encryption keys corresponding to each field type in the target data table in the database; Based on the global security parameter set and the data encryption keys corresponding to each field type, the data fields to be encrypted are encrypted in layers to obtain the encrypted data. The encrypted data is stored in the database according to the global security parameter set.

2. The method according to claim 1, characterized in that, The step involves performing layered encryption on the data fields to be encrypted in the database based on the global security parameter set and the data encryption keys corresponding to each field type, to obtain encrypted data, including: Based on the identifier of the symmetric encryption algorithm in the global security parameter set, the target data encryption key corresponding to the field type of the data field to be encrypted is used to perform symmetric encryption on the data field to be encrypted, and the symmetric encrypted ciphertext is obtained. Based on the identifier of the asymmetric encryption algorithm in the global security parameter set, the target data encryption key is asymmetrically encapsulated using the post-quantum cryptography PQC master public key to obtain asymmetric encapsulated ciphertext. Based on the identifiers of the quantum-resistant algorithms in the global security parameter set, generate the quantum-resistant index hash value of the data field to be encrypted; Based on the data storage strategy in the global security parameter set, the encrypted metadata information is determined, and the symmetric encrypted ciphertext, the asymmetric encapsulated ciphertext, the quantum-resistant index hash value, and the encrypted metadata information are integrated into encrypted data in a preset storage format.

3. The method according to claim 2, characterized in that, The step involves using the identifier of the symmetric encryption algorithm in the global security parameter set, and employing the target data encryption key corresponding to the field type of the data field to be encrypted, to perform symmetric encryption on the data field to be encrypted, resulting in symmetric encrypted ciphertext, including: The symmetric encryption algorithm is executed according to the identifier of the symmetric encryption algorithm to determine the target key length of the target data encryption key. A random number of the target key length is generated by a quantum random number generator, and the random number of the target key length is used as the target data encryption key. The data field to be encrypted is divided into multiple data blocks to be encrypted. Using the target data encryption key, each data block to be encrypted is symmetrically encrypted to obtain the ciphertext of each data block, and the ciphertexts of each data block are integrated into the symmetric encrypted ciphertext.

4. The method according to claim 3, characterized in that, Before performing symmetric encryption on each block of data to be encrypted using the target data encryption key, the process includes: Determine the cumulative usage duration of the target data encryption key and / or the cumulative number of decryption attempts using the target data encryption key; Based on the cumulative usage time and / or the cumulative decryption count, determine whether to rotate the target data encryption key; If so, a new target data encryption key is derived based on the target data encryption key, the common matrix, and the lattice generator. The new target data encryption key is then used to re-encrypt the data of the field type to which the data to be encrypted belongs, which is already stored in the database.

5. The method according to claim 2, characterized in that, The step involves using the identifier of the asymmetric encryption algorithm in the global security parameter set, and employing the post-quantum cryptography (PQC) master public key to asymmetricly encapsulate the target data encryption key, resulting in asymmetric encapsulated ciphertext, including: The asymmetric encryption algorithm is executed according to the identifier of the asymmetric encryption algorithm to generate a lattice-based PQC master key pair, wherein the PQC master key pair includes a PQC master public key and a PQC master private key; The encapsulation function corresponding to the asymmetric encryption algorithm is called, and the target data encryption key is asymmetrically encapsulated using the PQC master public key to obtain the asymmetric encapsulated ciphertext.

6. The method according to claim 2, characterized in that, The step of generating a quantum-resistant index hash value for the data field to be encrypted based on the identifier of the quantum-resistant algorithm in the global security parameter set includes: The anti-quantum algorithm is executed according to the identifier of the anti-quantum algorithm, and the anti-quantum hash operation is performed on the data field to be encrypted to extract the feature value of the data field to be encrypted; The feature value of the data field to be encrypted is used as the quantum-resistant index hash value of the data field to be encrypted.

7. The method according to claim 2, characterized in that, The step of storing the encrypted data in the database according to the global security parameter set includes: Based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value, determine the tree index information of the encrypted data; The encrypted data is stored in the target storage location of the database according to the target storage location indicated by the tree index information.

8. The method according to claim 7, characterized in that, The step of determining the tree index information of the encrypted data based on the identifier of the index encryption algorithm in the global security parameter set and the quantum-resistant index hash value includes: A pointer to the location where the encrypted data will be stored is determined, and an index encryption key is obtained by derivation based on the PQC master private key. The index encryption algorithm is executed according to the identifier of the index encryption algorithm, and the pointer is encrypted using the index encryption key to obtain the encrypted pointer; Based on the quantum-resistant index hash value, the pointer, and the encrypted pointer, the tree index information of the encrypted data is determined, and the tree index information includes internal node information and leaf node information.

9. The method according to any one of claims 1-8, characterized in that, The global security parameter set also includes: the identifiers of the decryption algorithms corresponding to the encryption algorithms required for each layer of encryption; The method further includes: Receive a database query request, and determine the quantum-resistant index hash value of the data field to be queried based on the database query request and the identifier of the quantum-resistant algorithm in the global security parameter set; Based on the quantum-resistant index hash value of the data field to be queried, the encrypted pointer of the data field to be queried is obtained from the tree index structure, and the encrypted data of the data field to be queried is obtained from the database based on the encrypted pointer of the data field to be queried. Based on the identifiers of each decryption algorithm in the global security parameter set, the encrypted data of the data field to be queried is decrypted in layers to obtain the data field to be queried.

10. An electronic device, characterized in that, include: The electronic device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the database encryption method as described in any one of claims 1 to 9.