CN111261214B - Answer protection monotonic counter and method for managing count value thereof - Google Patents

Answer protection monotonic counter and method for managing count value thereof Download PDF

Info

Publication number
CN111261214B
CN111261214B CN202010366817.6A CN202010366817A CN111261214B CN 111261214 B CN111261214 B CN 111261214B CN 202010366817 A CN202010366817 A CN 202010366817A CN 111261214 B CN111261214 B CN 111261214B
Authority
CN
China
Prior art keywords
sector
data
adjacent sectors
sectors
count value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010366817.6A
Other languages
Chinese (zh)
Other versions
CN111261214A (en
Inventor
黄亚龙
徐光明
虞安华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xtx Technology Inc
Original Assignee
XTX Technology Shenzhen Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by XTX Technology Shenzhen Ltd filed Critical XTX Technology Shenzhen Ltd
Priority to CN202010366817.6A priority Critical patent/CN111261214B/en
Publication of CN111261214A publication Critical patent/CN111261214A/en
Application granted granted Critical
Publication of CN111261214B publication Critical patent/CN111261214B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C16/00Erasable programmable read-only memories
    • G11C16/02Erasable programmable read-only memories electrically programmable
    • G11C16/06Auxiliary circuits, e.g. for writing into memory
    • G11C16/22Safety or protection circuits preventing unauthorised or accidental access to memory cells
    • G11C16/225Preventing erasure, programming or reading when power supply voltages are outside the required ranges
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/78Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure storage of data
    • G06F21/79Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure storage of data in semiconductor storage media, e.g. directly-addressable memories

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention provides a response protection monotonic counter and a method for managing the count value thereof, comprising the following steps: finding the sector with data, if only 1 sector has data, finding from back to front whether 2 values can be found in the sector to satisfy M1+1= M2, if yes, using M2 as a count value, and if not, using the first value in the sector as the count value. If the 2 sectors all have data, judging whether the data in the previous sector is valid, if the data in the previous sector is invalid, taking the first value in the next sector as a counting value, if the data in the previous sector is valid, judging whether the last value M5 plus 1 in the previous sector is equal to the first value M6 in the next sector, if the data in the previous sector is equal to the first value M6 in the next sector, taking M6 as the counting value, and if the data in the previous sector is not valid, taking M5 as. The embodiment determines the correct count value by judging the rule met by the numerical value in the sector, and the correct count value can be determined by the scheme of the invention even if abnormal power failure or other abnormal conditions occur when the two storage blocks are switched.

Description

Answer protection monotonic counter and method for managing count value thereof
Technical Field
The invention relates to the technical field of storage, in particular to a response protection monotonic counter and a method for managing the count value thereof.
Background
The enhanced Flash with answer Protection Monotonic Counter (RPMC) is a Basic Input-Output System (BIOS) chip of Intel push-to-master, which contains a large-capacity Flash chip and RPMC circuit, wherein, the F L ASH chip is used to store the code and data of CPU BIOS, the RPMC circuit ensures the confidentiality and integrity of read-write data, the RPMC circuit and its integrated F L ASH form the hardware platform of BIOS in computer System.
In the prior art, a response protection monotonic counter usually adopts two storage blocks to store and count data in turn, and when the current storage block is not fully recorded with count data, only the data needs to be read or counted in the current storage block; however, when one memory block stores the full count data, the current total count number is written into the other memory block, and the count identification bit and the check bit of the other memory block are written at the same time, and then the memory block with the full count data is erased, and then the necessary switching between the two memory blocks is required. However, in the prior art, if power is abnormally lost or other abnormal conditions, such as voltage fluctuation, etc., occur when two memory blocks are switched, it is often difficult to determine the current memory block being counted, so that a correct count value cannot be determined.
Disclosure of Invention
The present invention is directed to a method for protecting a monotonic counter and managing the count value thereof in response, and aims to solve the above-mentioned problems in the prior art.
To achieve the above object, an embodiment of the present invention provides a method for managing a count value of a response protection monotonic counter, where the response protection monotonic counter includes an eFlash, the eFlash includes 4 storage blocks, each storage block includes 4 sectors, and the method for managing a count value of the response protection monotonic counter includes:
when the power-on condition is met, detecting whether data exists in 4 sectors of any one of 4 storage blocks;
when only one sector of the 4 sectors of any storage block has data, taking the last data in the sector as M2, and detecting whether M1 exists in the data arranged before M2 in the sector, wherein M2 is M1+ 1;
if M1 exists in the data arranged before M2 in the sector, setting M2 as the count value corresponding to any storage block;
if M1 does not exist in the data arranged before M2 in the one sector, taking the data arranged one bit before M2 in the one sector as M2, and performing the step of detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+1, until when M2 is the second data counted positively in the one sector and M1 does not exist in the data arranged before M2 in the one sector, setting the first data counted positively in the one sector as the count value corresponding to any memory block;
when two adjacent sectors exist in the 4 sectors of any storage block, detecting whether data in the prior sector in the two adjacent sectors are valid;
if the data in the sector arranged in front of the two adjacent sectors are invalid, taking the positive first data in the sector arranged in back of the two adjacent sectors as the count value corresponding to any storage block;
if the data in the preceding sector of the two adjacent sectors is valid, taking the first last data in the preceding sector of the two adjacent sectors as M5, taking the first positive data in the following sector of the two adjacent sectors as M6, and judging whether M5+1 is M6;
if M5+1 is M6, M6 is used as the count value corresponding to the above-mentioned any memory block, and if M5+1 is M6 is not M, M5 is used as the count value corresponding to the above-mentioned any memory block.
Optionally, the detecting whether the data in the preceding sector of the two adjacent sectors is valid includes:
taking the last data in the first sector of the two adjacent sectors as M4, and detecting whether M3 exists in the data in the first sector of the two adjacent sectors before M4, wherein M4 is M3+ 1;
if M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is valid;
if M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data arranged one bit before M4 in the preceding sector of the two adjacent sectors is M4, and the step of detecting whether M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors is performed, wherein M4 is M3+1, until when M4 is the positive second data in the preceding sector of the two adjacent sectors, and M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data in the preceding sector of the two adjacent sectors is determined to be invalid.
In addition, to achieve the above object, an embodiment of the present invention further provides an answer protection monotonic counter, where the answer protection monotonic counter includes:
the flash comprises 4 storage blocks, each storage block comprises 4 sectors, and the sectors are used for storing counting data;
the detection module is used for detecting whether data exists in 4 sectors of any one of the 4 storage blocks when the power-on condition is met;
the detection module is further used for taking the last-but-one data in one sector as M2 when only one sector of the 4 sectors of any storage block has data, and detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+ 1;
a setting module, configured to set M2 as a count value corresponding to any one of the storage blocks if M1 exists in data arranged before M2 in the one sector;
a step jumping module, configured to, if M1 does not exist in data arranged in the one sector before M2, use data arranged in the one sector before M2 as M2, and perform the step of detecting whether M1 exists in data arranged in the one sector before M2, where M2 is M1+1, until when M2 is second data counted positively in the one sector and M1 does not exist in data arranged in the one sector before M2, set first data counted positively in the one sector as a count value corresponding to any memory block;
the detection module is further used for detecting whether the data in the sector arranged in front of the two adjacent sectors is valid or not when the data exists in the two adjacent sectors in the 4 sectors of any storage block;
the setting module is further configured to use positive first data in a sector arranged after the two adjacent sectors as a count value corresponding to the any storage block if data in a sector arranged before the two adjacent sectors are invalid;
the detection module is further configured to, if the data in the preceding sector of the two adjacent sectors is valid, determine that M5+1 is M6, where M5 is the first data from the last sector of the two adjacent sectors, and M6 is the first data from the last sector of the two adjacent sectors;
the setting module is further configured to use M6 as the count value corresponding to the any storage block if M5+1 is M6, and use M5 as the count value corresponding to the any storage block if M5+1 is M6 is not M.
Optionally, the detection module is further configured to:
taking the last data in the first sector of the two adjacent sectors as M4, and detecting whether M3 exists in the data in the first sector of the two adjacent sectors before M4, wherein M4 is M3+ 1;
if M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is valid;
if M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data arranged one bit before M4 in the preceding sector of the two adjacent sectors is M4, and the step of detecting whether M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors is performed, wherein M4 is M3+1, until when M4 is the positive second data in the preceding sector of the two adjacent sectors, and M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data in the preceding sector of the two adjacent sectors is determined to be invalid.
In the invention, when the power-on condition is met, whether data exists in 4 sectors of any one of 4 storage blocks is detected; when only one sector of the 4 sectors of any storage block has data, taking the last data in the sector as M2, and detecting whether M1 exists in the data arranged before M2 in the sector, wherein M2 is M1+ 1; if M1 exists in the data arranged before M2 in the sector, setting M2 as the count value corresponding to any storage block; if M1 does not exist in the data arranged before M2 in the one sector, taking the data arranged one bit before M2 in the one sector as M2, and performing the step of detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+1, until when M2 is the second data counted positively in the one sector and M1 does not exist in the data arranged before M2 in the one sector, setting the first data counted positively in the one sector as the count value corresponding to any memory block; when two adjacent sectors exist in the 4 sectors of any storage block, detecting whether data in the prior sector in the two adjacent sectors are valid; if the data in the sector arranged in front of the two adjacent sectors are invalid, taking the positive first data in the sector arranged in back of the two adjacent sectors as the count value corresponding to any storage block; if the data in the preceding sector of the two adjacent sectors is valid, taking the first last data in the preceding sector of the two adjacent sectors as M5, taking the first positive data in the following sector of the two adjacent sectors as M6, and judging whether M5+1 is M6; if M5+1 is M6, M6 is used as the count value corresponding to the above-mentioned any memory block, and if M5+1 is M6 is not M, M5 is used as the count value corresponding to the above-mentioned any memory block. The invention determines the correct count value by judging the rule that the numerical values in the sectors conform to, and the correct count value can be determined by the scheme of the embodiment even if abnormal power failure or other abnormal conditions occur when the two storage blocks are switched.
Drawings
FIG. 1 is a flowchart illustrating an embodiment of a method for managing count values of an ACR monotonic counter according to the present invention;
FIG. 2 is a schematic structural diagram of an eFlash in an embodiment of a method for managing count values of a response protection monotonic counter according to the present invention;
FIG. 3 is a diagram illustrating storage of a sector in an embodiment of a method for managing count values of an acknowledge protection monotonic counter according to the invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating an embodiment of a method for managing a count value of a response protection monotonic counter according to the present invention. As shown in fig. 1, the method of managing the count value of the answer protection monotonic counter includes:
step S10, when the power-on condition is satisfied, detecting whether data exists in 4 sectors of any one of 4 storage blocks;
in this embodiment, a 4K × 32eFlash (embedded flash) is added inside the RPMC, and since the RPMC has 4 sets of counters, the eFlash is divided into 4 storage blocks, and each storage block includes 4 Sector sectors. Referring to fig. 2, fig. 2 is a schematic structural diagram of eFlash in an embodiment of a method for managing a count value of a response protection monotonic counter according to the present invention. As shown in fig. 2, counter 0 of RPMC corresponds to sectors 0 to 3, and sectors 0 to 3 belong to the first memory block; counter 1 of RPMC corresponds to Sector 4-Sector 7, and Sector 4-Sector 7 belong to the second storage block; counter 2 of RPMC corresponds to Sector 8-Sector 11, and Sector 8-Sector 11 belong to the third storage block; counter 3 of RPMC corresponds to sectors 12 to 15, and sectors 12 to 15 belong to the fourth memory block. When the external HOST sends a command to increment the count value, the RPMC will sequentially write the correct count value into the sectors of the corresponding memory block. Referring to fig. 3, fig. 3 is a schematic diagram illustrating storage bits of a sector in an embodiment of a method for managing a count value of an acknowledge protection monotonic counter according to the present invention. As shown in fig. 3, one sector includes 128 storage bits, i.e., one sector can store 128 count values.
Wherein, the power-on condition means that the power supply voltage of the enhanced Flash containing the RPMC reaches the starting voltage. That is, when the power supply voltage of the enhanced Flash containing the RPMC reaches the starting voltage, whether data exists in 4 sectors of any one of the 4 storage blocks is detected. Any memory block may be any one of the first memory block, the second memory block, the third memory block, and the fourth memory block. The first memory block will be described as an example.
Step S20, when only one sector of the 4 sectors of any memory block has data, taking the last data in the one sector as M2, and detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+ 1;
in this embodiment, when only one of the 4 sectors of the first memory block has data, for example, when there is data in Sector0 of the first memory block, the last data in Sector0 is taken as M2, and it is detected whether M1 exists in the data arranged before M2 in Sector0, where M2 is M1+ 1. For example, if the last-but-one data in Sector0 is 88, it is found whether there is one data of 87 from the last-but-one to the first-plus data in Sector0, if found, it means that M1 exists, and if not, it means that M1 does not exist when the last-but-one data in Sector0 is M2.
Step S30, if M1 exists in the data arranged before M2 in the sector, setting M2 as the count value corresponding to the any storage block;
in this embodiment, if M1 exists, the current M2 is set as the count value corresponding to the first storage block. That is, when HOST needs to read the count value from the first memory block, the read count value is M2.
Step S40, if M1 does not exist in the data arranged in the one sector before M2, setting the data arranged in the one sector before M2 as M2, and performing the step of detecting whether M1 exists in the data arranged in the one sector before M2, where M2 is M1+1, until when M2 is the second data counted positively in the one sector and M1 does not exist in the data arranged in the one sector before M2, setting the first data counted positively in the one sector as the count value corresponding to any memory block;
in this embodiment, when M2 is the first to last data in Sector0, if M1 cannot be found, the previous data of M2 is taken as M2, that is, the second to last data in Sector0 is taken as M2, M1 is searched from the third to positive data in Sector0, and if M1 can be found, M2 (the second to last data in Sector 0) at this time is taken as the count value corresponding to the first storage block. If M1 cannot be found, the previous data of M2 is taken as M2, that is, the third last data in Sector0 is taken as M2, M1 is searched from the fourth last data to the first positive data in Sector0, and if M1 can be found, M2 (the third last data in Sector 0) at this time is taken as the count value corresponding to the first storage block. If M1 cannot be found, the above steps are repeated until M2 is the second positive data in Sector0 and M1 does not exist in the data arranged before M2 in Sector0, and the first positive data in Sector0 is set as the count value corresponding to the first storage block.
Step S50, when there are two adjacent sectors in the 4 sectors of any storage block, detecting whether the data in the sector arranged in front of the two adjacent sectors is valid;
in this embodiment, when there are two adjacent sectors in the 4 sectors of the first storage block, for example, there are data in sectors 2 and 3, it is detected whether data in the Sector arranged in front of the two adjacent sectors is valid, that is, whether data in Sector2 is valid.
In one embodiment, the detecting whether the data in the preceding sector of the two adjacent sectors is valid includes:
taking the last data in the first sector of the two adjacent sectors as M4, and detecting whether M3 exists in the data in the first sector of the two adjacent sectors before M4, wherein M4 is M3+ 1; if M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is valid; if M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data arranged one bit before M4 in the preceding sector of the two adjacent sectors is M4, and the step of detecting whether M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors is performed, wherein M4 is M3+1, until when M4 is the positive second data in the preceding sector of the two adjacent sectors, and M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data in the preceding sector of the two adjacent sectors is determined to be invalid.
In this embodiment, taking the Sector arranged in the front as Sector2 as an example, the last data in Sector2 is taken as M4, and it is detected whether M3 exists in the data arranged before M4 in Sector2, where M4 is M3+ 1. For example, if the first to last data in Sector2 is 66, then it is found whether there is 65 data from the first to last data in Sector2, and if it can be found, i.e., it indicates that M3 exists, then it is determined that the data in Sector2 is valid.
When M4 is the first data to the last in Sector2, if M3 cannot be found, the previous data of M4 is taken as M4, namely the second data to the last in Sector2 is taken as M4, M3 is found from the third to the first data to the positive number in Sector2, and if M3 can be found, the data in Sector2 is determined to be valid. If M3 cannot be found, the previous data of M4 is taken as M4, namely the third last data in Sector2 is taken as M4, M3 is searched from the fourth last to the first positive data in Sector2, and if M3 can be found, the data in Sector2 is determined to be valid. If M3 cannot be found, the above steps are repeated until the data in Sector2 is determined to be invalid when M4 is the second most significant data in Sector2 and M3 does not exist in the data arranged before M4 in Sector 2.
Step S60, if the data in the preceding sector of the two adjacent sectors is invalid, taking the positive first data in the succeeding sector of the two adjacent sectors as the count value corresponding to the any storage block;
in this embodiment, if the data in the preceding sector of the two adjacent sectors is invalid, the positive first data in the succeeding sector of the two adjacent sectors is directly used as the count value corresponding to the first storage block.
Step S70, if the data in the preceding sector of the two adjacent sectors is valid, taking the first last data in the preceding sector of the two adjacent sectors as M5, taking the first positive data in the succeeding sector of the two adjacent sectors as M6, and determining whether M5+1 is M6;
in step S80, if M5+1 ═ M6 is satisfied, M6 is used as the count value corresponding to the above-mentioned any memory block, and if M5+1 ═ M6 is not satisfied, M5 is used as the count value corresponding to the above-mentioned any memory block.
In this embodiment, if the data in the sector preceding the first of the two adjacent sectors is valid, the data of the first last of the two adjacent sectors is M5, the data of the first positive of the two adjacent sectors is M6, and it is determined whether M5+1 is M6. When the equation is satisfied, M6 is used as the count value corresponding to the first memory block, and when the equation is not satisfied, M5 is used as the count value corresponding to the first memory block.
In this embodiment, when the power-on condition is satisfied, whether data exists in 4 sectors of any one of 4 storage blocks is detected; when only one sector of the 4 sectors of any storage block has data, taking the last data in the sector as M2, and detecting whether M1 exists in the data arranged before M2 in the sector, wherein M2 is M1+ 1; if M1 exists in the data arranged before M2 in the sector, setting M2 as the count value corresponding to any storage block; if M1 does not exist in the data arranged before M2 in the one sector, taking the data arranged one bit before M2 in the one sector as M2, and performing the step of detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+1, until when M2 is the second data counted positively in the one sector and M1 does not exist in the data arranged before M2 in the one sector, setting the first data counted positively in the one sector as the count value corresponding to any memory block; when two adjacent sectors exist in the 4 sectors of any storage block, detecting whether data in the prior sector in the two adjacent sectors are valid; if the data in the sector arranged in front of the two adjacent sectors are invalid, taking the positive first data in the sector arranged in back of the two adjacent sectors as the count value corresponding to any storage block; if the data in the preceding sector of the two adjacent sectors is valid, taking the first last data in the preceding sector of the two adjacent sectors as M5, taking the first positive data in the following sector of the two adjacent sectors as M6, and judging whether M5+1 is M6; if M5+1 is M6, M6 is used as the count value corresponding to the above-mentioned any memory block, and if M5+1 is M6 is not M, M5 is used as the count value corresponding to the above-mentioned any memory block. The embodiment determines the correct count value by judging the rule met by the numerical value in the sector, and even if abnormal power failure or other abnormal conditions occur when the two storage blocks are switched, the correct count value can be determined by the scheme of the embodiment.
This embodiment further provides an answer protection monotonic counter, where the answer protection monotonic counter includes:
the flash comprises 4 storage blocks, each storage block comprises 4 sectors, and the sectors are used for storing counting data;
the detection module is used for detecting whether data exists in 4 sectors of any one of the 4 storage blocks when the power-on condition is met;
the detection module is further used for taking the last-but-one data in one sector as M2 when only one sector of the 4 sectors of any storage block has data, and detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+ 1;
a setting module, configured to set M2 as a count value corresponding to any one of the storage blocks if M1 exists in data arranged before M2 in the one sector;
a step jumping module, configured to, if M1 does not exist in data arranged in the one sector before M2, use data arranged in the one sector before M2 as M2, and perform the step of detecting whether M1 exists in data arranged in the one sector before M2, where M2 is M1+1, until when M2 is second data counted positively in the one sector and M1 does not exist in data arranged in the one sector before M2, set first data counted positively in the one sector as a count value corresponding to any memory block;
the detection module is further used for detecting whether the data in the sector arranged in front of the two adjacent sectors is valid or not when the data exists in the two adjacent sectors in the 4 sectors of any storage block;
the setting module is further configured to use positive first data in a sector arranged after the two adjacent sectors as a count value corresponding to the any storage block if data in a sector arranged before the two adjacent sectors are invalid;
the detection module is further configured to, if the data in the preceding sector of the two adjacent sectors is valid, determine that M5+1 is M6, where M5 is the first data from the last sector of the two adjacent sectors, and M6 is the first data from the last sector of the two adjacent sectors;
the setting module is further configured to use M6 as the count value corresponding to the any storage block if M5+1 is M6, and use M5 as the count value corresponding to the any storage block if M5+1 is M6 is not M.
A detection module further configured to:
taking the last data in the first sector of the two adjacent sectors as M4, and detecting whether M3 exists in the data in the first sector of the two adjacent sectors before M4, wherein M4 is M3+ 1;
if M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is valid;
if M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data arranged one bit before M4 in the preceding sector of the two adjacent sectors is M4, and the step of detecting whether M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors is performed, wherein M4 is M3+1, until when M4 is the positive second data in the preceding sector of the two adjacent sectors, and M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, the data in the preceding sector of the two adjacent sectors is determined to be invalid.
The specific embodiment of the answer protection monotonic counter of the present invention is substantially the same as the embodiments of the method for managing the count value of the answer protection monotonic counter, and will not be described herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for causing a terminal device to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (4)

1. A method of managing a count value of a replay protection monotonic counter, wherein the replay protection monotonic counter comprises eFlash, the eFlash comprising 4 memory blocks, each of the memory blocks comprising 4 sectors, the method of managing a count value of a replay protection monotonic counter comprising:
when the power-on condition is met, detecting whether data exists in 4 sectors of any one of 4 storage blocks;
when only one sector of the 4 sectors of any storage block has data, taking the last data in the sector as M2, and detecting whether M1 exists in the data arranged before M2 in the sector, wherein M2 is M1+ 1;
if M1 exists in the data arranged before M2 in the sector, setting M2 as the count value corresponding to any storage block;
if M1 does not exist in the data arranged before M2 in the one sector, taking the data arranged one bit before M2 in the one sector as M2, and performing the step of detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+1, until when M2 is the second data counted positively in the one sector and M1 does not exist in the data arranged before M2 in the one sector, setting the first data counted positively in the one sector as the count value corresponding to any memory block;
when two adjacent sectors exist in the 4 sectors of any storage block, detecting whether data in the prior sector in the two adjacent sectors are valid;
if the data in the sector arranged in front of the two adjacent sectors are invalid, taking the positive first data in the sector arranged in back of the two adjacent sectors as the count value corresponding to any storage block;
if the data in the preceding sector of the two adjacent sectors is valid, taking the first last data in the preceding sector of the two adjacent sectors as M5, taking the first positive data in the following sector of the two adjacent sectors as M6, and judging whether M5+1 is M6;
if M5+1 is M6, M6 is used as the count value corresponding to the above-mentioned any memory block, and if M5+1 is M6 is not M, M5 is used as the count value corresponding to the above-mentioned any memory block.
2. The method of managing the count value of the answer protection monotonic counter of claim 1, wherein the detecting whether data in a preceding sector of the two adjacent sectors is valid comprises:
taking the last data in the first sector of the two adjacent sectors as M4, and detecting whether M3 exists in the data in the first sector of the two adjacent sectors before M4, wherein M4 is M3+ 1;
if M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is valid;
if M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, setting the data arranged one bit before M4 in the preceding sector of the two adjacent sectors as M4, and performing the step of detecting whether M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, wherein M4 is M3+1, until when M4 is the positive second data in the preceding sector of the two adjacent sectors and M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is invalid.
3. An answer protection monotonic counter, wherein the answer protection monotonic counter comprises:
the flash comprises 4 storage blocks, each storage block comprises 4 sectors, and the sectors are used for storing counting data;
the detection module is used for detecting whether data exists in 4 sectors of any one of the 4 storage blocks when the power-on condition is met;
the detection module is further used for taking the last-but-one data in one sector as M2 when only one sector of the 4 sectors of any storage block has data, and detecting whether M1 exists in the data arranged before M2 in the one sector, wherein M2 is M1+ 1;
a setting module, configured to set M2 as a count value corresponding to any one of the storage blocks if M1 exists in data arranged before M2 in the one sector;
a step jumping module, configured to, if M1 does not exist in data arranged in the one sector before M2, use data arranged in the one sector before M2 as M2, and perform the step of detecting whether M1 exists in data arranged in the one sector before M2, where M2 is M1+1, until when M2 is second data counted positively in the one sector and M1 does not exist in data arranged in the one sector before M2, set first data counted positively in the one sector as a count value corresponding to any memory block;
the detection module is further used for detecting whether the data in the sector arranged in front of the two adjacent sectors is valid or not when the data exists in the two adjacent sectors in the 4 sectors of any storage block;
the setting module is further configured to use positive first data in a sector arranged after the two adjacent sectors as a count value corresponding to the any storage block if data in a sector arranged before the two adjacent sectors are invalid;
the detection module is further configured to, if the data in the preceding sector of the two adjacent sectors is valid, determine that M5+1 is M6, where M5 is the first data from the last sector of the two adjacent sectors, and M6 is the first data from the last sector of the two adjacent sectors;
the setting module is further configured to use M6 as the count value corresponding to the any storage block if M5+1 is M6, and use M5 as the count value corresponding to the any storage block if M5+1 is M6 is not M.
4. The answer protection monotonic counter of claim 3, wherein the detection module is further configured to:
taking the last data in the first sector of the two adjacent sectors as M4, and detecting whether M3 exists in the data in the first sector of the two adjacent sectors before M4, wherein M4 is M3+ 1;
if M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is valid;
if M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, setting the data arranged one bit before M4 in the preceding sector of the two adjacent sectors as M4, and performing the step of detecting whether M3 exists in the data arranged before M4 in the preceding sector of the two adjacent sectors, wherein M4 is M3+1, until when M4 is the positive second data in the preceding sector of the two adjacent sectors and M3 does not exist in the data arranged before M4 in the preceding sector of the two adjacent sectors, determining that the data in the preceding sector of the two adjacent sectors is invalid.
CN202010366817.6A 2020-04-30 2020-04-30 Answer protection monotonic counter and method for managing count value thereof Active CN111261214B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010366817.6A CN111261214B (en) 2020-04-30 2020-04-30 Answer protection monotonic counter and method for managing count value thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010366817.6A CN111261214B (en) 2020-04-30 2020-04-30 Answer protection monotonic counter and method for managing count value thereof

Publications (2)

Publication Number Publication Date
CN111261214A CN111261214A (en) 2020-06-09
CN111261214B true CN111261214B (en) 2020-08-07

Family

ID=70951689

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010366817.6A Active CN111261214B (en) 2020-04-30 2020-04-30 Answer protection monotonic counter and method for managing count value thereof

Country Status (1)

Country Link
CN (1) CN111261214B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112582008A (en) * 2020-12-11 2021-03-30 武汉新芯集成电路制造有限公司 Monotonic counter and method of operating the same
CN112582009B (en) * 2020-12-11 2022-06-21 武汉新芯集成电路制造有限公司 Monotonic counter and counting method thereof

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101122887A (en) * 2007-01-17 2008-02-13 晶天电子(深圳)有限公司 Flash-memory card for caching a hard disk drive with data-area toggling of pointers
CN102509046A (en) * 2010-11-02 2012-06-20 微软公司 Globally valid measured operating system launch with hibernation support
CN104484624A (en) * 2014-12-15 2015-04-01 上海新储集成电路有限公司 Monotonous counter and monotonous counting method
CN104657678A (en) * 2013-11-19 2015-05-27 北京兆易创新科技股份有限公司 Replay protection monotonic counter, reading method and counting method thereof
CN105095772A (en) * 2014-05-19 2015-11-25 英特尔公司 Method and apparatus for securely saving and restoring the state of a computing platform

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1700642A (en) * 2005-05-25 2005-11-23 北京兆日科技有限责任公司 A method for implementing monotone counter
US8184812B2 (en) * 2009-06-03 2012-05-22 Freescale Semiconductor, Inc. Secure computing device with monotonic counter and method therefor
US9405707B2 (en) * 2011-12-20 2016-08-02 Intel Corporation Secure replay protected storage
US10860500B2 (en) * 2019-01-28 2020-12-08 Intel Corporation System, apparatus and method for replay protection for a platform component

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101122887A (en) * 2007-01-17 2008-02-13 晶天电子(深圳)有限公司 Flash-memory card for caching a hard disk drive with data-area toggling of pointers
CN102509046A (en) * 2010-11-02 2012-06-20 微软公司 Globally valid measured operating system launch with hibernation support
CN104657678A (en) * 2013-11-19 2015-05-27 北京兆易创新科技股份有限公司 Replay protection monotonic counter, reading method and counting method thereof
CN105095772A (en) * 2014-05-19 2015-11-25 英特尔公司 Method and apparatus for securely saving and restoring the state of a computing platform
CN104484624A (en) * 2014-12-15 2015-04-01 上海新储集成电路有限公司 Monotonous counter and monotonous counting method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于可信平台模块的虚拟单调计数器研究;李昊 等;《计算机研究与发展》;20111231;第48卷(第3期);第415-422页 *

Also Published As

Publication number Publication date
CN111261214A (en) 2020-06-09

Similar Documents

Publication Publication Date Title
CN102750191B (en) For starting the method for the refresh operation in solid state, non-volatile memory
CN111261214B (en) Answer protection monotonic counter and method for managing count value thereof
CN106227625A (en) The restoration methods of a kind of flash data damaged because of power down and system
CN109685190B (en) Power-down protection method and device for IC card
CN109496292A (en) A kind of disk management method, disk management device and electronic equipment
US7788550B2 (en) Redundant bit patterns for column defects coding
CN111857600B (en) Data reading and writing method and device
CN114005476A (en) Flash memory, flash memory erasing and writing counting method, electronic equipment and computer storage medium
EP3057100A1 (en) Memory device and operating method of same
CN113194161A (en) Method and device for setting MMIO base address of server system
US7685356B2 (en) Chronological identification in flash memory using cyclic numbers
EP3404662B1 (en) A method and system for implementing a non-volatile counter using non-volatile memory
US9558110B2 (en) Method for managing a flash memory
CN105335095A (en) Flash file system processing method and apparatus
CN110008059B (en) Data updating method and device for nonvolatile storage medium and storage medium
CN114300026A (en) Monotonic counter, counting method, electronic device and storage medium
CN107301073B (en) Configuration information retrieval method and device based on solid state disk system
CN107515828B (en) Data reading and writing method and mobile terminal
KR100575657B1 (en) Method for reading nand flash
KR100525537B1 (en) Applied Program Bungle Detection Apparatus and Method by Interrupt
CN114328283B (en) Counting address acquisition method, counting method, device, equipment and storage medium
US20170337104A1 (en) Counter in a flash memory
CN116610269B (en) Data storage method, device, storage medium and controller
CN110888596B (en) File erasing method and device for Flash storage area
CN102103891B (en) Chip parameter identification method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address

Address after: 518000 Room 101, building 10, Dayun software Town, 8288 Longgang Avenue, he'ao community, Yuanshan street, Longgang District, Shenzhen City, Guangdong Province

Patentee after: XTX Technology Inc.

Address before: Floor 1, building 10, Dayun software Town, No. 8288, Henggang street, Longgang District, Shenzhen City, Guangdong Province

Patentee before: Paragon Technology (Shenzhen) Ltd.

CP03 Change of name, title or address