Method and system for storing and extracting private data of encrypted storage medium
By using random keys in encrypted storage media for encryption and decryption and data verification, data leakage and integrity issues are solved, and data is securely stored and extracted, ensuring the stability of business processes.
Patent Information
- Application Number
- CN202411229125.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-06
AI Technical Summary
In encrypted storage media, direct plain text writing and reading of data can easily lead to business data leakage, and the lack of a data verification mechanism may lead to abnormal business processes.
Find the free sector in the encrypted storage medium, generate a random key for encryption and decryption, and perform data integrity verification to ensure the security and integrity of the data during storage and extraction.
It effectively avoids business data leakage and corruption, ensures the security and integrity of data, and also has version management functions to prevent business process abnormalities caused by incompatibility of data formats in different versions.
Smart Images

Figure CN119089473A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of data encryption, and in particular relates to a method and system for storing and extracting private data in an encrypted storage medium. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] In order to ensure the security of data transfer in the storage medium, the storage medium needs to be encrypted. In this business scenario, it is usually necessary to store the business information of the product in the medium, such as describing the scope of use of the storage medium, the use rights of the storage medium, and other information required by the business.
[0004] However, since the storage medium has been encrypted, the file system in the storage medium is also in an encrypted state, and conventional file operations cannot be used to store business data. If the data is written directly in plain text and read directly when used, the internal business data is easily leaked to the outside because the data is directly read and written in plain text; in addition, since there is no data verification mechanism, the integrity of the business data cannot be verified, and damaged data may be used, causing abnormalities in the business process. Summary of the invention
[0005] In order to solve the above problems, the present invention proposes a method and system for storing and extracting private data in an encrypted storage medium. The present invention finds a free storage area in the sector of the encrypted storage medium, and then organizes the area into a data interface for internal use, which can avoid the risk of business data leakage and perform data integrity verification to avoid damage to business data and cause business process abnormalities.
[0006] According to some embodiments, the present invention adopts the following technical solutions:
[0007] A method for storing private data in an encrypted storage medium comprises the following steps:
[0008] Find a free storage sector in the encrypted storage medium, construct a structure describing the storage sector, and initialize each member of the structure;
[0009] Generate a random key, and copy the random key into the encryption and decryption key field of the structure;
[0010] Calculate the data check bit for the structure itself and the business data to be stored;
[0011] The business data except the mark field and the key field are encrypted using the random key, and after the encryption is completed, the business data is written into an idle storage sector.
[0012] As an optional implementation, the members of the structure include structure identification and version number information.
[0013] As an optional implementation, the random key is generated through a random number interface, and all subsequent encryption and decryption operations during this operation are performed using the random key.
[0014] As an optional implementation, CRC32 is used to calculate the data check bit.
[0015] A method for extracting private data from an encrypted storage medium comprises the following steps:
[0016] Read the offset of the sector storing the business data to determine whether the data identifier exists;
[0017] If the data identification is normal, read the description structure of the business data, extract the generated random key in the encryption storage medium, decrypt the description structure by the random key, and determine the basic information of the business data;
[0018] Verify the version, calculate the check digit of the data, and compare the calculated check digit with the check digit in the structure. If the version or comparison result is inconsistent, terminate the entire extraction process;
[0019] If the version and comparison results are consistent, the starting position of the business data is found according to the business data offset field in the description structure, all business data is read from the sector according to the basic information of the business data, and the business data is decrypted using the random key.
[0020] As an optional implementation, the offset is the offset length of the calculated free storage sector relative to the starting position of the partition.
[0021] As an optional implementation method, the structure used to describe the business data, that is, the basic information of the business data specifically includes the extension header identifier, user data key, version number, total data length, data header size, user data offset, the total size of the space available to the user and the actual user data size used.
[0022] As an optional implementation, the check bit of the calculation data is performed using a CRC32 check.
[0023] As an optional implementation, based on the basic information of the business data, the process of reading out all the business data from the sector includes: finding the starting position of the business data according to the business data offset field in the description structure, obtaining the size of the business data through the length field, extracting the plaintext business data written during initialization according to the offset and length, and returning the business data to the data extraction requester.
[0024] An encrypted storage medium private data storage system, comprising:
[0025] The initialization module is used to find a free storage sector in the encrypted storage medium, construct a structure describing the storage sector, and perform initialization operations on each member of the structure;
[0026] A key generation module, used for generating a random key, and copying the random key into the encryption and decryption key field of the structure;
[0027] A check bit calculation module is used to calculate the data check bits of the structure itself and the business data to be stored;
[0028] The data writing module is used to encrypt the business data except the mark field and the key field using the random key, and write the business data into the idle storage sector after the encryption is completed.
[0029] A system for extracting private data from an encrypted storage medium, comprising:
[0030] The offset reading module is used to read the offset of the sector storing the business data and determine whether the data identifier exists;
[0031] A description structure extraction module is used to read the description structure of the business data if the data identification is normal, extract the generated random key in the encryption storage medium, decrypt the description structure by the random key, and determine the basic information of the business data;
[0032] The comparison module is used to verify the version, calculate the check digit of the data, and compare the calculated check digit with the check digit in the structure. If the version or the comparison result is inconsistent, the entire extraction process is terminated;
[0033] The decryption and extraction module is used to find the starting position of the business data according to the offset field of the business data in the description structure if the version and the comparison result are consistent, read all the business data from the sector according to the basic information of the business data, and decrypt the business data using the random key.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] Compared with direct write storage, the present invention has transparent encryption and decryption protection for written data, which can avoid the risk of business data leakage, data integrity verification, and avoid business process abnormalities caused by damaged business data. It also has a version management function to avoid business process abnormalities caused by incompatible data formats of different versions.
[0036] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0038] Figure 1 is a schematic diagram of a process flow of private data storage in an encrypted storage medium according to an embodiment;
[0039] Figure 2 is a schematic diagram of a process for extracting private data from an encrypted storage medium according to an embodiment;
[0040] Figure 3 The present invention is a data distribution diagram of an encrypted storage medium of an embodiment. DETAILED DESCRIPTION
[0041] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0042] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0043] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0044] In the absence of conflict, the embodiments in this application and the features in the embodiments may be combined with each other.
[0045] Embodiment 1
[0046] A method for storing private data in an encrypted storage medium, such as Figure 1 As shown, first, a free storage area is found in the sector of the encrypted storage medium, and the area is organized into a data interface for internal use, including an extended header identifier, a randomly generated key for the protected data area, a data structure version number (for ensuring version compatibility) and a data check code / data check bit (for checking the integrity of business data), specifically including the following steps:
[0047] 1) After the storage medium is made, first find an unused free disk sector in the encrypted storage medium. After the program tests whether it can read and write normally, construct a structure describing the storage area and initialize each member of the structure, including the structure identifier, version number information and data offset length initialization.
[0048] 2) Encrypt and protect the data in this area, generate a 64-character random key through the random number interface, copy the random key to the encryption and decryption key field of the structure, and all subsequent encryption and decryption operations are performed using the random key.
[0049] 3) Calculate the data check bit for the business data and the structure itself. Here we use CRC32 to verify the integrity of the data. After the CRC32 calculation is completed, it is written into the check bit field describing the structure.
[0050] 4) All business data except the tag field and the key field are encrypted using the newly generated random key. After encryption, the business data is written into the free disk sector at one time.
[0051] Embodiment 2
[0052] A method for extracting private data from an encrypted storage medium, such as Figure 2 As shown, the following steps are included:
[0053] 1) When the business data needs to be used (usually after the encrypted storage medium is inserted into the terminal), first read the offset of the sector where the business data is stored (the offset is an unused free storage area for backing up the encrypted data header found by analyzing the data structure of the encryption device. It is an offset relative to the starting position of the partition of the encrypted storage medium. The offset is fixed and can be used to store business data) to see if the data identifier exists.
[0054] Specifically, the data distribution of the encrypted storage medium of this embodiment is as follows: Figure 3 shown.
[0055] 2) If the data identification is normal, first read the fixed-size business data description structure, then extract the initialized 64-bit random key in the encrypted storage medium, and decrypt the data description structure with the key. After decryption, you can get the plaintext structure describing the business data, which mainly includes the following fields: extension header identification, user data key, version number, total data length, data header size, user data offset, total size of space available to the user (usually around 64KB), and actual size of user data used.
[0056] 3) According to the total size field of the business data, all the business data can be read out through the data reading interface. After the reading is completed, all the business data can be decrypted using the key in step 2).
[0057] 4) After decryption is completed, the version is first verified to see if it is the version number supported by the terminal, and then the CRC32 checksum of the data is calculated, and the calculated CRC32 checksum is compared with the CRC32 checksum in the structure. If they are inconsistent, the data has been modified and there is an abnormality. The whole process is terminated. If they are consistent, proceed to the following steps.
[0058] 5) Through step 4), the original written business data structure after decryption and CRC32 verification can be obtained, and then the starting position of the business data is found according to the business data offset field in the description structure, and the size of the business data is obtained through the length field; the plaintext business data written during initialization is extracted according to the offset and data length and the data is returned to the interface caller, and the entire business process is completed.
[0059] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0060] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0061] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0062] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0063] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made by those skilled in the art within the spirit and principle of the present invention without creative labor shall be included in the protection scope of the present invention.
Claims
1. A method for storing private data in an encrypted storage medium, characterized in that: The following steps are involved: Find a free storage sector in the encrypted storage medium, construct a structure describing the storage sector, and initialize each member of the structure; Generate a random key, and copy the random key into the encryption and decryption key field of the structure; Calculate the data check bit for the structure itself and the business data to be stored; The business data except the mark field and the key field are encrypted using the random key, and after the encryption is completed, the business data is written into an idle storage sector.
2. A method for storing private data in an encrypted storage medium as claimed in claim 1, characterized in that: The members of the structure include structure identification and version number information.
3. A method for storing private data in an encrypted storage medium as claimed in claim 1, characterized in that: The random key is generated through a random number interface, and all subsequent encryption and decryption operations during this operation are performed using the random key.
4. A method for storing private data in an encrypted storage medium as claimed in claim 1, characterized in that: Use CRC32 to calculate the data check bit.
5. A method for extracting private data from an encrypted storage medium, based on the storage method described in claims 1-4, characterized in that: The following steps are involved: Read the offset of the sector storing the business data to determine whether the data identifier exists; If the data identification is normal, read the description structure of the business data, extract the generated random key in the encryption storage medium, decrypt the description structure by the random key, and determine the basic information of the business data; Verify the version, calculate the check digit of the data, and compare the calculated check digit with the check digit in the structure. If the version or comparison result is inconsistent, terminate the entire extraction process; If the version and comparison results are consistent, the starting position of the business data is found according to the business data offset field in the description structure, all business data is read from the sector according to the basic information of the business data, and the business data is decrypted using the random key.
6. A method for extracting private data from an encrypted storage medium as claimed in claim 5, characterized in that: The offset is the offset length of the calculated free storage sector relative to the starting position of the partition.
7. A method for extracting private data from an encrypted storage medium as claimed in claim 5, characterized in that: A structure used to describe business data, that is, the basic information of business data includes the extension header identifier, user data key, version number, total data length, data header size, user data offset, total size of space available to the user, and actual size of user data used.
8. A method for extracting private data from an encrypted storage medium as claimed in claim 5, characterized in that: The check bit of the calculated data is performed using CRC32 check; Or, based on the basic information of the business data, the process of reading all the business data from the sector includes: finding the starting position of the business data according to the business data offset field in the description structure, obtaining the size of the business data through the length field, extracting the plaintext business data written during initialization according to the offset and length, and returning the business data to the data extraction requester.
9. An encrypted storage medium private data storage system, characterized in that: include: The initialization module is used to find a free storage sector in the encrypted storage medium, construct a structure describing the storage sector, and perform initialization operations on each member of the structure; A key generation module, used for generating a random key, and copying the random key into the encryption and decryption key field of the structure; A check bit calculation module is used to calculate the data check bits of the structure itself and the business data to be stored; The data writing module is used to encrypt the business data except the mark field and the key field using the random key, and write the business data into the idle storage sector after the encryption is completed.
10. A system for extracting private data from encrypted storage media, characterized in that: include: The offset reading module is used to read the offset of the sector storing the business data and determine whether the data identifier exists; A description structure extraction module is used to read the description structure of the business data if the data identification is normal, extract the generated random key in the encryption storage medium, decrypt the description structure by the random key, and determine the basic information of the business data; The comparison module is used to verify the version, calculate the check digit of the data, and compare the calculated check digit with the check digit in the structure. If the version or the comparison result is inconsistent, the entire extraction process is terminated; The decryption and extraction module is used to find the starting position of the business data according to the offset field of the business data in the description structure if the version and the comparison result are consistent, read all the business data from the sector according to the basic information of the business data, and decrypt the business data using the random key.
