A data processing method, device, equipment and medium
By using third-party server management key pairs in Ceph distributed object storage system to generate ciphertext and plaintext keys, the performance bottlenecks and security problems caused by key management in Ceph object storage system are solved, and more efficient data is achieved Processing and security.
Patent Information
- Application Number
- CN202211587299.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-12-07
AI Technical Summary
In Ceph distributed object storage system, the existing object storage gateway is designed to use barbican server management keys, resulting in limited download performance, excessive metadata usage, and performance-affected performance, and master key leakage may lead to file leakage.
Using data processing methods, generate ciphertext keys or plaintext keys according to the data request type, manage key pairs through third-party servers, reduce master key operations, improve security, and save key groups in local bucket metadata , reduce the amount of metadata storage.
It improves the security and performance of data processing, reduces the storage of file metadata, avoids the risk of master key leakage, and improves the efficiency of data processing.
Smart Images

Figure CN116015767B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and in particular to a data processing method, device, equipment and medium. Background Art
[0002] Ceph is a distributed object storage system, and data security is one of the key issues that object storage needs to solve. In the original Ceph object storage gateway design, the barbican server (KMS1.0 for short) is used to manage keys. Each time a file is downloaded, the master key needs to be decrypted in KMS1.0, which limits the download performance. The master key string is also stored in the metadata of the file. When there are too many files, too much memory of the metadata server will be occupied, seriously affecting the performance of the Ceph storage system. And when managing keys based on KMS1.0, each master key corresponds to a unique decryption key. When the master key is leaked, file leaks may occur.
[0003] As can be seen from the above, in the process of data processing, how to improve data security, reduce the storage volume of file metadata, and improve the performance and efficiency of data processing are problems to be solved in this field. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a data processing method, device, equipment and medium, which can improve data security, reduce the storage volume of file metadata, and improve the performance and efficiency of data processing. The specific scheme is as follows:
[0005] In a first aspect, the present application discloses a data processing method, comprising:
[0006] Determine the type of the acquired data request; the type includes key group storage, file encryption, and file decryption;
[0007] If the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket;
[0008] If the type of the acquired data request is file encryption, an encryption key group is screened from the metadata according to the data request to obtain an encryption ciphertext key in the encryption key group, an encryption plaintext key corresponding to the encryption ciphertext key is determined from a third-party server, and the data in the file to be encrypted is encrypting by using the encryption plaintext key;
[0009] If the type of the data request obtained is file decryption, a decryption ciphertext key is filtered out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the file to be decrypted is decrypted using the decryption plaintext key.
[0010] Optionally, if the type of the acquired data request is a key group, after the key group is saved, the method further includes:
[0011] Determining master key version information in the data request;
[0012] Determine whether the master key version information is the latest version. If the master key version information is the latest version, verify the master key in the data request. If the verification passes, send the master key in the data request to the third-party server so that the third-party server generates a plaintext key based on the master key and saves the plaintext key to the third-party server.
[0013] Optionally, the generating a ciphertext key based on the data request, generating a key group based on the ciphertext key, and saving the key to metadata of a local storage bucket includes:
[0014] Performing base64 encoding operation on the master key, key generation information and the master key version information in the data request to obtain a ciphertext key;
[0015] A key serial number corresponding to the master key is determined, the ciphertext key and the key serial number are combined to obtain a key group, and the key group, the key serial number and the master key version information are saved to the metadata of the storage bucket.
[0016] Optionally, if the type of the acquired data request is file encryption, filtering out an encryption key group from the metadata according to the data request includes:
[0017] If the type of the acquired data request is file encryption, determine whether the master key version information in the metadata of the storage bucket is the latest version; if the master key version information in the metadata of the storage bucket is the latest version, obtain the encryption key serial number from the metadata;
[0018] A key group having the same serial number as the encryption key is selected from the metadata according to the data request as the encryption key group.
[0019] Optionally, determining from the third-party server an encrypted plaintext key corresponding to the encrypted ciphertext key, and encrypting the data in the file to be encrypted using the encrypted plaintext key includes:
[0020] Determine whether the master key in the data request is available. If the master key in the data request is available, determine the encrypted plaintext key corresponding to the encrypted ciphertext key and the version information of the encrypted plaintext key from the third-party server and the metadata respectively, and save the version information of the encrypted plaintext key, the encryption algorithm and the key serial number to the file to be encrypted;
[0021] The file to be encrypted is encrypted using the encrypted plaintext key.
[0022] Optionally, if the type of the acquired data request is file decryption, filtering out a decryption ciphertext key from the metadata according to the data request, and determining a decryption plaintext key corresponding to the decryption ciphertext key from the third-party server includes:
[0023] If the type of the acquired data request is file decryption, then the encryption key serial number in the file to be decrypted is obtained;
[0024] A decryption ciphertext key is screened out from the storage bucket according to the encryption key serial number, and a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server.
[0025] Optionally, after encrypting the data in the to-be-encrypted file using the encrypted plaintext key, the method further includes:
[0026] Determine an encryption key pair based on the encryption ciphertext key and the encryption plaintext key;
[0027] The encryption key pair is saved to a local cache, the saving time is recorded, and a key deletion time is determined. When it is detected that the current time reaches the key deletion time, the encryption key pair is deleted;
[0028] When the data request type corresponding to the encrypted ciphertext key is file decryption, determine whether the encrypted ciphertext key still exists in the cache. If the encrypted ciphertext key does not exist in the cache, directly jump to the step of determining the decryption plaintext key corresponding to the decryption ciphertext key from the third-party server. If the encrypted ciphertext key exists in the cache, directly obtain the decryption plaintext key corresponding to the decryption ciphertext key from the cache.
[0029] In a second aspect, the present application discloses a data processing device, comprising:
[0030] A determination module, used to determine the type of the acquired data request; the type includes key group storage, file encryption and file decryption;
[0031] A key group generation module, configured to generate a ciphertext key based on the data request if the type of the acquired data request is key group storage, generate a key group based on the ciphertext key, and save the key group to the metadata of the local storage bucket;
[0032] an encryption module, configured to, if the type of the acquired data request is file encryption, filter out an encryption key group from the metadata according to the data request to obtain an encryption ciphertext key in the encryption key group, determine an encryption plaintext key corresponding to the encryption ciphertext key from a third-party server, and encrypt data in the file to be encrypted using the encryption plaintext key;
[0033] A decryption module is used to, if the type of the acquired data request is file decryption, filter out a decryption ciphertext key from the metadata according to the data request, determine a decryption plaintext key corresponding to the decryption ciphertext key from the third-party server, and use the decryption plaintext key to decrypt the data in the file to be decrypted.
[0034] In a third aspect, the present application discloses an electronic device, comprising:
[0035] Memory, used to store computer programs;
[0036] The processor is used to execute the computer program to implement the aforementioned data processing method.
[0037] In a fourth aspect, the present application discloses a computer storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned disclosed data processing method are implemented.
[0038] It can be seen that the present application provides a data processing method, including determining the type of data request obtained; the types include key group storage, file encryption and file decryption; if the type of data request obtained is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket; if the type of data request obtained is file encryption, an encryption key group is screened out from the metadata according to the data request to obtain an encrypted ciphertext key in the encryption key group, an encrypted plaintext key corresponding to the encrypted ciphertext key is determined from a third-party server, and the encrypted plaintext key is used to encrypt the data in the file to be encrypted; if the type of data request obtained is file decryption, a decryption ciphertext key is screened out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the decryption plaintext key is used to decrypt the data in the file to be decrypted. This application is applied to the envelope key management server (abbreviated as KMS2.0), which can use the master key to generate a key pair of plaintext key (i.e. plaintext DEK) and ciphertext key (ciphertext DEK). The key pair generated each time is different, so the security is improved, and the storage amount of file metadata can be reduced, thereby improving the performance and efficiency of data processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0040] Figure 1 A flow chart of a data processing method disclosed in this application;
[0041] Figure 2 A specific flow chart of a data processing method disclosed in this application;
[0042] Figure 3 A flow chart of a data processing method disclosed in this application;
[0043] Figure 4 A specific flow chart of a data processing method disclosed in this application;
[0044] Figure 5 A specific flow chart of a data processing method disclosed in this application;
[0045] Figure 6 A schematic diagram of the structure of a data processing device disclosed in this application;
[0046] Figure 7 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Ceph is a distributed object storage system, and data security is one of the key issues to be solved in object storage. In the original object storage gateway design of Ceph, the barbican server (KMS1.0 for short) is used to manage keys. Each time a file is downloaded, the master key needs to be decrypted in KMS1.0, which limits the download performance. The master key string is also stored in the metadata of the file. When there are too many files, it will occupy too much memory of the metadata server, seriously affecting the performance of the Ceph storage system. And when managing keys based on KMS1.0, each master key corresponds to a unique decryption key. When the master key is leaked, file leakage may occur. As can be seen from the above, in the process of data processing, how to improve data security, reduce the storage volume of file metadata, and improve the performance and efficiency of data processing are issues to be solved in this field.
[0049] See also Figure 1 As shown, the embodiment of the present invention discloses a data processing method, which may specifically include:
[0050] Step S11: Determine the type of the acquired data request; the type includes key group storage, file encryption, and file decryption.
[0051] Step S12: If the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket.
[0052] In this embodiment, if the type of data request obtained is a key group, after saving, it also includes: determining the master key version information in the data request; judging whether the master key version information is the latest version, if the master key version information is the latest version, verifying the master key in the data request, if the verification passes, sending the master key in the data request to a third-party server, so that the third-party server generates a plaintext key based on the master key, and saves the plaintext key to the third-party server.
[0053] Specifically, the key group storage process is as follows: perform base64 encoding on the master key, key generation information and the master key version information in the data request to obtain the ciphertext key; determine the key serial number corresponding to the master key, combine the ciphertext key and the key serial number to obtain the key group, and save the key group, the key serial number and the master key version information to the metadata of the storage bucket.
[0054] In this embodiment, in KMS2.0, a key pair of plaintext DEK and ciphertext DEK can be generated on a third-party server based on the master key, and the plaintext DEK can be decrypted on the key server based on the ciphertext DEK. The ciphertext DEK is composed of the master key, key generation information and master key version information encoded and encrypted in base64. The ciphertext DEK can also be base64 decoded to decrypt the above information.
[0055] Step S13: If the type of the acquired data request is file encryption, an encryption key group is screened out from the metadata according to the data request to obtain an encrypted ciphertext key in the encryption key group, an encrypted plaintext key corresponding to the encrypted ciphertext key is determined from a third-party server, and the encrypted plaintext key is used to encrypt the data in the file to be encrypted.
[0056] In this embodiment, after using the encrypted plaintext key to encrypt the data in the to-be-encrypted file, it also includes: determining an encryption key pair based on the encrypted ciphertext key and the encrypted plaintext key; saving the encryption key pair to a local cache, recording the saving time, and determining the key deletion time, and when it is detected that the current time reaches the key deletion time, deleting the encryption key pair; when the data request type corresponding to the encrypted ciphertext key is obtained as file decryption, determining whether the encrypted ciphertext key still exists in the cache, if the encrypted ciphertext key does not exist in the cache, directly jumping to the step of determining the decryption plaintext key corresponding to the decryption ciphertext key from the third-party server, if the encrypted ciphertext key exists in the cache, directly obtaining the decryption plaintext key corresponding to the decryption ciphertext key from the cache.
[0057] In this embodiment, in KMS1.0, only one encryption key can be obtained based on the master key. In order to be compatible with the data saved in the Ceph system using KMS1.0, when setting encryption, it is necessary to verify whether the key is KMS1.0 version or KMS2.0 version. In Ceph's object storage system, when setting the storage bucket to save data in an encrypted manner, the master key is transmitted to the object storage system through an http (HyperText Transfer Protocol) request. Then first verify the master key in KMS2.0. If the verification fails, verify it in KMS1.0 again, and set the encryption type according to the verification result.
[0058] The specific encryption process is as follows Figure 2 As shown, when the verification in KMS2.0 is passed, envelope encryption is used. Use the master key in the data request to parse KMS2.0 to obtain the plaintext DEK and ciphertext DEK. After obtaining, save the key sequence number (sorted from "1") and ciphertext DEK as a group of key groups to the user.rgw.crypt.bucketkeystore of the bucket metadata, and set the newly added key group as the encryption key group used by the bucket to encrypt files. When setting server-side encryption for the bucket later, first traverse the ciphertext DEK in the bucket key warehouse, perform base64 decoding, and then check whether the master key of the current request is in the key store. If it exists in the database, no new key group will be added. The existing encryption group will be set as the encryption key group used to encrypt files. At the same time, when encrypting envelopes, the master key will be set to the user.rgw.crypt.keyid parameter of the bucket's metadata, and the version information (version), encryption algorithm (algorithm) and key sequence number (bucketkeyid) of the KMS encryption key group used to encrypt files will be set in the user.rgw.crypt.kmskeyinfo of the bucket's metadata. The specific format is:
[0059] user.rgw.crypt.kmskeyinfo:"{"version":"v2","algorithm":"AES256","bucketk eyid:"1"}"
[0060] The meaning of each parameter is:
[0061] Key version information (version): v1 when using KMS1.0, v2 when using KMS2.0;
[0062] Encryption algorithm: AES256;
[0063] Key serial number (bucketkeyid): When using kms2.0, it is the key serial number currently in use. When using kms1.0, it is empty.
[0064] Therefore, after setting up envelope encryption, there are three parameters for server-side encryption in the bucket metadata:
[0065] (1) Master Key
[0066] user.rgw.crypt.keyid:***
[0067] (2) Key library, including key serial number and ciphertext DEK
[0068] user.rgw.crypt.bucketkeystore:{
[0069] "1":"Ciphertext DEK1",
[0070] "2":"Ciphertext DEK1"
[0071] }
[0072] (3) Encryption key group used to encrypt files
[0073] user.rgw.crypt.kmskeyinfo:"{"version":"v2","algorithm":"AES256","bucketk eyid":"1"}"
[0074] When KMS1.0 is identified, the master key is set to the user.rgw.crypt.keyid parameter, and the encryption information is set to user.rgw.crypt.kmskeyinfo in the bucket attr. The specific format is:
[0075] user.rgw.crypt.kmskeyinfo:"{"version":"v1","algorithm":"AES256","bucketk eyid:""}"
[0076] Step S14: If the type of the acquired data request is file decryption, a decryption ciphertext key is screened out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the file to be decrypted is decrypted using the decryption plaintext key.
[0077] In this embodiment, the type of the acquired data request is determined; the types include key group storage, file encryption and file decryption; if the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket; if the type of the acquired data request is file encryption, an encryption key group is screened out from the metadata according to the data request to obtain an encrypted ciphertext key in the encryption key group, an encrypted plaintext key corresponding to the encrypted ciphertext key is determined from a third-party server, and the data in the to-be-encrypted file is encrypting using the encrypted plaintext key; if the type of the acquired data request is file decryption, a decryption ciphertext key is screened out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the to-be-encrypted file is decrypted using the decryption plaintext key. This application is applied to the envelope key management server (abbreviated as KMS2.0), which can use the master key to generate a key pair of plaintext key (i.e. plaintext DEK) and ciphertext key (ciphertext DEK). The key pair generated each time is different, so the security is improved, and the storage amount of file metadata can be reduced, thereby improving the performance and efficiency of data processing.
[0078] See also Figure 3 As shown, the embodiment of the present invention discloses a data processing method, which may specifically include:
[0079] Step S21: Determine the type of the acquired data request; the type includes key group storage, file encryption, and file decryption.
[0080] Step S22: If the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket.
[0081] In this embodiment, the specific process of generating and saving the key group is as follows: Figure 4As shown, first set KMS encryption for the bucket, then determine whether the key can pass the verification in KMS2.0. If so, traverse the ciphertext DEK in the bucket keystore and perform base64 decoding. Then check whether the currently requested master key is in the keystore. If so, no new key group is added, and the currently existing encryption group is set as the encryption key group for encrypting files. If not, generate a ciphertext key based on the master key, and then generate a key group based on the ciphertext key, and save the key group to the metadata of the local storage bucket. If the key does not pass the verification in KMS2.0, determine whether the key can pass the verification in KMS1.0. If so, write the encryption key to user.rgw.crypt.keyid in the bucket metadata, and save the key version information (version), encryption algorithm (algorithm) and key serial number (bucketkeyid) to user.rgw.crypt.kmskeyinfo of the bucket metadata.
[0082] Step S23: If the type of the data request obtained is file encryption, determine whether the master key version information in the metadata of the storage bucket is the latest version; if the master key version information in the metadata of the storage bucket is the latest version, obtain the encryption key serial number from the metadata, and then filter out the key group with the same encryption key serial number as the encryption key group from the metadata according to the data request to obtain the encrypted ciphertext key in the encryption key group, determine the encrypted plaintext key corresponding to the encrypted ciphertext key from the third-party server, and use the encrypted plaintext key to encrypt the data in the encrypted file.
[0083] In this embodiment, specifically, determining an encrypted plaintext key corresponding to the encrypted ciphertext key from a third-party server, and encrypting the data in the to-be-encrypted file using the encrypted plaintext key, includes: judging whether the master key in the data request is available, and if the master key in the data request is available, determining the encrypted plaintext key corresponding to the encrypted ciphertext key and the version information of the encrypted plaintext key from the third-party server and the metadata respectively, saving the version information of the encrypted plaintext key, the encryption algorithm and the key serial number to the to-be-encrypted file; and encrypting the to-be-encrypted file using the encrypted plaintext key.
[0084] Step S24: If the type of the acquired data request is file decryption, a decryption ciphertext key is filtered out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the file to be decrypted is decrypted using the decryption plaintext key.
[0085] In this embodiment, if the type of data request obtained is file decryption, the encryption key serial number in the file to be decrypted is obtained, the decryption ciphertext key is screened out from the metadata of the storage bucket according to the encryption key serial number, the decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and then the decryption plaintext key is used to decrypt the data in the file to be decrypted.
[0086] In this embodiment, the specific decryption process is as follows: Figure 5 As shown, when downloading a KMS-encrypted file, first read the content in the file metadata user.rgw.crypt.kmskeyinfo. If it is empty, use the KMS1.0 decryption logic. If user.rgw.crypt.kmskeyinfo is not empty and the key version is v1, use the KMS1.0 decryption logic. If the key version is v2, use the KMS2.0 decryption logic. When using KMS2.0 to decrypt, get the corresponding ciphertext DEK from the user.rgw.crypt.bucketkeystore of the bucket's attr according to the key sequence number in user.rgw.crypt.kmskeyinfo. Use the ciphertext DEK to exchange for the plaintext DEK and then decrypt the file. When using the original KMS1.0 encryption, read user.rgw.crypt.keyid as the key-id, exchange for the key in the KMS1.0 server and then decrypt.
[0087] This application is applied to the envelope plus key management server (abbreviated as KMS2.0), which can use the master key to generate a key pair of plaintext key and ciphertext key. The key pair generated each time is different, so the security is improved. When encrypting, the plaintext DEK is used to encrypt the data, and the ciphertext DEK is saved for decryption. When decrypting, the ciphertext DEK is used to decrypt the plaintext DEK on the KMS2.0 server, and the plaintext DEK is used to decrypt the data. This process reduces the operation of the master key and further improves security. When saving the ciphertext DEK, it is not directly saved in the metadata of the file, but saved in the attr (metadata) of the storage bucket, and a key serial number is saved for the ciphertext DEK. The key serial number is saved in the metadata of the file. When decrypting the file, the ciphertext DEK is obtained in the metadata of the storage bucket according to the key serial number, and the plaintext DEK is obtained according to the ciphertext DEK for decryption. Using this solution can reduce the storage volume of file metadata. In order to avoid the need for decryption keys every time data is downloaded, this solution will cache the ciphertext DEK and plaintext DEK in the file system. Taking the cache time of 5 minutes as an example, within 5 minutes, there is no need to obtain the ciphertext DEK in KMS2.0 based on the plaintext DEK. It only needs to be obtained in the cache, reducing the dependence on the KMS2.0 system, thereby improving performance. In this application, it is also compatible with data that has been encrypted using KMS1.0 to achieve high availability of the system.
[0088] In this embodiment, the type of the acquired data request is determined; the types include key group storage, file encryption and file decryption; if the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket; if the type of the acquired data request is file encryption, an encryption key group is screened out from the metadata according to the data request to obtain an encrypted ciphertext key in the encryption key group, an encrypted plaintext key corresponding to the encrypted ciphertext key is determined from a third-party server, and the data in the to-be-encrypted file is encrypting using the encrypted plaintext key; if the type of the acquired data request is file decryption, a decryption ciphertext key is screened out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the to-be-encrypted file is decrypted using the decryption plaintext key. This application is applied to the envelope key management server (abbreviated as KMS2.0), which can use the master key to generate a key pair of plaintext key (i.e. plaintext DEK) and ciphertext key (ciphertext DEK). The key pair generated each time is different, so the security is improved, and the storage amount of file metadata can be reduced, thereby improving the performance and efficiency of data processing.
[0089] See also Figure 6As shown, an embodiment of the present invention discloses a data processing device, which may specifically include:
[0090] A determination module 11 is used to determine the type of the acquired data request; the type includes key group storage, file encryption and file decryption;
[0091] A key group generation module 12 is used to generate a ciphertext key based on the data request if the type of the acquired data request is key group storage, generate a key group based on the ciphertext key, and save the key group to the metadata of the local storage bucket;
[0092] The encryption module 13 is configured to, if the type of the acquired data request is file encryption, filter out an encryption key group from the metadata according to the data request to obtain an encryption ciphertext key in the encryption key group, determine an encryption plaintext key corresponding to the encryption ciphertext key from a third-party server, and encrypt the data in the file to be encrypted using the encryption plaintext key;
[0093] The decryption module 14 is used to filter out a decryption ciphertext key from the metadata according to the data request if the type of the acquired data request is file decryption, determine a decryption plaintext key corresponding to the decryption ciphertext key from the third-party server, and use the decryption plaintext key to decrypt the data in the file to be decrypted.
[0094] In this embodiment, the type of the acquired data request is determined; the types include key group storage, file encryption and file decryption; if the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket; if the type of the acquired data request is file encryption, an encryption key group is screened out from the metadata according to the data request to obtain an encrypted ciphertext key in the encryption key group, an encrypted plaintext key corresponding to the encrypted ciphertext key is determined from a third-party server, and the data in the to-be-encrypted file is encrypting using the encrypted plaintext key; if the type of the acquired data request is file decryption, a decryption ciphertext key is screened out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the to-be-encrypted file is decrypted using the decryption plaintext key. This application uses the "Envelope Plus Key Management Server (KMS2.0 for short)", which can use the "master key" to generate a key pair of "plaintext key (ie plaintext DEK) + ciphertext key (ciphertext DEK)". The key pair generated each time is different, so the security is improved, and it can reduce the storage amount of file metadata and improve the performance and efficiency of data processing.
[0095] In some specific embodiments, the key group generation module 12 may specifically include:
[0096] A master key version information determination module, used to determine the master key version information in the data request;
[0097] The version judgment module is used to judge whether the master key version information is the latest version. If the master key version information is the latest version, the master key in the data request is verified. If the verification passes, the master key in the data request is sent to the third-party server so that the third-party server generates a plaintext key based on the master key and saves the plaintext key to the third-party server.
[0098] In some specific embodiments, the key group generation module 12 may specifically include:
[0099] A ciphertext key determination module, used to perform a base64 encoding operation on the master key, key generation information and the master key version information in the data request to obtain a ciphertext key;
[0100] A key serial number determination module is used to determine the key serial number corresponding to the master key, combine the ciphertext key and the key serial number to obtain a key group, and save the key group, the key serial number and the master key version information to the metadata of the storage bucket.
[0101] In some specific embodiments, the encryption module 13 may specifically include:
[0102] an encryption key serial number determination module, configured to determine whether the master key version information in the metadata of the storage bucket is the latest version if the type of the acquired data request is file encryption, and to obtain the encryption key serial number from the metadata if the master key version information in the metadata of the storage bucket is the latest version;
[0103] The encryption key group determination module is used to select a key group with the same encryption key sequence number as the encryption key group from the metadata according to the data request.
[0104] In some specific embodiments, the encryption module 13 may specifically include:
[0105] a module for storing files to be encrypted, used to determine whether the master key in the data request is available; if the master key in the data request is available, determining the encrypted plaintext key corresponding to the encrypted ciphertext key and the version information of the encrypted plaintext key from the third-party server and the metadata respectively, and saving the version information of the encrypted plaintext key, the encryption algorithm and the key serial number to the file to be encrypted;
[0106] The encryption module is used to encrypt the file to be encrypted using the encryption plaintext key.
[0107] In some specific embodiments, the decryption module 14 may specifically include:
[0108] An encryption key serial number determination module, used for obtaining the encryption key serial number in the file to be decrypted if the type of the acquired data request is file decryption;
[0109] The decryption ciphertext key determination module is used to select the decryption ciphertext key from the storage bucket according to the encryption key serial number, and determine the decryption plaintext key corresponding to the decryption ciphertext key from the third-party server.
[0110] In some specific embodiments, the encryption module 13 may specifically include:
[0111] An encryption key pair determination module, configured to determine an encryption key pair based on the encryption ciphertext key and the encryption plaintext key;
[0112] A deletion module, used to save the encryption key pair to a local cache, record the saving time, and determine the key deletion time, and when it is detected that the current time reaches the key deletion time, delete the encryption key pair;
[0113] A cache module, for determining whether the encrypted ciphertext key still exists in the cache when the data request type corresponding to the encrypted ciphertext key is file decryption; if the encrypted ciphertext key does not exist in the cache, directly jumping to the step of determining the decryption plaintext key corresponding to the decryption ciphertext key from the third-party server; if the encrypted ciphertext key exists in the cache, directly obtaining the decryption plaintext key corresponding to the decryption ciphertext key from the cache.
[0114] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the data processing method performed by the electronic device disclosed in any of the aforementioned embodiments.
[0115] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0116] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.
[0117] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20 to realize the operation and processing of the data 223 in the memory 22 by the processor 21, which can be Windows, Unix, Linux, etc. In addition to including a computer program that can be used to complete the data processing method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data transmitted from an external device received by the data processing device, the data 223 can also include data collected by its own input and output interface 25, etc.
[0118] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0119] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the data processing method disclosed in any of the aforementioned embodiments are implemented.
[0120] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0121] The data processing method, device, equipment and storage medium provided by the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A data processing method, characterized in that: include: Determine the type of data request to obtain; The types include key group storage, file encryption, and file decryption; If the type of the acquired data request is key group storage, a ciphertext key is generated based on the data request, a key group is generated based on the ciphertext key, and the key group is saved to the metadata of the local storage bucket; If the type of the acquired data request is file encryption, an encryption key group is screened from the metadata according to the data request to obtain an encryption ciphertext key in the encryption key group, an encryption plaintext key corresponding to the encryption ciphertext key is determined from a third-party server, and the data in the file to be encrypted is encrypting by using the encryption plaintext key; If the type of the acquired data request is file decryption, a decryption ciphertext key is screened out from the metadata according to the data request, a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server, and the data in the file to be decrypted is decrypted using the decryption plaintext key; After encrypting the data in the to-be-encrypted file using the encrypted plaintext key, the method further includes: Determine an encryption key pair based on the encryption ciphertext key and the encryption plaintext key; The encryption key pair is saved to a local cache, the saving time is recorded, and a key deletion time is determined. When it is detected that the current time reaches the key deletion time, the encryption key pair is deleted; When the data request type corresponding to the encrypted ciphertext key is file decryption, determine whether the encrypted ciphertext key still exists in the cache. If the encrypted ciphertext key does not exist in the cache, directly jump to the step of determining the decryption plaintext key corresponding to the decryption ciphertext key from the third-party server. If the encrypted ciphertext key exists in the cache, directly obtain the decryption plaintext key corresponding to the decryption ciphertext key from the cache.
2. The data processing method according to claim 1, characterized in that: If the type of the acquired data request is a key group storage, the method further includes: Determining master key version information in the data request; Determine whether the master key version information is the latest version. If the master key version information is the latest version, verify the master key in the data request. If the verification passes, send the master key in the data request to the third-party server so that the third-party server generates a plaintext key based on the master key and saves the plaintext key to the third-party server.
3. The data processing method according to claim 2, characterized in that: The generating a ciphertext key based on the data request, generating a key group based on the ciphertext key, and saving the key to metadata of a local storage bucket includes: Performing base64 encoding operation on the master key, key generation information and the master key version information in the data request to obtain a ciphertext key; A key serial number corresponding to the master key is determined, the ciphertext key and the key serial number are combined to obtain a key group, and the key group, the key serial number and the master key version information are saved to the metadata of the storage bucket.
4. The data processing method according to claim 3, characterized in that: If the type of the acquired data request is file encryption, filtering out an encryption key group from the metadata according to the data request includes: If the type of the acquired data request is file encryption, determine whether the master key version information in the metadata of the storage bucket is the latest version; if the master key version information in the metadata of the storage bucket is the latest version, obtain the encryption key serial number from the metadata; A key group having the same serial number as the encryption key is selected from the metadata according to the data request as the encryption key group.
5. The data processing method according to claim 4, characterized in that: The step of determining an encrypted plaintext key corresponding to the encrypted ciphertext key from a third-party server and encrypting the data in the file to be encrypted by using the encrypted plaintext key comprises: Determine whether the master key in the data request is available. If the master key in the data request is available, determine the encrypted plaintext key corresponding to the encrypted ciphertext key and the version information of the encrypted plaintext key from the third-party server and the metadata respectively, and save the version information of the encrypted plaintext key, the encryption algorithm and the key serial number to the file to be encrypted; The file to be encrypted is encrypted using the encrypted plaintext key.
6. The data processing method according to claim 1, characterized in that: If the type of the acquired data request is file decryption, filtering out a decryption ciphertext key from the metadata according to the data request, and determining a decryption plaintext key corresponding to the decryption ciphertext key from the third-party server, including: If the type of the acquired data request is file decryption, then the encryption key serial number in the file to be decrypted is obtained; A decryption ciphertext key is screened out from the storage bucket according to the encryption key serial number, and a decryption plaintext key corresponding to the decryption ciphertext key is determined from the third-party server.
7. A data processing device, characterized in that: include: A judgment module, used to judge the type of the acquired data request; The types include key group storage, file encryption, and file decryption; A key group generation module, configured to generate a ciphertext key based on the data request if the type of the acquired data request is key group storage, generate a key group based on the ciphertext key, and save the key group to the metadata of the local storage bucket; an encryption module, configured to, if the type of the acquired data request is file encryption, filter out an encryption key group from the metadata according to the data request to obtain an encryption ciphertext key in the encryption key group, determine an encryption plaintext key corresponding to the encryption ciphertext key from a third-party server, and encrypt data in the file to be encrypted using the encryption plaintext key; a decryption module, configured to, if the type of the acquired data request is file decryption, filter out a decryption ciphertext key from the metadata according to the data request, determine a decryption plaintext key corresponding to the decryption ciphertext key from the third-party server, and decrypt the data in the file to be decrypted using the decryption plaintext key; The encryption module is further used to determine an encryption key pair based on the encryption ciphertext key and the encryption plaintext key after encrypting the data in the to-be-encrypted file using the encryption plaintext key; The encryption key pair is saved to a local cache, the saving time is recorded, and the key deletion time is determined. When it is detected that the current time reaches the key deletion time, the encryption key pair is deleted. When the data request type corresponding to the encryption ciphertext key is obtained as file decryption, it is determined whether the encryption ciphertext key still exists in the cache. If the encryption ciphertext key does not exist in the cache, it is directly jumped to the step of determining the decryption plaintext key corresponding to the decryption ciphertext key from the third-party server. If the encryption ciphertext key exists in the cache, the decryption plaintext key corresponding to the decryption ciphertext key is directly obtained from the cache.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the data processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 6 is implemented.
