Method and device for writing secure data to NAND flash memory and storage medium
By analyzing the security level and length of the data to be stored, and using a Bloom filter to determine the available secure storage space of NAND flash memory, the problem of the inability to reasonably manage and utilize NAND flash memory in existing technologies is solved, and secure data writing and efficient management are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN QUANHUIDA TECH CO LTD
- Filing Date
- 2025-08-07
- Publication Date
- 2026-05-15
AI Technical Summary
Existing data writing methods cannot properly manage and utilize NAND flash memory space, and cannot guarantee data security.
By receiving write requests for data to be stored, parsing the security level and length of the data, using a Bloom filter to determine available secure storage space, and allocating target storage space in the NAND flash memory according to a preset splicing order.
It improves the data write efficiency of NAND flash memory and ensures data security and proper management.
Smart Images

Figure CN121092065B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data management technology, and in particular to a secure data writing method, apparatus and storage medium for NAND flash memory. Background Technology
[0002] Currently, NAND flash memory chips are widely used in electronic devices such as computer systems, digital cameras, portable music players, USB flash drives, and memory cards due to their advantages such as low power consumption, better resistance to physical impacts and electromagnetic compatibility, smaller physical size, and lighter weight. However, existing data writing methods suffer from problems such as inefficient management and utilization of NAND flash memory space and inability to guarantee data security. Summary of the Invention
[0003] This invention provides a secure data writing method for NAND flash memory, aiming to solve the problems of existing data writing methods that cannot reasonably manage and utilize NAND flash memory and cannot guarantee data security. Upon receiving a write request for data to be stored, the method parses the request to obtain the security level and length of the data to be stored. The data length and security level are concatenated according to a preset concatenation order to obtain a query string for the data to be stored. The query string is processed using a preset Bloom filter to determine whether there is available secure storage space for the data to be stored in the NAND flash memory. If available secure storage space exists, a target storage space is allocated for the data to be stored within that space, and the data is written to the target storage space. This method solves the problems of existing data writing methods that cannot reasonably manage and utilize NAND flash memory and cannot guarantee data security.
[0004] In a first aspect, embodiments of the present invention provide a secure data writing method for NAND flash memory, wherein the NAND flash memory includes multiple storage blocks with different security levels, and the secure data writing method for NAND flash memory includes the following steps:
[0005] Upon receiving a write request for data to be stored, the write request is parsed to obtain the security level of the data to be stored and the data length of the data to be stored.
[0006] The data length and security level of the data to be stored are concatenated according to a preset concatenation order to obtain the query string of the data to be stored;
[0007] The query string is processed according to a preset Bloom filter to determine whether there is available safe storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available safe storage space.
[0008] If there is available secure storage space for the data to be stored in the NAND flash memory, then allocate target storage space for the data to be stored in the available secure storage space;
[0009] The data to be stored is written to the target storage space.
[0010] Optionally, the storage block includes multiple storage pages, and the step of concatenating the data length of the data to be stored with the security level of the data to be stored according to a preset concatenation order to obtain the query character field of the data to be stored includes:
[0011] The number of storage pages required for the data to be stored is determined based on the data length of the data to be stored;
[0012] The number of storage pages required for the data to be stored and the security level of the data to be stored are concatenated according to the preset concatenation order to obtain the query string of the data to be stored. The preset concatenation order is the order in which the number of storage pages required for the data to be stored comes first, followed by the security level of the data to be stored.
[0013] Optionally, the available secure storage space is available storage pages, and the Bloom filter is constructed based on the available secure storage space, including:
[0014] For each security level corresponding to a storage block, determine the maximum number of consecutive available storage pages M1 in the storage block corresponding to the security level, where M1 is an integer greater than or equal to 1;
[0015] The Bloom filter is constructed based on the maximum number of consecutive elements M1.
[0016] Optionally, constructing the Bloom filter based on the maximum consecutive number M1 includes:
[0017] Each value from 1 to M1 is concatenated with the security level corresponding to the storage block according to the preset concatenation order to obtain a set of strings to be calculated. The set of strings to be calculated includes M1 strings to be calculated, and each storage block corresponding to the security level corresponds to one set of strings to be calculated.
[0018] For each set of strings to be calculated, hash calculations are performed on the M strings to be calculated in the set of strings to be calculated using N hash functions to obtain a hash array corresponding to the set of strings to be calculated.
[0019] The Bloom filter is constructed based on the hash array corresponding to the set of strings to be calculated.
[0020] Optionally, after storing the data to be stored in the target storage space, the secure data writing method for the NAND flash memory further includes:
[0021] The maximum number of consecutive available storage pages M2 in the storage block where the target storage space is located is re-determined, where M2 is an integer greater than or equal to 0 and less than M1;
[0022] The Bloom filter is updated based on the maximum consecutive number M2.
[0023] Optionally, the method further includes:
[0024] If there is no available secure storage space for the data to be stored in the NAND flash memory, then according to the remaining storage space and storage frequency, a target storage space is allocated for the data to be stored in the storage blocks corresponding to the other security levels, and a temporary mark is made. The temporary mark is used to indicate that the target storage space is in the storage blocks corresponding to the other security levels.
[0025] Secondly, embodiments of the present invention also provide a secure data reading method for NAND flash memory, wherein the NAND flash memory includes multiple storage blocks with different security levels, and the secure data reading method for NAND flash memory includes the following steps:
[0026] Upon receiving a read request from a target user, the write request is parsed to obtain the security level of the data to be read and the storage path of the data to be read.
[0027] If no temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage block corresponding to the security level of the data to be read, based on the storage path of the data to be read.
[0028] If a temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage blocks corresponding to the other security levels based on the temporary marker.
[0029] Thirdly, embodiments of the present invention also provide a secure data writing device for NAND flash memory, the secure data writing device for NAND flash memory comprising:
[0030] The parsing module is used to receive a write request for data to be stored, parse the write request, and obtain the security level and data length of the data to be stored.
[0031] The splicing module is used to splice the data length of the data to be stored and the security level of the data to be stored according to a preset splicing order to obtain the query string of the data to be stored;
[0032] The determination module is used to process the query string according to a preset Bloom filter to determine whether there is available safe storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available safe storage space.
[0033] The allocation module is used to allocate target storage space for the data to be stored in the available safe storage space if there is available safe storage space for the data to be stored in the NAND flash memory;
[0034] The writing module is used to write the data to be stored into the target storage space.
[0035] Fourthly, embodiments of the present invention provide a secure data reading device for NAND flash memory, the secure data reading device for NAND flash memory comprising:
[0036] The receiving module is used to receive a read request from a target user, parse the read request, and obtain the security level of the data to be read and the storage path of the data to be read.
[0037] The first reading module is used to read the target data corresponding to the data to be read from the storage block corresponding to the security level of the data to be read, based on the storage path of the data to be read, if no temporary marker is detected in the storage path.
[0038] The second reading module is used to read the target data corresponding to the data to be read from the storage blocks corresponding to the other security levels based on the temporary marker detected in the storage path.
[0039] Fifthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the secure data writing method for NAND flash memory provided in the embodiments of the present invention.
[0040] In this embodiment of the invention, upon receiving a write request for data to be stored, the write request is parsed to obtain the security level and data length of the data to be stored. The data length and security level of the data to be stored are concatenated according to a preset concatenation order to obtain a query string for the data to be stored. The query string is processed according to a preset Bloom filter to determine whether there is available secure storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available secure storage space. If there is available secure storage space for the data to be stored in the NAND flash memory, a target storage space is allocated for the data to be stored in the available secure storage space. The data to be stored is then written to the target storage space. Upon receiving a write request for data to be stored, the system parses the request to obtain the security level and length of the data. The data length and security level are then concatenated according to a preset order to generate a query string. This query string is processed using a preset Bloom filter to determine if available secure storage space exists in the NAND flash memory. If such space exists, a target storage space is allocated within that space, and the data is written to it. This approach addresses the issues of existing data writing methods that fail to adequately manage and utilize NAND flash memory, thus compromising data security. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a flowchart of a secure data writing method for NAND flash memory provided in an embodiment of the present invention;
[0043] Figure 2 This is a flowchart illustrating a secure data reading method for NAND flash memory provided in an embodiment of the present invention;
[0044] Figure 3 This is a schematic diagram of a secure data writing device for NAND flash memory provided in an embodiment of the present invention;
[0045] Figure 4 This is a schematic diagram of the structure of a secure data reading device for NAND flash memory provided in an embodiment of the present invention. Detailed Implementation
[0046] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0047] like Figure 1 As shown, Figure 1 This is a flowchart of a secure data writing method for NAND flash memory provided by an embodiment of the present invention. The secure data writing method for NAND flash memory includes the following steps:
[0048] 101. Upon receiving a write request for the data to be stored, parse the write request to obtain the security level and length of the data to be stored.
[0049] In this embodiment of the invention, the secure data writing method for NAND flash memory described above can be applied to NAND flash memory, which includes multiple storage blocks with different security levels. The NAND flash memory is a non-volatile memory that employs a non-linear macrocell model and uses floating-gate transistors to store data; data is not lost after power failure.
[0050] The aforementioned security data can be understood as data that needs to be securely stored, such as user data and NAND flash memory management data.
[0051] The data to be stored mentioned above can be understood as data that needs to be written into NAND flash memory.
[0052] The write request mentioned above can be an operation request to write data to NAND flash memory.
[0053] The above analysis can be understood as the process of extracting the security level and data length of the data to be stored from the write request of the data to be stored.
[0054] The above security levels can be understood as the security level of the data, such as high, medium, and low.
[0055] The above data length can be understood as the size or length of the data, in bytes.
[0056] It should be noted that when a write request for data to be stored is received, the write request can be parsed to obtain the security level and length of the data to be stored.
[0057] 102. Concatenate the length of the data to be stored and the security level of the data to be stored according to the preset concatenation order to obtain the query string of the data to be stored.
[0058] In this embodiment of the invention, the above-mentioned preset splicing order can be understood as a splicing order pre-set by the system, such as a splicing order with data length first and security level second.
[0059] The query string described above can be understood as a string representation used in NAND flash memory for quickly locating and retrieving specific data. The query string can be obtained by concatenating the data length and security level of the data to be stored according to a preset concatenation order.
[0060] In one possible embodiment, when the preset concatenation order is data length first and security level second, and the data length to be stored is 10 and the security level of the data to be stored is high, the data length and security level of the data to be stored are concatenated according to the preset concatenation order, and the resulting query string of the data to be stored is 10-high.
[0061] 103. Process the query string according to the preset Bloom filter to determine whether there is available safe storage space in the NAND flash memory for the data to be stored.
[0062] In this embodiment of the invention, the Bloom filter is constructed based on available safe storage space. In NAND flash memory, the Bloom filter can be used to determine whether there is available safe space to store the data to be stored. The aforementioned available safe storage space can be the space remaining in the NAND flash memory after deducting the space already occupied, which can be used to safely store data.
[0063] The Bloom filter described above is a data structure used to detect whether data exists in a set. The Bloom filter maps query strings to secure storage spaces using multiple hash functions, and records the availability of storage space for each security level by setting the corresponding position of bit arrays. Each hash function corresponds to a row in an array. If, after hashing the query string, each hash function's corresponding array contains a hash value for the query string, then the storage space corresponding to that security level can store the data to be stored for that query string.
[0064] It should be noted that when we need to store data, we can use a Bloom filter to process the query string of the data to be stored, so as to quickly determine whether there is available safe storage space in the NAND flash memory, thereby improving the writing efficiency of safe data.
[0065] 104. If there is available safe storage space for the data to be stored in the NAND flash memory, then allocate target storage space for the data to be stored in the available safe storage space.
[0066] In this embodiment of the invention, if there is available safe storage space for the data to be stored in the NAND flash memory, then target storage space can be allocated for the data to be stored in the available safe storage space.
[0067] The aforementioned target storage space can be understood as a storage space allocated in NAND flash memory for storing the data to be stored.
[0068] 105. Write the data to be stored to the target storage space.
[0069] In this embodiment of the invention, after obtaining the target storage space, the data to be stored can be written into the target storage space.
[0070] The above writing can be understood as saving the data to be stored to the target storage space.
[0071] In this embodiment of the invention, the present invention uses a Bloom filter to quickly detect whether there is sufficient and secure storage space to store new data without scanning the entire NAND flash memory, thereby improving write efficiency. At the same time, by managing the data according to its security level, the present invention can better protect the security of the data.
[0072] In this embodiment of the invention, upon receiving a write request for data to be stored, the write request is parsed to obtain the security level and data length of the data to be stored. The data length and security level of the data to be stored are concatenated according to a preset concatenation order to obtain a query string for the data to be stored. The query string is processed according to a preset Bloom filter to determine whether there is available secure storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available secure storage space. If there is available secure storage space for the data to be stored in the NAND flash memory, a target storage space is allocated for the data to be stored in the available secure storage space. The data to be stored is then written to the target storage space. Upon receiving a write request for data to be stored, the system parses the request to obtain the security level and length of the data. The data length and security level are then concatenated according to a preset order to generate a query string. This query string is processed using a preset Bloom filter to determine if available secure storage space exists in the NAND flash memory. If such space exists, a target storage space is allocated within that space, and the data is written to it. This approach addresses the issues of existing data writing methods that fail to adequately manage and utilize NAND flash memory, thus compromising data security.
[0073] It is understood that in the specific implementation of this application, data related to NAND data, storage data, and secure storage data are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required. Furthermore, the collection, use, and processing of related data, as well as the training, deployment, and invocation of algorithm models, must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0074] Optionally, the storage block includes multiple storage pages. In the step of concatenating the data length and security level of the data to be stored according to a preset concatenation order to obtain the query string of the data to be stored, the number of storage pages required for the data to be stored can be determined according to the data length of the data to be stored; the number of storage pages required for the data to be stored and the security level of the data to be stored are concatenated according to a preset concatenation order to obtain the query string of the data to be stored.
[0075] In this embodiment of the invention, the preset splicing order can be a pre-set splicing order. The preset splicing order is the order in which the number of storage pages required for the data to be stored comes first, followed by the security level of the data to be stored.
[0076] The data length mentioned above can be the size or length of the data to be stored, in bytes.
[0077] The number of storage pages mentioned above can be understood as the number of pages storing data.
[0078] The above security levels can be understood as the security level of the data, such as high, medium, and low.
[0079] The query string mentioned above can be a string representation in NAND flash memory used to quickly locate and retrieve specific data.
[0080] It should be noted that the number of storage pages required for the data to be stored can be determined based on the length of the data to be stored. The number of storage pages required for the data to be stored and the security level of the data to be stored are then concatenated in a preset concatenation order to obtain the query string of the data to be stored.
[0081] Optionally, the available secure storage space is the available storage pages. In the step of constructing the Bloom filter based on the available secure storage space, for each security level, the maximum number of consecutive available storage pages M1 in the storage block corresponding to the security level can be determined, where M1 is an integer greater than or equal to 1; and the Bloom filter is constructed based on the maximum number of consecutive pages M1.
[0082] In this embodiment of the invention, the above-mentioned available secure storage space is available storage pages. The maximum number of consecutive pages M1 can be used to represent the maximum available storage space. For example, M1 = 8 means that there are 8 consecutive available storage pages, and the maximum data length that can be stored is within 8 pages.
[0083] The Bloom filter described above is a data structure used to detect the existence of data in a set. The Bloom filter maps data to secure storage spaces using a hash function and records whether each secure storage space is occupied by setting the corresponding position of the bit set.
[0084] It should be noted that a Bloom filter can be constructed based on the available secure storage space. For each security level, the maximum number of consecutive available storage pages M1 in the storage block corresponding to the security level can be determined. M1 is an integer greater than or equal to 1, and the maximum number of consecutive pages M1 is used to construct the Bloom filter.
[0085] Optionally, in the step of constructing a Bloom filter based on the maximum consecutive number M1, each value from 1 to M1 can be concatenated with the security level corresponding to the storage block according to a preset concatenation order to obtain a set of strings to be calculated; for each set of strings to be calculated, the M strings in the set of strings to be calculated are hashed using N hash functions to obtain a hash array corresponding to the set of strings to be calculated; and a Bloom filter is constructed based on the hash array corresponding to the set of strings to be calculated.
[0086] In this embodiment of the invention, the above-mentioned set of strings to be calculated includes M1 strings to be calculated, and each storage block corresponding to a security level corresponds to a set of strings to be calculated.
[0087] M1 above is an integer greater than or equal to 1.
[0088] The above-mentioned preset splicing order is a splicing order pre-set by the system. This preset splicing order prioritizes the number of storage pages required for the data to be stored, followed by the security level of the data to be stored.
[0089] The hash function described above can be understood as a mathematical function that converts input data of arbitrary length into an output of fixed length.
[0090] The hash calculation described above can be understood as the process of converting M strings to be calculated from the set of strings to be calculated into a hash array corresponding to the set of strings to be calculated using N hash functions.
[0091] The hash array described above is a data structure used to quickly determine whether an element exists in a set. The hash array is obtained by performing hash calculations on each string in the set of strings to be calculated using N hash functions. In this embodiment, since the strings to be calculated are constructed from available storage space and security levels, the hash array can quickly query whether there is sufficient storage space in the storage blocks of each security level to store the data to be stored.
[0092] The aforementioned Bloom filter is a data structure used to detect whether data exists in a set. It contains hash arrays corresponding to N hash functions. Each hash array records the availability of storage space. By performing multiple queries and verifications through N hash arrays, the occurrence of the same hash value for different query strings can be reduced, making the availability of storage space more accurate.
[0093] In one possible embodiment, different Bloom filters can be configured for different security levels, that is, each security level is configured with a Bloom filter. After the security level of the data to be stored is obtained, the corresponding Bloom filter is matched according to the security level of the data to be stored.
[0094] In one possible implementation, different security levels are configured to share a single Bloom filter, where a hash array within the Bloom filter includes information on storage space availability for each security level. After resolving the security level of the data to be stored, the existence of available storage space is directly determined using the Bloom filter.
[0095] It should be noted that each value from 1 to M1 can be concatenated with the security level corresponding to the storage block according to a preset concatenation order to obtain a set of strings to be calculated. For each set of strings to be calculated, the M strings in the set are hashed using N hash functions to obtain a hash array corresponding to the set of strings to be calculated. Then, a Bloom filter is constructed using the hash array corresponding to the set of strings to be calculated.
[0096] Optionally, after storing the data to be stored in the target storage space, the maximum number of consecutive available storage pages M2 in the storage block where the target storage space is located can be re-determined, where M2 is an integer greater than or equal to 0 and less than M1; and the Bloom filter is updated based on the maximum number of consecutive pages M2.
[0097] In this embodiment of the invention, the target storage space may be a storage space allocated in the NAND flash memory for storing the data to be stored.
[0098] The aforementioned available storage pages refer to available safe storage space. Available safe storage space can be the space remaining in the NAND flash memory after deducting the space that has already been occupied, which can be used to safely store data.
[0099] M2 is an integer greater than or equal to 0 and less than M1.
[0100] The maximum contiguous quantity mentioned above can be understood as the maximum number of contiguous storage pages available in a storage block.
[0101] It should be noted that the maximum number of consecutive available storage pages M2 in the storage block where the target storage space is located can be redefined, and the Bloom filter can be updated based on the maximum number of consecutive pages M2. Updating the Bloom filter by the maximum number of consecutive pages M2 can more accurately reflect the usage of storage space corresponding to each security level and improve the efficiency of storage management.
[0102] In one possible embodiment, each security level is configured with a Bloom filter, and the above updates may be limited to the Bloom filter corresponding to the security level.
[0103] In one possible embodiment, different security levels are configured to share a single Bloom filter, and the above update is an update to the overall Bloom filter.
[0104] Optionally, the secure data writing method for NAND flash memory can also allocate target storage space for the data to be stored in the storage blocks corresponding to other security levels, and temporarily mark it, if there is no available secure storage space for the data to be stored in the NAND flash memory, based on the remaining storage space and storage frequency.
[0105] In this embodiment of the invention, the aforementioned remaining storage space can be understood as the space remaining in the NAND flash memory after deducting the occupied and available safe storage space, which can be used to write new data.
[0106] The aforementioned storage frequency can be understood as the number of times data is written to NAND flash memory.
[0107] The aforementioned temporary marker is used to indicate that the target storage space is in the storage block corresponding to the other security levels.
[0108] It should be noted that if there is no available secure storage space for the data to be stored in the NAND flash memory, the target storage space for the data to be stored can be allocated in the storage blocks corresponding to the other security levels according to the remaining storage space and storage frequency, and temporarily marked. This can make more efficient use of flash memory space and improve the efficiency of data storage.
[0109] Figure 2This is a flowchart illustrating a secure data reading method for NAND flash memory provided in an embodiment of the present invention. The secure data reading method for NAND flash memory includes the following steps:
[0110] 201. Upon receiving a read request from the target user, the read request is parsed to obtain the security level of the data to be read and the storage path of the data to be read.
[0111] In this embodiment of the invention, the NAND flash memory includes multiple storage blocks with different security levels.
[0112] The read request mentioned above could be an operation request from a target user to read data from NAND flash memory.
[0113] The above analysis can be understood as the process of identifying the data to be read, determining the security level of the data to be read, and determining the storage path of the data to be read.
[0114] The data to be read mentioned above can be understood as the data that needs to be read from the NAND flash memory.
[0115] The above security levels can be understood as the security level of the data, such as high, medium, and low.
[0116] The aforementioned storage path can be understood as the storage location of the data to be read in the NAND flash memory.
[0117] It should be noted that when a read request is received from a target user, the read request can be parsed to obtain the security level of the data to be read and the storage path of the data to be read.
[0118] 202. If no temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage block corresponding to the security level of the data to be read, based on the storage path of the data to be read.
[0119] In this embodiment of the invention, the aforementioned temporary marker is used to indicate that the target storage space is located in the storage block corresponding to the remaining security level. The target storage space can be understood as a storage space allocated in the NAND flash memory for storing the data to be read.
[0120] The target data mentioned above can be data read from the storage path that corresponds to the data to be read.
[0121] It should be noted that if no temporary marker is detected in the storage path, the target data corresponding to the data to be retrieved is read from the storage block corresponding to the security level of the data to be retrieved, based on the storage path of the data to be read.
[0122] 203. If a temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage blocks corresponding to the other security levels based on the temporary marker.
[0123] In this embodiment of the invention, when a temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage blocks corresponding to the other security levels based on the temporary marker.
[0124] In this embodiment of the invention, upon receiving a read request from a target user, the read request can be parsed to obtain the security level of the data to be read and the storage path of the data to be read. If no temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage block corresponding to the security level of the data to be read, based on the storage path of the data to be read. If a temporary marker is detected in the storage path, the target data corresponding to the data to be read is read from the storage blocks corresponding to the other security levels, based on the temporary marker. The temporary marker ensures that the data can be read correctly even if the storage path is modified or damaged.
[0125] like Figure 3 As shown, this embodiment of the invention provides a secure data writing device for NAND flash memory, which includes:
[0126] The parsing module 301 is used to receive a write request for data to be stored, parse the write request, and obtain the security level of the data to be stored and the data length of the data to be stored.
[0127] The splicing module 302 is used to splice the data length of the data to be stored and the security level of the data to be stored according to a preset splicing order to obtain the query string of the data to be stored;
[0128] The determination module 303 is used to process the query string according to a preset Bloom filter to determine whether there is available safe storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available safe storage space.
[0129] The allocation module 304 is used to allocate target storage space for the data to be stored in the available safe storage space if there is available safe storage space for the data to be stored in the NAND flash memory;
[0130] The writing module 305 is used to write the data to be stored into the target storage space.
[0131] Optionally, the splicing module 302 is further configured to determine the number of storage pages required for the data to be stored based on the data length of the data to be stored; and to splice the number of storage pages required for the data to be stored and the security level of the data to be stored according to the preset splicing order to obtain the query string of the data to be stored, wherein the preset splicing order is the order in which the number of storage pages required for the data to be stored comes first, followed by the security level of the data to be stored.
[0132] Optionally, the determining module 303 is further configured to determine, for each security level, the maximum number of consecutive available storage pages M1 in the storage block corresponding to the security level, where M1 is an integer greater than or equal to 1; and construct the Bloom filter based on the maximum number of consecutive pages M1.
[0133] Optionally, the determining module 303 is further configured to concatenate each value from 1 to M1 with the security level corresponding to the storage block according to the preset concatenation order to obtain a set of strings to be calculated, wherein the set of strings to be calculated includes M1 strings to be calculated, and each storage block corresponding to the security level corresponds to one set of strings to be calculated; for each set of strings to be calculated, hash calculation is performed on the M strings to be calculated in the set of strings to be calculated using N hash functions to obtain a hash array corresponding to the set of strings to be calculated; and based on the hash array corresponding to the set of strings to be calculated, the Bloom filter is constructed.
[0134] Optionally, the secure data writing device for the NAND flash memory is further configured to redetermine the maximum number of consecutive available storage pages M2 in the storage block where the target storage space is located, where M2 is an integer greater than or equal to 0 and less than M1; and update the Bloom filter based on the maximum number of consecutive pages M2.
[0135] Optionally, the secure data writing device for the NAND flash memory is further configured to, if there is no available secure storage space for the data to be stored in the NAND flash memory, allocate a target storage space for the data to be stored in the storage blocks corresponding to the remaining security levels according to the remaining storage space and the storage frequency, and temporarily mark it, wherein the temporary mark is used to indicate that the target storage space is in the storage blocks corresponding to the remaining security levels.
[0136] like Figure 4 As shown, this embodiment of the invention provides a secure data reading device for NAND flash memory, which includes:
[0137] The receiving module 401 is used to receive a read request from a target user, parse the read request, and obtain the security level of the data to be read and the storage path of the data to be read.
[0138] The first reading module 402 is used to read the target data corresponding to the data to be read from the storage block corresponding to the security level of the data to be read, based on the storage path of the data to be read, if no temporary marker is detected in the storage path;
[0139] The second reading module 403 is used to read the target data corresponding to the data to be read from the storage blocks corresponding to the other security levels based on the temporary marker detected in the storage path.
[0140] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the secure data writing method for NAND flash memory provided in this invention and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0141] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0142] The above description discloses only preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. Therefore, equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.
Claims
1. A secure data writing method for NAND flash memory, characterized in that, The NAND flash memory includes multiple storage blocks with different security levels, and the secure data writing method for the NAND flash memory includes the following steps: Upon receiving a write request for data to be stored, the write request is parsed to obtain the security level and length of the data to be stored. The data length and security level of the data to be stored are concatenated according to a preset concatenation order to obtain the query string of the data to be stored; The query string is processed according to a preset Bloom filter to determine whether there is available secure storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available secure storage space, which is a available storage page. Specifically, for each storage block corresponding to the security level, the maximum number of consecutive available storage pages M1 in the storage block corresponding to the security level is determined, where M1 is an integer greater than or equal to 1. The Bloom filter is constructed based on the maximum number of consecutive pages M1. If there is available secure storage space for the data to be stored in the NAND flash memory, then allocate target storage space for the data to be stored in the available secure storage space; The data to be stored is written to the target storage space.
2. The secure data writing method for NAND flash memory as described in claim 1, characterized in that, The storage block includes multiple storage pages. The process of concatenating the data length and security level of the data to be stored according to a preset concatenation order to obtain the query string of the data to be stored includes: The number of storage pages required for the data to be stored is determined based on the data length of the data to be stored; The number of storage pages required for the data to be stored and the security level of the data to be stored are concatenated according to the preset concatenation order to obtain the query string of the data to be stored. The preset concatenation order is the order in which the number of storage pages required for the data to be stored comes first, and the security level of the data to be stored comes last.
3. The secure data writing method for NAND flash memory as described in claim 1, characterized in that, The construction of the Bloom filter based on the maximum consecutive number M1 includes: Each value from 1 to M1 is concatenated with the security level corresponding to the storage block according to the preset concatenation order to obtain a set of strings to be calculated. The set of strings to be calculated includes M1 strings to be calculated, and each storage block corresponding to the security level corresponds to one set of strings to be calculated. For each set of strings to be calculated, hash calculations are performed on the M1 strings to be calculated in the set of strings to be calculated using N hash functions to obtain the hash array corresponding to the set of strings to be calculated. The Bloom filter is constructed based on the hash array corresponding to the set of strings to be calculated.
4. The secure data writing method for NAND flash memory as described in claim 3, characterized in that, After storing the data to be stored in the target storage space, the secure data writing method for NAND flash memory further includes: The maximum number of consecutive available storage pages M2 in the storage block where the target storage space is located is re-determined, where M2 is an integer greater than or equal to 0 and less than M1; The Bloom filter is updated based on the maximum consecutive number M2.
5. The secure data writing method for NAND flash memory as described in any one of claims 1 to 4, characterized in that, The method further includes: If there is no available secure storage space for the data to be stored in the NAND flash memory, then according to the remaining storage space and storage frequency, a target storage space is allocated for the data to be stored in the storage blocks corresponding to the other security levels, and a temporary mark is made. The temporary mark is used to indicate that the target storage space is in the storage blocks corresponding to the other security levels.
6. A secure data writing device for NAND flash memory, characterized in that, The NAND flash memory includes multiple storage blocks with different security levels, and the secure data writing device for the NAND flash memory includes: The parsing module is used to receive a write request for data to be stored, parse the write request, and obtain the security level and data length of the data to be stored. The splicing module is used to splice the data length of the data to be stored and the security level of the data to be stored according to a preset splicing order to obtain the query string of the data to be stored; The determination module is used to process the query string according to a preset Bloom filter to determine whether there is available secure storage space for the data to be stored in the NAND flash memory. The Bloom filter is constructed based on the available secure storage space, which is an available storage page. Specifically, for each storage block corresponding to the security level, the maximum consecutive number M1 of available storage pages in the storage block corresponding to the security level is determined, where M1 is an integer greater than or equal to 1; the Bloom filter is constructed based on the maximum consecutive number M1. The allocation module is used to allocate target storage space for the data to be stored in the available safe storage space if there is available safe storage space for the data to be stored in the NAND flash memory; The writing module is used to write the data to be stored into the target storage space.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the secure data writing method for NAND flash memory as described in any one of claims 1 to 5.