Data processing method and device, electronic equipment and storage medium
By splicing encrypted data, key identification and key validity time information, the problem of key rotation delay is solved, timely judgment and rotation of key expiration are realized, and the continuous security of data is ensured.
Patent Information
- Application Number
- CN202410627965.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-08-27
AI Technical Summary
In the existing technology, database managers cannot determine whether the key has expired through the encrypted ciphertext, resulting in a delay in key rotation and increasing the risk of data loss and leakage.
By splicing the encrypted data, key identification and key validity time information into spliced data in the data processing method, the key expiration judgment is realized, and decryption and new key generation are performed when the key expires, completing Key rotation.
It realizes the timely judgment and rotation of key expiration, avoids the risk of data loss or leakage caused by key expiration or not replacing it for a long time, and improves the continuous security of data.
Smart Images

Figure CN118551397A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data security technology, and in particular to a data processing method, device, electronic equipment and storage medium. Background Art
[0002] In order to ensure the confidentiality of important data stored in information systems, a certain encryption algorithm is usually used to encrypt the data according to the key, and then the encrypted important data is stored in the database. In the encryption algorithm, if the key is always kept unchanged, the security of the key cannot be guaranteed. Therefore, in order to improve the security factor of data encryption, it is necessary to update the key based on the key life cycle, such as updating the key once every six months or one year, so that the data to be stored can be re-encrypted and stored regularly. This method is called key rotation.
[0003] Although key rotation is introduced on the basis of encryption algorithm in the prior art, for the relevant managers of the database, it is impossible to determine whether the key of the data has expired only by the ciphertext after data encryption, which leads to errors in the operation of related files of the encrypted data, and increases the risk of data loss and leakage due to failure to rotate the key in time when the key expires. Summary of the invention
[0004] To solve the existing technical problems, the embodiments of the present invention provide a data processing method, device, electronic device and storage medium.
[0005] To achieve the above object, the technical solution of the embodiment of the present invention is implemented as follows:
[0006] An embodiment of the present invention provides a data processing method, which is applied to an electronic device, and includes: obtaining first spliced data, the first spliced data including first encrypted data, a first key identifier, and valid time information of a first key corresponding to the first key identifier, the first encrypted data being obtained by encrypting data based on the first key corresponding to the first key identifier;
[0007] Determining whether the first key has expired based on the validity time information corresponding to the first key;
[0008] In the case where it is determined that the first key has expired, decrypting the first encrypted data using the first key to obtain the data;
[0009] Generate a second key, use the second key to encrypt the data to obtain second encrypted data, and obtain second spliced data based on the second encrypted data, wherein the second spliced data includes the second encrypted data, a second key identifier, and valid time information of the second key corresponding to the second key identifier.
[0010] In the above scheme, the electronic device includes a password module and an encryption and decryption module; the decrypting the first encrypted data using the first key to obtain the data includes: the encryption and decryption module of the electronic device sends the first encrypted data and the first key identifier to the password module and calls the decryption algorithm;
[0011] The cryptographic module decrypts the first encrypted data using the first key corresponding to the first key identifier to obtain the data.
[0012] In the above solution, obtaining the second spliced data based on the second encrypted data includes: combining the second encrypted data, a second key identifier and valid time information corresponding to the second key into the second spliced data.
[0013] In the above scheme, the electronic device includes a password module and an encryption and decryption module; the generating of the second key, encrypting the data with the second key to obtain the second encrypted data, and obtaining the second spliced data based on the second encrypted data, comprises: the password module of the electronic device generates the second key and the valid time information corresponding to the second key, and sends the second key identifier corresponding to the second key and the valid time information corresponding to the second key to the encryption and decryption module;
[0014] The encryption and decryption module sends the data and the second key identifier to the password module and calls the encryption algorithm;
[0015] The cryptographic module encrypts the data using the second key to obtain second encrypted data, and sends the second encrypted data and a second key identifier corresponding to the second key to the encryption and decryption module;
[0016] The encryption / decryption module combines the second encrypted data, the second key identifier, and the valid time information corresponding to the second key into the second spliced data.
[0017] In the above scheme, the obtaining of the first spliced data includes: encrypting the data with the first key to obtain the first encrypted data, and combining the first encrypted data, the first key identifier and the valid time information corresponding to the first key into the first spliced data.
[0018] In the above scheme, the electronic device includes a password module and an encryption and decryption module; the obtaining of the first spliced data includes: the password module of the electronic device generates the first key and the valid time information corresponding to the first key, and sends the first key identifier corresponding to the first key and the valid time information corresponding to the first key to the encryption and decryption module;
[0019] The encryption and decryption module sends the data and the first key identifier to the password module and calls an encryption algorithm;
[0020] The cryptographic module encrypts the data using the first key to obtain first encrypted data, and sends the first encrypted data and a first key identifier corresponding to the first key to the encryption and decryption module;
[0021] The encryption / decryption module combines the first encrypted data, the first key identifier, and the valid time information corresponding to the first key into the first spliced data.
[0022] The embodiment of the present invention further provides a data processing device, which is applied to an electronic device, and comprises: an encryption and decryption module, a password module and a judgment module; wherein:
[0023] The encryption and decryption module is used to obtain first spliced data, the first spliced data including first encrypted data, a first key identifier and valid time information of a first key corresponding to the first key identifier, the first encrypted data being obtained by encrypting data based on the first key corresponding to the first key identifier;
[0024] The judging module is configured to judge whether the first key has expired based on the validity time information corresponding to the first key;
[0025] The cryptographic module is used to decrypt the first encrypted data using the first key to obtain the data when the judgment module determines that the first key has expired; and is also used to generate a second key, and encrypt the data using the second key to obtain second encrypted data;
[0026] The encryption and decryption module is further used to obtain second spliced data based on the second encrypted data, where the second spliced data includes the second encrypted data, a second key identifier, and valid time information of a second key corresponding to the second key identifier.
[0027] In the above solution, the encryption and decryption module is used to send the first encrypted data and the first key identifier to the password module and call the decryption algorithm;
[0028] The cryptographic module is used to decrypt the first encrypted data using the first key corresponding to the first key identifier to obtain the data.
[0029] In the above solution, the cryptographic module is used to generate the second key and the valid time information corresponding to the second key, and send the second key identifier corresponding to the second key and the valid time information corresponding to the second key to the encryption and decryption module;
[0030] The encryption and decryption module is used to send the data and the second key identifier to the password module and call the encryption algorithm;
[0031] The cryptographic module is configured to encrypt the data using the second key to obtain second encrypted data, and send the second encrypted data and a second key identifier corresponding to the second key to the encryption / decryption module;
[0032] The encryption and decryption module is used to combine the second encrypted data, the second key identifier and the valid time information corresponding to the second key into the second spliced data.
[0033] In the above solution, the cryptographic module is used to generate the first key and the valid time information corresponding to the first key, and send the first key identifier corresponding to the first key and the valid time information corresponding to the first key to the encryption and decryption module;
[0034] The encryption and decryption module is used to send the data and the first key identifier to the password module and call the encryption algorithm;
[0035] The cryptographic module is configured to encrypt the data using the first key to obtain first encrypted data, and send the first encrypted data and a first key identifier corresponding to the first key to the encryption / decryption module;
[0036] The encryption and decryption module is used to combine the first encrypted data, the first key identifier and the valid time information corresponding to the first key into the first spliced data.
[0037] An embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data processing method described in the embodiment of the present invention when executing the program.
[0038] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the data processing method described in the embodiment of the present invention are implemented.
[0039] An embodiment of the present invention further provides a computer program product, including a computer program, and the computer program can be executed by a processor of a computer device to complete the steps of the data processing method described in the embodiment of the present invention.
[0040] The data processing method, device, electronic device and storage medium provided by the embodiments of the present invention can directly determine whether the key has expired based on the spliced data containing encrypted data, key identification and key validity time information, thereby realizing key rotation and avoiding the problem of reduced data security caused by data loss or leakage due to key expiration or failure to replace the key for a long time, so as to realize continuous protection of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 The data processing method of the present invention is shown in FIG. Figure 1 ;
[0042] Figure 2 The interactive process diagram of the data processing method according to the embodiment of the present invention is as follows: Figure 1 ;
[0043] Figure 3 The interactive process diagram of the data processing method according to the embodiment of the present invention is as follows: Figure 2 ;
[0044] Figure 4 The interactive process diagram of the data processing method according to the embodiment of the present invention is as follows: Figure 3 ;
[0045] Figure 5 The data processing method of the present invention is shown in FIG. Figure 2 ;
[0046] Figure 6 A schematic diagram of the structure of a data processing device according to an embodiment of the present invention;
[0047] Figure 7 The figure is a schematic diagram of the hardware structure of the electronic device according to the embodiment of the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0049] It should be understood that the terms "system" and "network" are often used interchangeably in this article. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0050] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable in appropriate circumstances, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, the process, method, system, product or equipment comprising a series of steps or units need not be limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0051] Before describing the data processing method of the embodiment of the present invention in detail, the key rotation process in the related art is briefly described. The related art process for implementing data encryption through key rotation is as follows:
[0052] When data needs to be encrypted and stored, a key is generated, the validity period or rotation period (such as half a year) of the key is set, and the current time of setting the key is recorded. The recorded current time and key-related information (such as the key ID) are written into the configuration file; the data is encrypted using the key using an encryption algorithm, and the encrypted ciphertext is stored in the database.
[0053] Relevant personnel read the information in the configuration file to determine that the key has expired and needs to be rotated.
[0054] The decryption algorithm is used to decrypt the ciphertext to obtain the plaintext of the data, generate a new key, set the effective time or rotation period (such as half a year) of the new key, and also record the current time of the new key, and write the recorded current time and related information of the new key (such as the key ID) into the configuration file to update the related information of the key in the configuration file; based on the encryption algorithm, the plaintext of the data is re-encrypted with the new key to obtain the re-encrypted ciphertext, and the encrypted ciphertext is stored in the database.
[0055] Over time, the above steps are repeated to achieve encrypted storage of data.
[0056] However, the relevant personnel only know whether the key has reached its validity period through the encrypted ciphertext; they need to read the configuration file to determine whether the key has expired. If the relevant personnel make mistakes in the configuration file, it is easy to cause the key to expire without key update or key rotation, so that the plaintext corresponding to the ciphertext cannot be obtained, and the key rotation will not be possible.
[0057] Based on this, an embodiment of the present invention provides a data processing method, which is applied to an electronic device. Figure 1 The data processing method of the present invention is shown in FIG. Figure 1 ;like Figure 1 As shown, the method includes:
[0058] Step 101: Obtain first spliced data, the first spliced data including first encrypted data, a first key identifier and valid time information of a first key corresponding to the first key identifier, the first encrypted data being obtained by encrypting data based on the first key corresponding to the first key identifier.
[0059] When storing encrypted data, the embodiment of the present invention splices or combines the encrypted data (referred to as the first encrypted data), the first key identifier corresponding to the key used for encryption (referred to as the first key), and the valid time information corresponding to the key, and stores them in the form of spliced data (referred to as the first spliced data), so that relevant personnel can know the valid time of the key (whether the key has expired) through the stored first spliced data, and thus can rotate the key.
[0060] The data processing methods of the embodiments of the present invention are applied to electronic devices, which can be any device with data processing and storage functions, including but not limited to computer devices (such as personal computers, servers, etc.), mobile terminals (such as mobile phones, tablets, wearable devices, etc.).
[0061] In some optional implementations, obtaining the first spliced data includes: encrypting the data using a first key to obtain the first encrypted data, and combining the first encrypted data, the first key identifier, and the valid time information corresponding to the first key into the first spliced data.
[0062] In this embodiment, the data obtained by the electronic device may be data that needs to be encrypted (also referred to as data that needs to be stored in ciphertext), or data that does not need to be encrypted (also referred to as data that does not need to be stored in ciphertext). If the data does not need to be stored in ciphertext, the above process does not need to be performed. That is, this embodiment is for data that needs to be stored in ciphertext. Specifically, a judgment module can be set in the electronic device to determine whether the obtained data is data that needs to be encrypted.
[0063] As an example, the data types that need to be encrypted can be pre-defined or configured in the electronic device (for example, sensitive data such as ID number, mobile phone number, bank card number, etc. can be set as the data type that needs to be encrypted. The type of data to be encrypted can be defined according to actual needs, and the present invention does not make specific limitations here). After identifying the data type corresponding to the acquired data, the judgment module in the electronic device determines whether the data type is the data type that needs to be encrypted.
[0064] For example, after the electronic device obtains the data, if the judgment module recognizes that the data type corresponding to the data is an identification number, then the data is determined to be data to be encrypted and needs to be further encrypted and stored in the form of spliced data; if the judgment module recognizes that the data type corresponding to the data is gender, then the data is determined to be unencrypted data and can be stored directly without encryption.
[0065] It should be noted that the character type of the data to be encrypted may be a numeric type or a character string type including punctuation marks, operation symbols, words, etc. The present invention does not impose any limitation on the character type of the data to be encrypted.
[0066] In this embodiment, after the electronic device determines that the data needs to be encrypted, it generates a first key and determines the valid time information of the first key; uses the first key to encrypt the data to obtain the first encrypted data, and combines the first encrypted data, the first key identifier corresponding to the first key, and the valid time information of the first key into the first spliced data.
[0067] In this embodiment, the first key identifier represents the identifier of the first key, which is obtained when the first key is generated, and each key has a unique key identifier corresponding to it. Specifically, the first key identifier can be represented by the ID of the first key.
[0068] In this embodiment, the effective time information of the first key represents the time information related to the effective time of the first key. The effective time of the first key represents the life cycle of the first key, which refers to the time span from the generation to the expiration of the first key, that is, the time within the life cycle of the first key is the effective time. If the life cycle of the first key is exceeded, it means that the first key is expired, and the security operation performed using the key will not be successful until a new key is replaced. In some optional embodiments, the effective time information of the first key can be the length of the effective time since the first key is set, for example, the effective time information of the first key is half a year; it should be noted that the effective time information of this embodiment needs to include the generation time of the first key and the length of time that the first key is continuously valid, and the two can be used in combination to determine the expiration time of the first key. In other optional embodiments, the effective time information of the first key can be the expiration time of the first key, for example, the effective time information of the first key is xx year xx month xx day x hour x minute, indicating that the above time is the expiration time of the first key, and the first key expires if the time is exceeded.
[0069] As an example, the validity period of the first key can be pre-set in months. For example, the validity period of the first key is pre-set to six months (half a year), that is, starting from the time when the first key is currently set, the validity period is half a year, and the first key will be replaced after half a year. For example, if the time of generating the first key is January 1, 2024, the first key will expire on July 1, 2024. It should be noted that different validity periods can be set for different keys, and the present invention does not specifically limit the setting of the granularity of the validity period of the key.
[0070] In this embodiment, the splicing method of the first spliced data can be key identifier (first key identifier)-key validity time information-encrypted data (first encrypted data). However, the embodiment of the present invention does not limit the splicing method of the spliced data, and other splicing methods are also within the protection scope of the embodiment of the present invention.
[0071] As an example, the first spliced data may be stored in the form of an array. For example, the first spliced data may be represented as:
[0072] #key-id#0001#date#20240101#cipher#E7E0E5F919CD46546FB9268FA3A5A6F1
[0073] Among them, key-id indicates that this part is the key identification part of the spliced data, and 0001 is the ID corresponding to the first key identification. data indicates that this part is the effective time information part of the key. If the effective time information of the key is the start time of setting the effective time of the first key, then 20240101 indicates that the start time of setting the effective time of the first key is January 1, 2024. It should be noted that this example is for the scenario where the effective time of the key is fixed for half a year, and the administrator knows by default that the effective time of the key is half a year. In other optional embodiments, 20240101 can also indicate that the expiration time of the first key is January 1, 2024. cipher indicates that this part is the encrypted data part. If the data to be encrypted is an ID number, then E7E0E5F919CD46546FB9268FA3A5A6F1 indicates the ciphertext value obtained after encrypting the ID number. Each piece of information can be separated by a special character (such as #), thereby splicing to form the first spliced data.
[0074] In some implementations, the electronic device includes a password module and an encryption / decryption module, and data encryption is implemented by the password module and the encryption / decryption module, and encrypted data is stored in the form of first spliced data.
[0075] Here, the password module and encryption / decryption module in the electronic device are both part of the data processing system of the present invention. The password module in the electronic device can be a bottom-level module in the data processing system, which is called by other modules to implement functions such as key generation and data encryption / decryption; the encryption / decryption module can be a high-level module in the data processing system, which completes data encryption / decryption by calling the bottom-level password module after receiving an encryption / decryption request, and obtains encrypted data and data corresponding to the key through interaction with the bottom-level module, thereby forming spliced data.
[0076] As an example, Figure 2 A schematic diagram of the interactive process of a data processing method according to an embodiment of the present invention is given. Figure 1 ;like Figure 2 As shown, the obtaining of the first splicing data includes:
[0077] Step 201: The cryptographic module generates a first key and valid time information corresponding to the first key.
[0078] In some implementations, after acquiring the data to be encrypted, the electronic device triggers the cryptographic module to generate a first key, obtains a first key identifier corresponding to the first key, and sets the validity time information corresponding to the first key.
[0079] Here, the first key is stored in a cryptographic module of the electronic device.
[0080] Step 202: The cryptographic module sends the first key identifier corresponding to the first key and the valid time information corresponding to the first key to the encryption and decryption module.
[0081] In this embodiment, the first key identifier corresponding to the first key sent by the password module to the encryption and decryption module is used by the encryption and decryption module to subsequently call the first key through the first key identifier to encrypt the data to be encrypted and subsequently decrypt the encrypted data.
[0082] Step 203: The encryption and decryption module sends the data and the first key identifier to the password module and calls the encryption algorithm.
[0083] In this embodiment, after receiving the first key identifier, the encryption / decryption module in the electronic device sends the first key identifier and the data to be encrypted to the password module to call the encryption algorithm of the password module.
[0084] In this embodiment, the encryption algorithm called can select the national secret standard SM4.0, or can use the advanced encryption standard. The appropriate encryption algorithm can be selected according to product requirements. The present invention does not impose specific restrictions on the selection of the encryption algorithm. It should be noted that the national secret standard SM4.0 (SM4) is a block cipher standard issued by the China National Cryptography Administration and is a block encryption algorithm; the Advanced Encryption Standard (AES) is a block encryption standard issued by the National Institute of Standards and Technology of the United States and is a commonly used encryption algorithm in symmetric key encryption.
[0085] As an example, if the SM4 algorithm is used to encrypt the data to be encrypted, the encryption algorithm interface of the SM4 algorithm in the cryptographic module can be called based on the data to be encrypted and the first key identifier. The pseudo code statement of the encryption algorithm interface of the SM4 algorithm is as follows: SM4_ENC (key1-id, sfzhm);
[0086] Among them, SM4_ENC is the encryption algorithm in the called SM algorithm, key1-id is the first key identifier corresponding to the first key entered in the encryption algorithm, and sfzhm is the data to be encrypted entered in the encryption algorithm. For example, if the data to be encrypted is an ID number, then sfzhm is the specific ID number.
[0087] Step 204: The cryptographic module encrypts the data using the first key to obtain first encrypted data.
[0088] In this embodiment, after receiving the data to be encrypted and the first key identifier sent by the encryption and decryption module, the cryptographic module calls the first key based on the first key identifier, encrypts the data to be encrypted through the encryption algorithm called by the encryption and decryption module, and obtains the first encrypted data of the data to be encrypted.
[0089] For example, if the data to be encrypted is the ID card number sfzhm, the pseudo code statement for obtaining the first encrypted data of the data to be encrypted through the encryption algorithm interface of the SM4 algorithm is as follows:
[0090] cip1_sfzhm=SM4_ENC(key1-id,sfzhm)
[0091] Among them, cip1_sfzhm is the first encrypted data output in the encryption algorithm, that is, the ciphertext value obtained after encrypting the ID card number. Apart from this, the rest of the information has been explained above and will not be repeated here.
[0092] Step 205: The cryptographic module sends the first encrypted data and the first key identifier corresponding to the first key to the encryption and decryption module.
[0093] In this embodiment, after the first encrypted data of the data to be encrypted is obtained through the password module, the password module sends the first encrypted data and the first key identifier to the encryption and decryption module. It should be noted that the first key identifier sent by the password module to the encryption and decryption module in the current step is used by the subsequent encryption and decryption module to call the decryption algorithm in the password module to decrypt the first encrypted data. The specific decryption process will be described below.
[0094] Step 206: The encryption / decryption module combines the first encrypted data, the first key identifier, and the valid time information corresponding to the first key into first concatenated data.
[0095] In this embodiment, after receiving the first encrypted data, the encryption / decryption module concatenates the first encrypted data, the first key identifier, and the valid time information corresponding to the first key received previously to form the first concatenated data.
[0096] At this point, the encryption of the data to be encrypted is completed through the password module and the encryption and decryption module, and the first spliced data is obtained.
[0097] In this embodiment, after obtaining the first splicing data, the electronic device stores the obtained first splicing data.
[0098] Step 102: Determine whether the first key has expired based on the validity time information corresponding to the first key.
[0099] In some embodiments, after the electronic device completes the storage of the first spliced data, it determines the validity time information of the first key in the first spliced data based on the current system time to determine whether the first key has expired. If it is determined that the first key has not expired, it continues to determine whether the first key has expired according to the set period; if it is determined that the first key has expired, it is necessary to rotate the key, that is, replace the first key. Among them, the set period is set according to the validity time information of the first key. If the validity time information of the first key is based on the granularity of the day, for example, the duration of the first key is x days, then the set period can be one day, for example, the first key is judged at xx hours and xx minutes every day whether it has expired. If the validity time information of the first key is based on the granularity of the month, for example, the duration of the first key is x months, then the set period can be one day, or it can be relatively long. The specific period can be set according to the actual situation, which will not be repeated here.
[0100] As an example, if the validity time information of the first key in the first splicing data is the start time of the validity time of the first key, then it is calculated whether the interval between the current system time and the start time of the validity time of the first key exceeds the preset validity period of the first key. If not, it indicates that the first key has not expired; if the interval is equal to the validity period of the first key, it indicates that the first key has expired.
[0101] For example, the preset validity period of the first key is half a year, and the value of the validity time information part of the first key in the first splicing data is #date#20240101, that is, the start time of the validity period of the first key is determined to be January 1, 2024. If the current system time for initiating the judgment is May 1, 2024, it can be calculated that the interval between the current system time and the start time for setting the validity period of the first key is four months, which does not exceed the preset validity period of the first key, indicating that the first key has not expired; if the current system time for initiating the judgment is July 1, 2024, it can be calculated that the interval between the current system time and the start time for setting the validity period of the first key is equal to the validity period of the first key, indicating that the first key has expired.
[0102] It should be noted that the key expiration can be determined regularly through a pre-set determination period, or the determination of the key expiration can be initiated irregularly by relevant personnel. The present invention does not specifically limit the determination of the key expiration.
[0103] Step 103: When it is determined that the first key has expired, the first encrypted data is decrypted using the first key to obtain the data.
[0104] Here, when it is determined that the first key has expired, key rotation needs to be performed to replace the first key with the second key. The first encrypted data can be decrypted using the first key to obtain the original data.
[0105] As an example, Figure 3 A schematic diagram of the interactive process of a data processing method according to an embodiment of the present invention is given. Figure 2 ;like Figure 3 As shown, decrypting the first encrypted data using the first key includes:
[0106] Step 301: The encryption / decryption module sends the first encrypted data and the first key identifier to the password module and calls the decryption algorithm.
[0107] In this embodiment, the encryption and decryption module in the electronic device sends the first key identifier and the first encrypted data to the password module, so as to call the decryption algorithm of the password module to decrypt the first encrypted data.
[0108] In this embodiment, the decryption algorithm called can select the SM4 algorithm as the encryption algorithm, or the AES algorithm, and the decryption algorithm corresponding to the appropriate encryption algorithm can be selected according to product requirements. The present invention does not impose specific restrictions on the selection of the decryption algorithm. It should be noted that the decryption algorithm and the encryption algorithm are the same algorithm.
[0109] As an example, if the SM4 algorithm is used to decrypt the first encrypted data, the decryption algorithm interface of the SM4 algorithm in the cryptographic module can be called based on the first encrypted data and the first key identifier. The pseudo code statement of the decryption algorithm interface of the SM4 algorithm is as follows: SM4_DEC (key1-id, cip_sfzhm);
[0110] Among them, SM4_DEC is the decryption algorithm in the called SM4 algorithm, key1-id is the first key identifier corresponding to the first key entered in the decryption algorithm, cip_sfzhm is the first encrypted data entered in the decryption algorithm. For example, if the encrypted ID number is decrypted, cip_sfzhm is the ciphertext value of the encrypted data obtained after encrypting the ID number.
[0111] Step 302: The cryptographic module decrypts the first encrypted data using the first key corresponding to the first key identifier to obtain data.
[0112] In this embodiment, after receiving the first encrypted data and the first key identifier sent by the encryption and decryption module, the password module decrypts the first encrypted data through the decryption algorithm called by the encryption and decryption module to obtain the data to be encrypted again.
[0113] For example, if the first encrypted data is cip_sfzhm after the ID card number is encrypted, the pseudo code statement for decrypting the first encrypted data through the decryption algorithm interface of the SM4 algorithm is as follows:
[0114] sfzhm=SM4_ENC(key1-id,cip_sfzhm)
[0115] Among them, sfzhm is the data after decrypting the first encrypted data output in the decryption algorithm, that is, the ID card number obtained by decrypting the ciphertext value corresponding to the encrypted ID card number. In addition, the rest of the information has been explained above and will not be repeated here.
[0116] In some implementations, after step 103, the data to be encrypted obtained after decryption is encrypted for the second time based on the second key to implement key rotation.
[0117] Step 104: Generate a second key, use the second key to encrypt the data to obtain second encrypted data, and obtain second spliced data based on the second encrypted data, wherein the second spliced data includes the second encrypted data, a second key identifier, and valid time information of the second key corresponding to the second key identifier.
[0118] Here, when it is confirmed that the first key has expired, the first key needs to be replaced with the second key. After the decrypted data is obtained again based on the first key, the second key is generated, and the data is encrypted using the generated second key to obtain second encrypted data, and the second spliced data is obtained based on the second encrypted data.
[0119] It should be noted that the present invention does not restrict the order of decrypting the first encrypted data using the first key in step 103 and generating the second key in step 104. That is, when it is determined that the first key has expired, the first encrypted data can be decrypted using the first key first, and then the second key can be generated; the second key can be generated first, and then the first encrypted data can be decrypted using the first key; or both can be performed simultaneously, that is, decrypting the first encrypted data using the first key and generating the second key can be performed simultaneously. This embodiment does not restrict the order of decrypting the first encrypted data using the first key and generating the second key.
[0120] In this embodiment, the second spliced data may be spliced data obtained by encrypting the data again, and the second spliced data may include the second encrypted data, the second key identifier, and the valid time information of the second key corresponding to the second key identifier.
[0121] The second key identifier represents the identifier of the second key, which is obtained when the second key is generated, and each key has a unique key identifier corresponding to it. Specifically, the second key identifier can be represented by the ID of the second key.
[0122] In this embodiment, the effective time information of the second key represents the time information related to the effective time of the second key. The effective time of the second key represents the life cycle of the second key, which refers to the time span from the generation to the expiration of the second key, that is, the time within the life cycle of the second key is the effective time. If the life cycle of the second key is exceeded, it means that the second key is expired, and the security operation performed using the key will not be successful until a new key is replaced. In some optional embodiments, the effective time information of the second key can be the length of the effective time since the second key is set, for example, the effective time information of the second key is half a year; it should be noted that the effective time information of this embodiment needs to include the generation time of the second key and the length of time that the second key is continuously valid, and the two can be used in combination to determine the expiration time of the second key. In other optional embodiments, the effective time information of the second key can be the expiration time of the second key. The setting of the effective time of the second key is similar to that of the first key, and will not be repeated here.
[0123] In some implementations, obtaining the second concatenated data based on the second encrypted data includes: combining the second encrypted data, the second key identifier, and the valid time information corresponding to the second key into the second concatenated data.
[0124] In this embodiment, the data obtained after decryption is encrypted using the second key corresponding to the second key identifier to obtain second encrypted data, and the second encrypted data, the second key identifier, and the valid time information corresponding to the second key identifier are spliced to obtain second spliced data. It should be noted that the present invention does not specifically limit the splicing method of the second spliced data.
[0125] As an example, the second spliced data may be stored in the form of an array. For example, the second spliced data may be represented as:
[0126] #key-id#0002#date#20240701#cipher#B172C699FBB359763E264F795FF8B25F
[0127] Among them, key-id indicates that this part is the key identification part of the spliced data, and 0002 is the ID corresponding to the second key identification. data indicates that this part is the effective time information part of the key. If the effective time information of the key is the start time of setting the effective time of the second key, then 20240701 indicates that the start time of setting the effective time of the second key is July 1, 2024. It should be noted that this example is for the scenario where the effective time of the key is fixed for half a year, and the administrator knows by default that the effective time of the key is half a year. In other optional embodiments, 20240701 can also indicate that the expiration time of the second key is July 1, 2024. cipher indicates that this part is the encrypted data part. If the data to be encrypted is the ID card number, then B172C699FBB359763E264F795FF8B25F indicates the ciphertext value obtained after encrypting the ID card number. Each information can be separated by a special character (such as #), thereby splicing to form the second spliced data.
[0128] In some implementations, the electronic device includes a password module and an encryption / decryption module, and the second spliced data is obtained through the password module and the encryption / decryption module of the electronic device.
[0129] Here, the explanation of the password module and the encryption / decryption module in the electronic device has been explained above and will not be repeated here.
[0130] As an example, Figure 4 A schematic diagram of the interactive process of a data processing method according to an embodiment of the present invention is given. Figure 3 ;like Figure 4 As shown, the generating of the second key, encrypting the data using the second key to obtain second encrypted data, and obtaining second spliced data based on the second encrypted data includes:
[0131] Step 401: The cryptographic module generates a second key and valid time information corresponding to the second key.
[0132] In some implementations, after the cryptographic module of the electronic device decrypts the first encrypted data to regain the data, the cryptographic module generates a second key, obtains a second key identifier corresponding to the second key, and sets valid time information corresponding to the second key.
[0133] Here, the second key is stored in a cryptographic module of the electronic device.
[0134] Step 402: The cryptographic module sends the second key identifier corresponding to the second key and the valid time information corresponding to the second key to the encryption / decryption module.
[0135] In this embodiment, the second key identifier corresponding to the second key sent by the password module to the encryption and decryption module is used by the encryption and decryption module to subsequently call the second key through the second key identifier to encrypt the data to be encrypted.
[0136] Step 403: The encryption and decryption module sends the data and the second key identifier to the password module and calls the encryption algorithm.
[0137] In this embodiment, after receiving the second key identifier, the encryption / decryption module in the electronic device sends the second key identifier and the data to be encrypted to the password module to call the encryption algorithm of the password module.
[0138] In this embodiment, the encryption algorithm called may be the SM4 algorithm or the AES algorithm, and a suitable encryption algorithm may be selected according to product requirements. The present invention does not impose any specific restrictions on the selection of the encryption algorithm.
[0139] As an example, if the SM4 algorithm is used to encrypt the data to be encrypted, the encryption algorithm interface of the SM4 algorithm in the cryptographic module can be called based on the data to be encrypted and the second key identifier. The pseudo code statement of the encryption algorithm interface of the SM4 algorithm is as follows:
[0140] SM4_ENC(key2-id,sfzhm)
[0141] Among them, SM4_ENC is the encryption algorithm in the called SM algorithm, key2-id is the second key identifier corresponding to the second key entered in the encryption algorithm, and sfzhm is the data to be encrypted entered in the encryption algorithm. For example, if the data to be encrypted is an ID number, then sfzhm is the specific ID number.
[0142] Step 404: The cryptographic module encrypts the data using the second key to obtain second encrypted data.
[0143] In this embodiment, after receiving the data to be encrypted and the second key identifier sent by the encryption and decryption module, the password module calls the second key based on the second key identifier, encrypts the data to be encrypted through the encryption algorithm called by the encryption and decryption module, and obtains the second encrypted data of the data to be encrypted.
[0144] For example, if the data to be encrypted is the ID card number sfzhm, the pseudo code statement for obtaining the second encrypted data of the data to be encrypted through the encryption algorithm interface of the SM4 algorithm is as follows:
[0145] cip2_sfzhm=SM4_ENC(key2-id,sfzhm)
[0146] Among them, key2-id is the second key identifier corresponding to the second key input in the encryption algorithm, cip2_sfzhm is the second encrypted data output in the encryption algorithm, that is, the ciphertext value obtained after encrypting the ID card number. In addition, the explanation of other information has been given in the pseudocode statement of the first encrypted data to be encrypted obtained through the encryption algorithm interface of the SM4 algorithm, and will not be repeated here.
[0147] Step 405: The cryptographic module sends the second encrypted data and the second key identifier corresponding to the second key to the encryption and decryption module.
[0148] In this embodiment, after the first encrypted data of the data to be encrypted is obtained by the password module, the second encrypted data and the second key identifier are sent to the encryption and decryption module by the password module. It should be noted that the second key identifier sent by the password module to the encryption and decryption module in the current step is used for the subsequent encryption and decryption module to call the decryption algorithm in the password module to decrypt the second encrypted data.
[0149] Step 406: The encryption / decryption module combines the second encrypted data, the second key identifier, and the valid time information corresponding to the second key into second concatenated data.
[0150] In this embodiment, after receiving the second encrypted data, the encryption / decryption module concatenates the second encrypted data, the second key identifier, and the valid time information corresponding to the second key received previously to form second concatenated data.
[0151] At this point, key rotation is completed through the password module and the encryption and decryption module to encrypt and store the encrypted data.
[0152] In this embodiment, after obtaining the second spliced data, the electronic device stores the obtained second spliced data.
[0153] The technical solution of the embodiment of the present invention is adopted. On the one hand, the first encrypted data is obtained by encrypting the encrypted data based on the generated first key to realize the encrypted storage of the encrypted data; on the other hand, in the process of encrypting and storing the data, the effective time information of the first key is combined with the encrypted data to form spliced data for storage, so as to determine whether the key has expired according to the spliced data. When it is determined that the first key has expired, the first encrypted data is decrypted, and the second spliced data is obtained by encrypting the encrypted data based on the second key generated to complete the key rotation, avoid the risks of data loss or leakage caused by key expiration or long-term non-replacement of the key, realize automatic secure storage of the encrypted data, and continuously provide protection for the encrypted data; on the other hand, the key is generated and stored in the cryptographic module at the bottom layer of the electronic device, and the encryption or decryption operation of the data is realized by the cryptographic module; the encryption and decryption module at the upper layer of the electronic device can only obtain the key identification, the effective time information of the key and the encrypted data, which further improves the security of the key storage and data encryption and decryption process.
[0154] As an example, Figure 5 A schematic diagram of a data processing method according to an embodiment of the present invention is given. Figure 2 .like Figure 5 As shown, the data processing method includes:
[0155] Receive data and confirm the data type, and determine whether the data needs to be encrypted and stored based on the data type.
[0156] After confirming that the data is data that needs to be encrypted and stored, a first key for encrypting the data for the first time is generated through the password module and the encryption and decryption module in the electronic device, and a first key identifier corresponding to the first key is obtained, and the valid time information of the first key is set. Then, the data is encrypted based on the first key to obtain first encrypted data, and the first spliced data is formed by splicing the first key identifier, the valid time information of the first key and the first encrypted data, and the obtained first spliced data is stored.
[0157] The judgment module of the electronic device determines whether the first key has expired through regular review based on the effective time information of the key. When it is determined that the first key has expired, the key rotation starts. The first encrypted data is first decrypted based on the first key to obtain the original data before encryption. Then, the password module and the encryption and decryption module in the electronic device generate a second key for encrypting the data for the second time, and at the same time obtain the second key identifier corresponding to the second key, and set the effective time information of the second key. Then, the data is encrypted based on the second key to obtain the second encrypted data. The second key identifier, the effective time information of the second key and the second encrypted data are spliced to form the second spliced data, and the obtained second spliced data is stored, thereby completing a key rotation.
[0158] The determination module of the electronic device continues to determine whether the second key has expired by means of periodic review, and starts the next key rotation after determining that the second key has expired, thereby achieving protection of the encrypted data.
[0159] Based on the above embodiments, an embodiment of the present invention further provides a data processing device, Figure 6 FIG. 1 is a schematic diagram of the structure of a data processing device according to an embodiment of the present invention; Figure 6 As shown, the device includes: an encryption and decryption module 51, a password module 52 and a judgment module 53; wherein,
[0160] The encryption and decryption module 51 is used to obtain first spliced data, wherein the first spliced data includes first encrypted data, a first key identifier, and valid time information of a first key corresponding to the first key identifier, and the first encrypted data is obtained by encrypting data based on the first key corresponding to the first key identifier;
[0161] The judging module 53 is configured to judge whether the first key has expired based on the validity time information corresponding to the first key;
[0162] The password module 52 is used to decrypt the first encrypted data using the first key to obtain the data when the judgment module 53 determines that the first key has expired; and is also used to generate a second key, and encrypt the data using the second key to obtain second encrypted data;
[0163] The encryption / decryption module 51 is further configured to obtain second spliced data based on the second encrypted data, where the second spliced data includes the second encrypted data, a second key identifier, and valid time information of a second key corresponding to the second key identifier.
[0164] In an optional embodiment of the present invention, the encryption and decryption module 51 is used to send the first encrypted data and the first key identifier to the password module 52 and call a decryption algorithm;
[0165] The cryptographic module 52 is configured to decrypt the first encrypted data using the first key corresponding to the first key identifier to obtain the data.
[0166] In an optional embodiment of the present invention, the cryptographic module 52 is used to generate the second key and the valid time information corresponding to the second key, and send the second key identifier corresponding to the second key and the valid time information corresponding to the second key to the encryption and decryption module 51;
[0167] The encryption and decryption module 51 is used to send the data and the second key identifier to the password module 52 and call the encryption algorithm;
[0168] The cryptographic module 52 is configured to encrypt the data using the second key to obtain second encrypted data, and send the second encrypted data and a second key identifier corresponding to the second key to the encryption / decryption module 51;
[0169] The encryption and decryption module 51 is used to combine the second encrypted data, the second key identifier and the valid time information corresponding to the second key into the second spliced data.
[0170] In an optional embodiment of the present invention, the password module 52 is used to generate the first key and the valid time information corresponding to the first key, and send the first key identifier corresponding to the first key and the valid time information corresponding to the first key to the encryption and decryption module 51;
[0171] The encryption and decryption module 51 is used to send the data and the first key identifier to the password module 52 and call the encryption algorithm;
[0172] The password module 52 is used to encrypt the data using the first key to obtain first encrypted data, and send the first encrypted data and a first key identifier corresponding to the first key to the encryption and decryption module 51;
[0173] The encryption and decryption module 51 is used to combine the first encrypted data, the first key identifier and the valid time information corresponding to the first key into the first spliced data.
[0174] In an optional embodiment of the present invention, the device further includes a storage module 54, which is used to store the first splicing data and / or the second splicing data.
[0175] In the embodiment of the present invention, the data processing device can be applied to electronic devices. The encryption and decryption module 51, the password module 52 and the judgment module 53 in the device can be implemented by a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU) or a field-programmable gate array (FPGA) in the electronic device in practical applications; the storage module 54 in the device can be implemented by a memory in the electronic device in practical applications.
[0176] It should be noted that: when the above-mentioned data processing device performs data processing, only the division of the above-mentioned program modules is used as an example for illustration. In actual applications, the above-mentioned processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the data processing device provided in the above-mentioned embodiment and the data processing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0177] An embodiment of the present invention further provides an electronic device, Figure 7 FIG. 1 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Figure 7 As shown, the electronic device 60 includes a memory 62, a processor 61, and a computer program stored in the memory 62 and executable on the processor 61. Optionally, when the processor 61 executes the program, the steps of the data processing method described in the embodiment of the present invention are implemented.
[0178] Optionally, the components in the electronic device 60 can be coupled together via a bus system 63. It can be understood that the bus system 63 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 53 also includes a power bus, a control bus and a status signal bus.
[0179] It is understandable that the memory 62 may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM); the magnetic surface memory may be a disk memory or a tape memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 62 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0180] The method disclosed in the above embodiment of the present invention can be applied to the processor 61, or implemented by the processor 61. The processor 61 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 61 or the instruction in the form of software. The above processor 61 can be a general processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 61 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be combined to execute. The software module can be located in a storage medium, which is located in the memory 62. The processor 61 reads the information in the memory 62 and completes the steps of the above method in combination with its hardware.
[0181] In an exemplary embodiment, the electronic device 60 may be implemented by one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general purpose processors, controllers, MCUs, microprocessors, or other electronic components to execute the aforementioned method.
[0182] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored.
[0183] Optionally, the computer-readable storage medium may be applied to the data processing device of the embodiment of the present invention; when the program is executed by the processor, the steps of the data processing method described in the embodiment of the present invention are implemented.
[0184] The embodiment of the present invention further provides a computer program product, including a computer program, and the computer program can be executed by the processor 61 of the electronic device 60 to complete the steps of the data processing method described in the embodiment of the present invention.
[0185] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0186] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0187] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0188] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0189] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0190] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0191] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.
[0192] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0193] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A data processing method, It is characterized in that The method is applied to an electronic device, and the method comprises: Obtaining first spliced data, the first spliced data including first encrypted data, a first key identifier, and valid time information of a first key corresponding to the first key identifier, the first encrypted data being obtained by encrypting data based on the first key corresponding to the first key identifier; Determining whether the first key has expired based on the validity time information corresponding to the first key; In the case where it is determined that the first key has expired, decrypting the first encrypted data using the first key to obtain the data; Generate a second key, use the second key to encrypt the data to obtain second encrypted data, and obtain second spliced data based on the second encrypted data, wherein the second spliced data includes the second encrypted data, a second key identifier, and valid time information of the second key corresponding to the second key identifier.
2. The method according to claim 1, It is characterized in that The electronic device includes a password module and an encryption / decryption module; the decrypting the first encrypted data using the first key to obtain the data includes: The encryption and decryption module of the electronic device sends the first encrypted data and the first key identifier to the password module and calls a decryption algorithm; The cryptographic module decrypts the first encrypted data using the first key corresponding to the first key identifier to obtain the data.
3. The method according to claim 1, It is characterized in that The obtaining the second spliced data based on the second encrypted data includes: The second encrypted data, the second key identifier, and the valid time information corresponding to the second key are combined into the second spliced data.
4. The method according to claim 1, It is characterized in that The electronic device includes a password module and an encryption and decryption module; the generating a second key, encrypting the data using the second key to obtain second encrypted data, and obtaining second spliced data based on the second encrypted data includes: The password module of the electronic device generates the second key and the valid time information corresponding to the second key, and sends the second key identifier corresponding to the second key and the valid time information corresponding to the second key to the encryption and decryption module; The encryption and decryption module sends the data and the second key identifier to the password module and calls the encryption algorithm; The cryptographic module encrypts the data using the second key to obtain second encrypted data, and sends the second encrypted data and a second key identifier corresponding to the second key to the encryption and decryption module; The encryption / decryption module combines the second encrypted data, the second key identifier, and the valid time information corresponding to the second key into the second spliced data.
5. The method according to claim 1, It is characterized in that The obtaining of the first splicing data comprises: The data is encrypted using the first key to obtain first encrypted data, and the first encrypted data, the first key identifier, and the valid time information corresponding to the first key are combined into the first spliced data.
6. The method according to claim 1, It is characterized in that The electronic device includes a password module and an encryption and decryption module; the obtaining of the first spliced data includes: The password module of the electronic device generates the first key and the valid time information corresponding to the first key, and sends the first key identifier corresponding to the first key and the valid time information corresponding to the first key to the encryption and decryption module; The encryption and decryption module sends the data and the first key identifier to the password module and calls an encryption algorithm; The cryptographic module encrypts the data using the first key to obtain first encrypted data, and sends the first encrypted data and a first key identifier corresponding to the first key to the encryption and decryption module; The encryption / decryption module combines the first encrypted data, the first key identifier, and the valid time information corresponding to the first key into the first spliced data.
7. A data processing device, It is characterized in that The device is applied to electronic equipment, and comprises: an encryption and decryption module, a password module and a judgment module; wherein: The encryption and decryption module is used to obtain first spliced data, the first spliced data including first encrypted data, a first key identifier and valid time information of a first key corresponding to the first key identifier, the first encrypted data being obtained by encrypting data based on the first key corresponding to the first key identifier; The judging module is configured to judge whether the first key has expired based on the validity time information corresponding to the first key; The cryptographic module is used to decrypt the first encrypted data using the first key to obtain the data when the judgment module determines that the first key has expired; and is also used to generate a second key, and encrypt the data using the second key to obtain second encrypted data; The encryption and decryption module is further used to obtain second spliced data based on the second encrypted data, where the second spliced data includes the second encrypted data, a second key identifier, and valid time information of a second key corresponding to the second key identifier.
8. The device according to claim 7, It is characterized in that The encryption and decryption module is used to send the first encrypted data and the first key identifier to the password module and call a decryption algorithm; The cryptographic module is used to decrypt the first encrypted data using the first key corresponding to the first key identifier to obtain the data.
9. The device according to claim 7, It is characterized in that The cryptographic module is configured to generate the second key and the valid time information corresponding to the second key, and send the second key identifier corresponding to the second key and the valid time information corresponding to the second key to the encryption and decryption module; The encryption and decryption module is used to send the data and the second key identifier to the password module and call the encryption algorithm; The cryptographic module is configured to encrypt the data using the second key to obtain second encrypted data, and send the second encrypted data and a second key identifier corresponding to the second key to the encryption / decryption module; The encryption and decryption module is used to combine the second encrypted data, the second key identifier and the valid time information corresponding to the second key into the second spliced data.
10. The method according to claim 7, It is characterized in that The cryptographic module is configured to generate the first key and the valid time information corresponding to the first key, and send the first key identifier corresponding to the first key and the valid time information corresponding to the first key to the encryption and decryption module; The encryption and decryption module is used to send the data and the first key identifier to the password module and call the encryption algorithm; The cryptographic module is configured to encrypt the data using the first key to obtain first encrypted data, and send the first encrypted data and a first key identifier corresponding to the first key to the encryption / decryption module; The encryption and decryption module is used to combine the first encrypted data, the first key identifier and the valid time information corresponding to the first key into the first spliced data.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the method according to any one of claims 1 to 6 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
13. A computer program product comprising a computer program, It is characterized in that The computer program implements the method according to any one of claims 1 to 6 when executed by a processor.
