Split counters with dynamic epoch tracking for cryptographic protection of secure data
Aspects and implementations include systems and techniques for efficient protection of secret data against replay attacks, including updating a unit of data of a plurality of units of data, updating an individual portion of a counter for the unit of data, the counter including an individual portion and a common portion, accessing a pointer value that distinguishes counters corresponding to a first epoch from counters corresponding to a second epoch, selecting, based on at least the pointer value and a value of the individual portion of the counter, an update value, and modifying the pointer value using the update value.
1 . A method to perform a cryptographic operation, the method comprising:
updating, using a processing device, a first unit of data of a plurality of units of data;
updating, using the processing device, an individual portion of a first counter of a plurality of counters, wherein each of the plurality of counters is associated with a corresponding unit of data of the plurality of units of data and comprises:
an individual portion of a respective counter, and
a common portion shared by the plurality of counters;
accessing, using the processing device, a pointer value that distinguishes a first subset of the plurality of counters corresponding to a first epoch for the common portion from a second subset of the plurality of counters corresponding to a second epoch for the common portion;
selecting, using the processing device, based on at least the pointer value and a value of the individual portion of the first counter, an update value; and
modifying, using the processing device, the pointer value using the update value, wherein the update value comprises a number of one or more counters re-assigned from the first subset of the plurality of counters to the second subset of the plurality of counters.
2 . The method of claim 1 , wherein the plurality of counters is associated with a top level of a tree of counters, wherein the tree of counters comprises two or more levels, and wherein a bottom level of the tree of counters comprises one or more root counters stored in a secure memory location.
3 . The method of claim 2 , where the secure memory location is in an on-chip memory.
4 . The method of claim 2 , wherein updating the individual portion of the first counter comprises incrementing the value of the individual portion of the first counter.
5 . The method of claim 1 , further comprising:
accessing a second unit of data of the plurality of units of data;
accessing a message authentication code (MAC) for the second unit of data;
determining, using the pointer value, a value of a second counter of the plurality of counters, wherein the second counter is associated with the second unit of data; and
determining, using the MAC and the value of the second counter, whether integrity of the second unit of data has been breached.
6 . The method of claim 5 , wherein the value of the second counter is one of:
a value of an individual portion of the second counter concatenated with a value of the common portion, provided that the second counter is associated with the first epoch; or
the value of the individual portion of the second counter concatenated with an incremented value of the common portion, provided that the second counter is associated with the second epoch.
7 . The method of claim 5 , wherein the value of the second counter is one of:
a value of an individual portion of the second counter added to a rescaled value of the common portion, provided that the second counter is associated with the first epoch; or
the value of the individual portion of the second counter added to a rescaled incremented value of the common portion, when the second counter is associated with the second epoch.
8 . The method of claim 1 , further comprising:
responsive to modifying the pointer value, identifying the one or more counters of the first subset that have been reassigned to the second subset;
accessing one or more units of data associated with the one or more reassigned counters; and
computing one or more message authentication codes (MACs) for the one or more units of data.
9 . The method of claim 8 , wherein computing each of the one or more MACs comprises re-encrypting a respective unit of the one or more units of data in view of a value of a respective counter of the one or more identified counters.
10 . The method of claim 8 , further comprising:
computing a message authentication code (MAC) for the first unit of data; and
computing, using the MAC for the first unit of data and the one or more MACs for the one or more units of data, a MAC for the plurality of counters.
11 . The method of claim 1 , wherein selecting the update value is further based on a difference between a maximum value that can be stored in the individual portion of the first counter and the value of the individual portion of the first counter.
12 . The method of claim 11 , wherein the update value is selected from a set of values not exceeding four.
13 . A system comprising:
a memory system; and
a processing device operatively coupled to the memory system, the processing device to:
update a first unit of data of a plurality of units of data;
update an individual portion of a first counter of a plurality of counters, wherein each of the plurality of counters is associated with a corresponding unit of data of the plurality of units of data and comprises:
an individual portion of a respective counter, and
a common portion shared by the plurality of counters;
access a pointer value that distinguishes a first subset of the plurality of counters corresponding to a first epoch for the common portion from a second subset of the plurality of counters corresponding to a second epoch for the common portion;
select, based on at least the pointer value and a value of the individual portion of the first counter, an update value; and
modify the pointer value using the update value, wherein the update value comprises a number of one or more counters re-assigned from the first subset of the plurality of counters to the second subset of the plurality of counters.
14 . The system of claim 13 , wherein to update the individual portion of the first counter, the processing device is to increment the value of the individual portion of the first counter.
15 . The system of claim 13 , wherein the processing device is further to:
access a second unit of data of the plurality of units of data;
access a message authentication code (MAC) for the second unit of data;
determine, using the pointer value, a value of a second counter of the plurality of counters, wherein the second counter is associated with the second unit of data; and
determine, using the MAC and the value of the second counter, whether integrity of the second unit of data has been breached.
16 . The system of claim 13 , wherein the processing device is further to:
identify the one or more counters of the first subset that have been reassigned to the second subset;
access one or more units of data associated with the one or more reassigned counters; and
compute one or more message authentication codes (MACs) for the one or more units of data.
17 . The system of claim 16 , wherein to compute each of the one or more MACs, the processing device is to re-encrypt a respective unit of the one or more units of data in view of a value of a respective counter of the one or more identified counters.
18 . The system of claim 16 , wherein the processing device is further to:
compute a message authentication code (MAC) for the first unit of data; and
compute, using the MAC for the first unit of data and the one or more MACs for the one or more units of data, a MAC for the plurality of counters.
19 . The system of claim 13 , wherein the processing device to select the update value further based on a difference between a maximum value that can be stored in the individual portion of the first counter and the value of the individual portion of the first counter.
20 . A non-transitory computer-readable storage medium storing instructions thereon that, when executed by a processing device, cause the processing device to:
update a first unit of data of a plurality of units of data;
update an individual portion of a first counter of a plurality of counters, wherein each of the plurality of counters is associated with a corresponding unit of data of the plurality of units of data and comprises:
an individual portion of a respective counter, and a common portion shared by the plurality of counters;
access a pointer value that distinguishes a first subset of the plurality of counters corresponding to a first epoch for the common portion from a second subset of the plurality of counters corresponding to a second epoch for the common portion;
select, based on at least the pointer value and a value of the individual portion of the first counter, an update value; and
modify the pointer value using the update value, wherein the update value comprises a number of one or more counters re-assigned from the first subset of the plurality of counters to the second subset of the plurality of counters.