A file storage method, device, equipment and medium

By using the China Secret algorithm to encrypt and process the stored files in file storage, generate file tags and bind them, and the encryption results are stored in a unified manner, solving the problem of inconsistent ciphertext format when storing files, reducing adaptation costs and increasing the File security meets the requirements of network security level protection and commercial password applications.

CN114328414BActive Publication Date: 2024-11-22CETC CYBERSPACE SECURITY TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202111679383.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2024-11-22
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

In the prior art, the ciphertext format lacks uniformity when storing files, resulting in an increase in file adaptation costs and the inability to effectively prevent the plaintext of the file from being stolen, affecting data security.

Method used

The National Secret algorithm is used to encrypt the plain text of stored files, generate file tags, bind the encryption results to the tags, and store them in a unified manner to ensure that the national Secret algorithm is used when storing files, and meet the requirements of network security level protection and commercial password applications.

Benefits of technology

Through a unified file storage format, the adaptation cost is reduced, the security of files is improved, and the plain text of files is prevented from being stolen, meeting the security evaluation requirements of network security level protection and commercial password applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114328414B_ABST
    Figure CN114328414B_ABST
Patent Text Reader

Abstract

The present disclosure proposes a file storage method, device, equipment, and medium, which includes: when obtaining the plaintext of the file to be stored, creating a file label for the plaintext of the file to be stored, and obtaining the security attribute information of the plaintext of the file to be stored; using the encryption algorithm information to process the plaintext of the file to be stored to obtain the encryption result; using the hash value of the file storage protection function identifier and the encryption algorithm information as the label verification code corresponding to the plaintext of the file to be stored, and writing the file storage protection function identifier, the encryption algorithm information, and the label verification code into the file label according to a preset format; binding the file label with the file ciphertext of the plaintext of the file to be stored in the encryption result to obtain the processed file to be stored, and storing the processed file to be stored. In this way, the security of the file can be improved, and the use of a unified file storage format reduces the cost of file adaptation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data security technology, and in particular to a file storage method, device, equipment, and medium. Background Art

[0002] With the rapid development of information technology, the country has issued a number of standard information to ensure data security, such as GB_T39786-2021 "Information Security Technology Information System Cryptography Application Basic Requirements", GM_T0054-2018 "Information System Cryptography Basic Requirements", GB_T25070-2019 "Information Security Technology Network Security Level Protection Security Design Technical Requirements", GM_T0055-2018 "Electronic File Cryptography Application Technical Specifications", GM_T0071-2019 "Electronic File Cryptography Application Guide" and other related specifications. Data security has received widespread attention from the society.

[0003] Therefore, how to ensure data security becomes an important issue that technicians in this field need to solve. Summary of the invention

[0004] In view of this, the purpose of the present disclosure is to provide a file storage method, device, equipment, and medium, which can improve the security of files and use a unified file storage format to reduce the file adaptation cost. The specific scheme is as follows:

[0005] In a first aspect, the present disclosure proposes a file storage method, comprising:

[0006] When obtaining the plaintext of the file to be stored, creating a file tag for the plaintext of the file to be stored, and obtaining security attribute information of the plaintext of the file to be stored, wherein the security attribute information includes a file storage protection function identifier and encryption algorithm information required for an encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm;

[0007] Using the encryption algorithm information to process the plaintext of the file to be stored to obtain an encryption result;

[0008] Using the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and writing the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format;

[0009] The file tag is bound to the file ciphertext of the plaintext file to be stored in the encryption result to obtain a processed file to be stored, and the processed file to be stored is stored.

[0010] Optionally, the using the encryption algorithm information to process the plaintext of the file to be stored to obtain an encryption result includes:

[0011] Generate a first key using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and use the first key to process the plaintext of the file to be stored to obtain a first encryption result, wherein the first encryption result includes the ciphertext of the file;

[0012] Generate a second key using a second encryption algorithm corresponding to a second encryption algorithm identifier in the encryption algorithm information, and encrypt the first key using the second key to obtain a key ciphertext, so as to use the key ciphertext as a second encryption result;

[0013] The second key is stored in a corresponding key storage address, and the first encryption result and the second encryption result are used as the encryption result.

[0014] Optionally, the generating a first key using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and processing the plaintext of the file to be stored using the first key to obtain a first encryption result includes:

[0015] Generate a file key using a file encryption algorithm corresponding to a file encryption algorithm identifier in a first encryption algorithm identifier in the encryption algorithm information, wherein the file encryption algorithm is used to encrypt the plaintext of the file to be stored, and the file encryption algorithm is a national secret algorithm;

[0016] Generate a MAC key using the MAC algorithm corresponding to the MAC algorithm identifier in the first encryption algorithm identifier in the encryption algorithm information, wherein the MAC algorithm is obtained based on the national encryption algorithm;

[0017] Encrypting the plaintext of the file to be stored using the file key to obtain the corresponding file ciphertext;

[0018] The file ciphertext is processed using the MAC key to obtain a file verification code, and the file ciphertext and the file verification code are used as the first encryption result.

[0019] Optionally, the using the file storage protection function identifier and the hash value of the encryption algorithm information as a tag verification code corresponding to the plaintext of the file to be stored includes:

[0020] Using the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code and the hash value of the key storage address as the label verification code corresponding to the plaintext of the file to be stored;

[0021] Accordingly, the step of writing the file storage protection function identifier, the encryption algorithm information and the tag verification code into the file tag according to a preset format includes:

[0022] The file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code, the key storage address and the label verification code are written into the file label according to a preset format.

[0023] Optionally, the file storage method further includes:

[0024] When a file parsing instruction corresponding to the processed file to be stored is obtained, the tag verification code is verified;

[0025] When the tag verification code is verified, the file verification code is verified;

[0026] When the file verification code is verified, the file ciphertext is decrypted using the file key to obtain the plaintext of the file to be stored.

[0027] Optionally, the generating the second key by using the second encryption algorithm corresponding to the second encryption algorithm identifier in the encryption algorithm information includes:

[0028] Generate a file key encryption key in the second key by using a file key encryption algorithm corresponding to a file key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information;

[0029] The MAC key encryption key in the second key is generated by using the MAC key encryption algorithm corresponding to the MAC key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information.

[0030] Optionally, the using the second key to encrypt the first key to obtain a key ciphertext includes:

[0031] Encrypting the file key using the file key encryption key to obtain a file key ciphertext;

[0032] The MAC key is encrypted using the MAC key encryption key to obtain a MAC key ciphertext.

[0033] In a second aspect, the present disclosure provides a file storage device, comprising:

[0034] A file label creation module, used for creating a file label for the plaintext of the file to be stored when obtaining the plaintext of the file to be stored, and obtaining security attribute information of the plaintext of the file to be stored, wherein the security attribute information includes a file storage protection function identifier and encryption algorithm information required for an encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm;

[0035] An encryption processing module, used to process the plain text of the file to be stored using the encryption algorithm information to obtain an encryption result;

[0036] A file label filling module, used to use the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format;

[0037] The storage module is used to bind the file tag with the file ciphertext of the plaintext file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored.

[0038] In a third aspect, the present disclosure provides an electronic device, including:

[0039] Memory and processor;

[0040] Wherein, the memory is used to store computer programs;

[0041] The processor is used to execute the computer program to implement the aforementioned disclosed file storage method.

[0042] In a fourth aspect, the present disclosure proposes a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned disclosed file storage method when executed by a processor.

[0043] It can be seen that when the present disclosure obtains the plaintext of the file to be stored, a file tag is created for the plaintext of the file to be stored, and the security attribute information of the plaintext of the file to be stored is obtained, wherein the security attribute information includes the file storage protection function identifier and the encryption algorithm information required for the encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm. Then the plaintext of the file to be stored is processed using the encryption algorithm information to obtain an encryption result, and then the hash value of the file storage protection function identifier and the encryption algorithm information is used as the tag verification code corresponding to the plaintext of the file to be stored, and the file storage protection function identifier, the encryption algorithm information and the tag verification code are written into the file tag according to a preset format. The file tag is bound to the file ciphertext of the plaintext of the file to be stored in the encryption result to obtain the processed file to be stored, and the processed file to be stored is stored. It can be seen that in the present disclosure, in the process of storing the plain text of the file to be stored, the encryption algorithm used is the national secret algorithm and / or the encryption algorithm obtained based on the national secret algorithm, which meets the relevant requirements of network security level protection and commercial cryptographic application and security assessment. After obtaining the encryption result, it is necessary to use the hash value of the file storage protection function identifier and the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label, and then bind the file label with the file ciphertext of the plain text of the file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored, so that the plain text of the file to be stored will be processed into the processed file to be stored in a unified format before being stored. Compared with the problem of increased intercommunication cost caused by the lack of effective unification of the ciphertext file format in the prior art, the file adaptation cost is reduced, and before the plain text of the file to be stored is stored, it is necessary to use the encryption algorithm to process it first to obtain the file ciphertext, which can effectively prevent the loss caused by the theft of the plain text of the file to be stored and improve the security of the file. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present disclosure 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 disclosure. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0045] Figure 1 A flow chart of a file storage method proposed in the present disclosure;

[0046] Figure 2 A flowchart of a specific file storage method proposed in the present disclosure;

[0047] Figure 3 A flowchart of a specific file storage method proposed in the present disclosure;

[0048] Figure 4 A schematic diagram of the structure of a file storage device proposed in the present disclosure;

[0049] Figure 5 The present invention is a schematic diagram of the structure of an electronic device. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.

[0051] See also Figure 1 As shown, the embodiment of the present disclosure proposes a file storage method, which includes:

[0052] Step S11: When the plaintext of the file to be stored is obtained, a file tag is created for the plaintext of the file to be stored, and security attribute information of the plaintext of the file to be stored is obtained, wherein the security attribute information includes a file storage protection function identifier and encryption algorithm information required for an encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm.

[0053] In actual applications, when the plaintext of the file to be stored is obtained, in order to ensure the security of the file to be stored, the plaintext of the file to be stored is usually encrypted and converted into the corresponding file ciphertext before being stored. In the process of encrypting the plaintext of the file to be stored, different encryption processes can be used. The specific encryption processes can be configured by the user. Different encryption processes correspond to different file storage protection function identifiers, that is, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored. For example, some file storage protection function identifiers indicate that the plaintext of the file to be stored is encrypted, and the digest of the plaintext of the file to be stored is calculated, and the digest result is encrypted. Some file storage protection function identifiers indicate that only the plaintext of the file to be stored is encrypted.

[0054] That is, when the plain text of the file to be stored is obtained, it is necessary to create a file tag for the plain text of the file to be stored, and obtain the security attribute information of the plain text of the file to be stored, wherein the security attribute information includes the file storage protection function identifier and the encryption algorithm information required for the encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plain text of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm. When the file storage protection function identifier is obtained, it is determined which encryption-related processing operations need to be performed on the plain text of the file to be stored, and accordingly, it is determined which encryption algorithm information needs to be input for performing encryption-related processing operations in the corresponding encryption processing steps. For example, the encryption algorithm information includes the file encryption algorithm identifier for encrypting the plain text of the file to be stored, the first algorithm mode corresponding to the file encryption algorithm identifier, and the first initialization vector corresponding to the file encryption algorithm identifier, and also includes a MAC (Message Authentication Code) algorithm identifier, a second algorithm mode corresponding to the MAC algorithm identifier, and a second initialization vector corresponding to the MAC algorithm identifier, etc. The national secret algorithms include SM2, SM3, SM4 algorithms, etc.

[0055] Step S12: using the encryption algorithm information to process the plaintext of the file to be stored to obtain an encryption result.

[0056] After obtaining the security attribute information, it is also necessary to use the encryption algorithm information in the security attribute information to process the plaintext of the file to be stored to obtain an encryption result. Specifically, the plaintext of the file to be stored is processed using the encryption algorithm information according to the encryption process corresponding to the file storage protection function identifier to obtain an encryption result.

[0057] Step S13: Using the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plaintext of the file to be stored, and writing the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format.

[0058] After obtaining the encryption result, it is also necessary to use the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to the preset format. The specific format of the file label can be seen in Table 1 below:

[0059] Table 1

[0060] File storage protection function identifier Encryption algorithm information Label verification code

[0061] Step S14: Binding the file tag with the file ciphertext of the plaintext file to be stored in the encryption result to obtain the processed file to be stored, and storing the processed file to be stored.

[0062] It is also necessary to bind the file tag with the file ciphertext of the plaintext file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored. The specific format of the processed file to be stored is shown in Table 2 below:

[0063] Table 2

[0064] File storage protection function identifier Encryption algorithm information Label verification code File ciphertext

[0065] It can be seen that when the present disclosure obtains the plaintext of the file to be stored, a file tag is created for the plaintext of the file to be stored, and the security attribute information of the plaintext of the file to be stored is obtained, wherein the security attribute information includes the file storage protection function identifier and the encryption algorithm information required for the encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm. Then the plaintext of the file to be stored is processed using the encryption algorithm information to obtain an encryption result, and then the hash value of the file storage protection function identifier and the encryption algorithm information is used as the tag verification code corresponding to the plaintext of the file to be stored, and the file storage protection function identifier, the encryption algorithm information and the tag verification code are written into the file tag according to a preset format. The file tag is bound to the file ciphertext of the plaintext of the file to be stored in the encryption result to obtain the processed file to be stored, and the processed file to be stored is stored. It can be seen that in the present disclosure, in the process of storing the plain text of the file to be stored, the encryption algorithm used is the national secret algorithm and / or the encryption algorithm obtained based on the national secret algorithm, which meets the relevant requirements of network security level protection and commercial cryptographic application and security assessment. After obtaining the encryption result, it is necessary to use the hash value of the file storage protection function identifier and the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label, and then bind the file label with the file ciphertext of the plain text of the file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored, so that the plain text of the file to be stored will be processed into the processed file to be stored in a unified format before being stored. Compared with the problem of increased intercommunication cost caused by the lack of effective unification of the ciphertext file format in the prior art, the file adaptation cost is reduced, and before the plain text of the file to be stored is stored, it is necessary to use the encryption algorithm to process it first to obtain the file ciphertext, which can effectively prevent the loss caused by the theft of the plain text of the file to be stored and improve the security of the file.

[0066] See also Figure 2 As shown, the plain text of the file to be stored is processed using the encryption algorithm information to obtain an encryption result, including:

[0067] Step S21: Generate a first key using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and use the first key to process the plaintext of the file to be stored to obtain a first encryption result, wherein the first encryption result includes the file ciphertext.

[0068] In a specific implementation process, the encryption process of the plaintext of the file to be stored represented by the file storage protection function identifier includes encrypting the plaintext of the file to be stored, calculating a file verification code for the file ciphertext corresponding to the plaintext of the file to be stored, encrypting the file key used to encrypt the plaintext of the file to be stored, and encrypting the MAC key used to encrypt the file verification code.

[0069] Accordingly, it is necessary to first generate a first key using the first encryption algorithm corresponding to the first encryption algorithm identifier in the encryption algorithm information, and use the first key to process the plaintext of the file to be stored to obtain a first encryption result, wherein the first encryption result includes the file ciphertext. The first encryption algorithm identifier includes a file encryption algorithm identifier and a MAC algorithm identifier.

[0070] Specifically, a first key is generated by using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and the first key is used to process the plaintext of the file to be stored to obtain a first encryption result, including: generating a file key by using a file encryption algorithm corresponding to a file encryption algorithm identifier in the first encryption algorithm identifier in the encryption algorithm information, wherein the file encryption algorithm is used to encrypt the plaintext of the file to be stored, and the file encryption algorithm is a national secret algorithm; generating a MAC key by using a MAC algorithm corresponding to a MAC algorithm identifier in the first encryption algorithm identifier in the encryption algorithm information, wherein the MAC algorithm is obtained based on the national secret algorithm; encrypting the plaintext of the file to be stored by using the file key to obtain a corresponding file ciphertext; processing the file ciphertext by using the MAC key to obtain a file verification code, and using the file ciphertext and the file verification code as the first encryption result.

[0071] Step S22: Generate a second key using the second encryption algorithm corresponding to the second encryption algorithm identifier in the encryption algorithm information, and encrypt the first key using the second key to obtain a key ciphertext, so as to use the key ciphertext as the second encryption result.

[0072] It is also necessary to generate a second key using a second encryption algorithm corresponding to a second encryption algorithm identifier in the encryption algorithm, and to encrypt the first key using the second key to obtain a key ciphertext, so as to use the key ciphertext as a second encryption result. The second encryption algorithm identifier includes a file key encryption algorithm identifier and a MAC key encryption algorithm identifier, the MAC key encryption algorithm identifier is an identifier of a MAC key encryption algorithm used to encrypt the MAC key, and the file key encryption algorithm identifier is an identifier of a file key encryption algorithm used to encrypt the file key.

[0073] Specifically, the second key is generated using the second encryption algorithm corresponding to the second encryption algorithm identifier in the encryption algorithm information, including: using the file key encryption algorithm corresponding to the file key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information to generate the file key encryption key in the second key; using the MAC key encryption algorithm corresponding to the MAC key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information to generate the MAC key encryption key in the second key.

[0074] Specifically, using the second key to encrypt the first key to obtain a key ciphertext includes: using the file key encryption key to encrypt the file key to obtain a file key ciphertext; using the MAC key encryption key to encrypt the MAC key to obtain a MAC key ciphertext.

[0075] Step S23: Store the second key in a corresponding key storage address, and use the first encryption result and the second encryption result as the encryption result.

[0076] It is also necessary to store the second key in the corresponding key storage address, and use the first encryption result and the second encryption result as the encryption result.

[0077] Correspondingly, the file storage protection function identifier and the hash value of the encryption algorithm information are used as the label verification code corresponding to the plaintext of the file to be stored, including: using the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code and the hash value of the key storage address as the label verification code corresponding to the plaintext of the file to be stored.

[0078] Correspondingly, writing the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format includes: writing the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code, the key storage address and the label verification code into the file label according to a preset format.

[0079] In actual application, it also includes: when the file parsing instruction corresponding to the processed file to be stored is obtained, the label verification code is verified; when the label verification code is verified, the file verification code is verified; when the file verification code is verified, the file ciphertext is decrypted using the file key to obtain the plaintext of the file to be stored.

[0080] That is, when it is necessary to parse the processed file to be stored, it is necessary to first verify the tag verification code, that is, to calculate the hash value of the information in the file tag except the tag verification code, and compare the calculation result with the tag verification code to see whether they are consistent. If they are consistent, the verification is passed, and the file verification code is verified. Specifically, the MAC key encryption key is obtained from the key storage address, and then the MAC key encryption key is used to decrypt the MAC key ciphertext to obtain the MAC key, and then the MAC key is used to process the file ciphertext to obtain the file verification code to be verified, and the file verification code to be verified is compared with the file verification code in the file tag. If they are inconsistent, the file verification code verification fails, and the file ciphertext has been tampered with. Since the file verification code is obtained by processing the file ciphertext using the MAC key, when the file verification code verification fails, it means that the file ciphertext is different from the original file ciphertext and has been tampered with, so there is no need to encrypt the file ciphertext, saving the calculation amount of file ciphertext decryption. If they are consistent, the file verification code is verified to be passed, the file ciphertext has not been tampered with, and the file ciphertext can be decrypted to obtain the plaintext of the file to be stored, that is, the file key encryption key is obtained from the key storage address, and then the file key encryption key is used to decrypt the file key ciphertext in the file tag to obtain the file key, and the file key is used to decrypt the file ciphertext to obtain the plaintext of the file to be stored.

[0081] See also Figure 3The figure shows the file storage flow chart. The application submits the file to be encrypted (that is, the aforementioned plaintext file to be stored) to the middleware, and the middleware starts to create a file tag, set the security attribute information of the file, generate a file key, a corresponding initialization vector (IV), a MAC key and a corresponding initialization vector, encrypt the file using the file encryption key and the corresponding initialization vector, and encrypt the file key, calculate the file verification code using the MAC key and the corresponding initialization vector, encrypt the MAC key, calculate the tag verification code, and store the file storage protection function identifier, the file verification code, the file encryption algorithm identifier, the algorithm mode corresponding to the file encryption algorithm identifier, the initialization vector corresponding to the file encryption algorithm identifier, the file key ciphertext, the MAC algorithm identifier, the algorithm mode corresponding to the MAC algorithm identifier, the initialization vector corresponding to the MAC algorithm identifier, the MAC key ciphertext, the key protection key algorithm identifier, the key storage address and the tag verification code in the file tag, wherein the key protection key algorithm identifier includes the file key encryption algorithm identifier and the MAC key encryption algorithm identifier, and the tag verification code is a hash value of other information in the file tag except the tag verification code, wherein the file tag can be specifically shown in Table 3 below, wherein @SFL and the version number represent the file storage protection function identifier. The file tag and the file are bound and the ciphertext of the file is stored in a preset format.

[0082] Table 3

[0083]

[0084] Among them, the parts from the file verification code to the tag verification code can be collectively referred to as security attributes, and the format of the file to be stored after processing is shown in Table 4 below:

[0085] Table 4

[0086] @SFL Version Number Security attributes File ciphertext

[0087] When you need to open a file stored according to the above process, submit the file ciphertext to the middleware, and the middleware starts to parse the file tag and verify the integrity of the file tag, that is, verify the tag verification code. After the tag verification code is verified, the file integrity is verified, that is, verify the file verification code. After the file verification code is verified, the file is decrypted to obtain the file plaintext, and then the file plaintext is returned to the application.

[0088] See also Figure 4 As shown, the present disclosure embodiment provides a file storage device, including:

[0089] A file label creation module 11 is used to create a file label for the plaintext of the file to be stored when the plaintext of the file to be stored is obtained, and obtain security attribute information of the plaintext of the file to be stored, wherein the security attribute information includes a file storage protection function identifier and encryption algorithm information required for an encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm;

[0090] The encryption processing module 12 is used to process the plain text of the file to be stored using the encryption algorithm information to obtain an encryption result;

[0091] A file label filling module 13 is used to use the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format;

[0092] The storage module 14 is used to bind the file tag with the file ciphertext of the plaintext file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored.

[0093] It can be seen that when the present disclosure obtains the plaintext of the file to be stored, a file tag is created for the plaintext of the file to be stored, and the security attribute information of the plaintext of the file to be stored is obtained, wherein the security attribute information includes the file storage protection function identifier and the encryption algorithm information required for the encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm. Then the plaintext of the file to be stored is processed using the encryption algorithm information to obtain an encryption result, and then the hash value of the file storage protection function identifier and the encryption algorithm information is used as the tag verification code corresponding to the plaintext of the file to be stored, and the file storage protection function identifier, the encryption algorithm information and the tag verification code are written into the file tag according to a preset format. The file tag is bound to the file ciphertext of the plaintext of the file to be stored in the encryption result to obtain the processed file to be stored, and the processed file to be stored is stored. It can be seen that in the present disclosure, in the process of storing the plain text of the file to be stored, the encryption algorithm used is the national secret algorithm and / or the encryption algorithm obtained based on the national secret algorithm, which meets the relevant requirements of network security level protection and commercial cryptographic application and security assessment. After obtaining the encryption result, it is necessary to use the hash value of the file storage protection function identifier and the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label, and then bind the file label with the file ciphertext of the plain text of the file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored, so that the plain text of the file to be stored will be processed into the processed file to be stored in a unified format before being stored. Compared with the problem of increased intercommunication cost caused by the lack of effective unification of the ciphertext file format in the prior art, the file adaptation cost is reduced, and before the plain text of the file to be stored is stored, it is necessary to use the encryption algorithm to process it first to obtain the file ciphertext, which can effectively prevent the loss caused by the theft of the plain text of the file to be stored and improve the security of the file.

[0094] In some specific implementations, the encryption processing module 12 is used to:

[0095] Generate a first key using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and use the first key to process the plaintext of the file to be stored to obtain a first encryption result, wherein the first encryption result includes the ciphertext of the file;

[0096] Generate a second key using a second encryption algorithm corresponding to a second encryption algorithm identifier in the encryption algorithm information, and encrypt the first key using the second key to obtain a key ciphertext, so as to use the key ciphertext as a second encryption result;

[0097] The second key is stored in a corresponding key storage address, and the first encryption result and the second encryption result are used as the encryption result.

[0098] In some specific implementations, the encryption processing module 12 is used to:

[0099] Generate a file key using a file encryption algorithm corresponding to a file encryption algorithm identifier in a first encryption algorithm identifier in the encryption algorithm information, wherein the file encryption algorithm is used to encrypt the plaintext of the file to be stored, and the file encryption algorithm is a national secret algorithm;

[0100] Generate a MAC key using the MAC algorithm corresponding to the MAC algorithm identifier in the first encryption algorithm identifier in the encryption algorithm information, wherein the MAC algorithm is obtained based on the national encryption algorithm;

[0101] Encrypting the plaintext of the file to be stored using the file key to obtain the corresponding file ciphertext;

[0102] The file ciphertext is processed using the MAC key to obtain a file verification code, and the file ciphertext and the file verification code are used as the first encryption result.

[0103] In some specific implementations, the file tag filling module 13 is used to:

[0104] Using the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code and the hash value of the key storage address as the label verification code corresponding to the plaintext of the file to be stored;

[0105] The file label filling module 13 is used to write the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code, the key storage address and the label verification code into the file label according to a preset format.

[0106] In some specific implementations, the file storage device further includes:

[0107] The file parsing module is used to verify the label verification code when obtaining the file parsing instruction corresponding to the processed file to be stored; when the label verification code is verified, verify the file verification code; when the file verification code is verified, use the file key to decrypt the file ciphertext to obtain the plaintext of the file to be stored.

[0108] In some specific implementations, the encryption processing module 12 is used to:

[0109] Generate a file key encryption key in the second key by using a file key encryption algorithm corresponding to a file key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information;

[0110] The MAC key encryption key in the second key is generated by using the MAC key encryption algorithm corresponding to the MAC key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information.

[0111] In some specific implementations, the encryption processing module 12 is used to:

[0112] Encrypting the file key using the file key encryption key to obtain a file key ciphertext;

[0113] The MAC key is encrypted using the MAC key encryption key to obtain a MAC key ciphertext.

[0114] Figure 5 2 is a block diagram of an electronic device 20 according to an exemplary embodiment. The electronic device 20 includes a processor 21 and a memory 22. The electronic device 20 may also include one or more of a multimedia component 23, an input / output (I / O) interface 24, and a communication component 25.

[0115] The processor 21 is used to control the overall operation of the electronic device 20 to complete all or part of the steps in the above-mentioned file storage. The memory 22 is used to store various types of data to support the operation of the electronic device 20, and these data may include, for example, instructions for any application or method used to operate on the electronic device 20, and application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The memory 22 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 23 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 22 or sent via the communication component 25. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 24 provides an interface between the processor 21 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 25 is used for wired or wireless communication between the electronic device 20 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more thereof, so the corresponding communication component 25 may include: Wi-Fi module, Bluetooth module, NFC module.

[0116] In an exemplary embodiment, the electronic device 20 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned file storage method.

[0117] Furthermore, an embodiment of the present disclosure also proposes a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the file storage method disclosed in any of the aforementioned embodiments.

[0118] Among them, the specific process of the above-mentioned file storage method can refer to the corresponding content disclosed in the above-mentioned embodiment, and will not be repeated here.

[0119] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0120] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0121] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

[0122] Finally, it should be noted that, in this article, relational terms such as first and second 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 series of processes, methods, articles or equipment containing other elements include not only those elements, but also other elements not explicitly listed, or also include elements inherent to such processes, methods, articles or equipment. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or equipment that includes the elements.

Claims

1. A file storage method, It is characterized in that include: When obtaining the plaintext of the file to be stored, creating a file tag for the plaintext of the file to be stored, and obtaining security attribute information of the plaintext of the file to be stored, wherein the security attribute information includes a file storage protection function identifier and encryption algorithm information required for an encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm; Using the encryption algorithm information to process the plaintext of the file to be stored to obtain an encryption result; Using the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and writing the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format; Binding the file tag with the file ciphertext of the plaintext file to be stored in the encryption result to obtain a processed file to be stored, and storing the processed file to be stored; The step of using the file storage protection function identifier and the hash value of the encryption algorithm information as the tag verification code corresponding to the plaintext of the file to be stored includes: The file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code and the hash value of the key storage address are used as the label verification code corresponding to the plaintext of the file to be stored; Accordingly, writing the file storage protection function identifier, the encryption algorithm information and the tag verification code into the file tag according to a preset format includes: The file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code, the key storage address and the label verification code are written into the file label according to a preset format.

2. The file storage method according to claim 1, It is characterized in that The using the encryption algorithm information to process the plaintext of the file to be stored to obtain an encryption result includes: Generate a first key using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and use the first key to process the plaintext of the file to be stored to obtain a first encryption result, wherein the first encryption result includes the ciphertext of the file; Generate a second key using a second encryption algorithm corresponding to a second encryption algorithm identifier in the encryption algorithm information, and encrypt the first key using the second key to obtain a key ciphertext, so as to use the key ciphertext as a second encryption result; The second key is stored in a corresponding key storage address, and the first encryption result and the second encryption result are used as the encryption result.

3. The file storage method according to claim 2, It is characterized in that The step of generating a first key by using a first encryption algorithm corresponding to a first encryption algorithm identifier in the encryption algorithm information, and processing the plaintext of the file to be stored by using the first key to obtain a first encryption result includes: Generate a file key using a file encryption algorithm corresponding to a file encryption algorithm identifier in a first encryption algorithm identifier in the encryption algorithm information, wherein the file encryption algorithm is used to encrypt the plaintext of the file to be stored, and the file encryption algorithm is a national secret algorithm; Generate a MAC key using the MAC algorithm corresponding to the MAC algorithm identifier in the first encryption algorithm identifier in the encryption algorithm information, wherein the MAC algorithm is obtained based on the national encryption algorithm; Encrypting the plaintext of the file to be stored using the file key to obtain the corresponding file ciphertext; The file ciphertext is processed using the MAC key to obtain a file verification code, and the file ciphertext and the file verification code are used as the first encryption result.

4. The file storage method according to claim 3, It is characterized in that Also includes: When a file parsing instruction corresponding to the processed file to be stored is obtained, the tag verification code is verified; When the tag verification code is verified, the file verification code is verified; When the file verification code is verified, the file ciphertext is decrypted using the file key to obtain the plaintext of the file to be stored.

5. The file storage method according to claim 3, It is characterized in that The generating the second key by using the second encryption algorithm corresponding to the second encryption algorithm identifier in the encryption algorithm information includes: Generate a file key encryption key in the second key by using a file key encryption algorithm corresponding to a file key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information; The MAC key encryption key in the second key is generated by using the MAC key encryption algorithm corresponding to the MAC key encryption algorithm identifier in the second encryption algorithm identifier in the encryption algorithm information.

6. The file storage method according to claim 5, It is characterized in that The step of encrypting the first key by using the second key to obtain a key ciphertext includes: Encrypting the file key using the file key encryption key to obtain a file key ciphertext; The MAC key is encrypted using the MAC key encryption key to obtain a MAC key ciphertext.

7. A file storage device, It is characterized in that include: A file label creation module, used for creating a file label for the plaintext of the file to be stored when obtaining the plaintext of the file to be stored, and obtaining security attribute information of the plaintext of the file to be stored, wherein the security attribute information includes a file storage protection function identifier and encryption algorithm information required for an encryption process corresponding to the file storage protection function identifier, the file storage protection function identifier indicates the encryption process corresponding to the plaintext of the file to be stored, and the encryption algorithm corresponding to the encryption algorithm information is a national secret algorithm and / or is obtained based on the national secret algorithm; An encryption processing module, used to process the plain text of the file to be stored using the encryption algorithm information to obtain an encryption result; A file label filling module, used to use the file storage protection function identifier and the hash value of the encryption algorithm information as the label verification code corresponding to the plain text of the file to be stored, and write the file storage protection function identifier, the encryption algorithm information and the label verification code into the file label according to a preset format; A storage module, used to bind the file tag with the file ciphertext of the plaintext file to be stored in the encryption result to obtain the processed file to be stored, and store the processed file to be stored; Among them, the file label filling module is used to: use the hash value of the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code and the key storage address as the label verification code corresponding to the plaintext of the file to be stored; write the file storage protection function identifier, the encryption algorithm information, the key ciphertext, the file verification code, the key storage address and the label verification code into the file label according to a preset format.

8. An electronic device, It is characterized in that include: Memory and processor; Wherein, the memory is used to store computer programs; The processor is used to execute the computer program to implement the file storage method according to any one of claims 1 to 6.

9. A computer-readable storage medium, It is characterized in that Used to store a computer program, wherein when the computer program is executed by a processor, the file storage method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Electronic medical record storage method, device and equipment, and storage medium

    CN108573737A

  • Outbound electronic document encryption method and system, terminal and storage medium

    CN110880965A

  • Browser file encryption uploading method and system based on national secret algorithm

    CN112822228A

  • File tag management method and device, storage medium and terminal equipment

    CN113468113A

  • Encryption and decryption method and device based on random hash and bit operation

    WO2020168628A1