Constant time
Last updated
Last updated
Whenever you interact with secrets and cryptographic parameters, you should use constant time functions to avoid leaking information via timing to an attacker. Such leaks can completely compromise security.
For example, you should increment counters/nonces, compare tags, compare passwords, and so on using this class.
Determines if two spans are equal in length and contain equal data. It returns true
if so and false
otherwise.
a
has a length of 0.
b
has a length of 0.
Increments a span counter.
buffer
has a length of 0.
Fills a span with the sum of two spans.
buffer
has a length of 0.
a
has a length of 0 or not equal to buffer.Length
.
b
has a length of 0 or not equal to a.Length
.
Fills a span with the result of subtracting the second span from the first span.
buffer
has a length of 0.
a
has a length of 0 or not equal to buffer.Length
.
b
has a length of 0 or not equal to a.Length
.
Determines if the contents of the first span is less than the second span. It returns true
if so and false
otherwise.
a
has a length of 0 or not equal to b.Length
.
b
has a length of 0.
Determines if the contents of the first span is greater than the second span. It returns true
if so and false
otherwise.
a
has a length of 0 or not equal to b.Length
.
b
has a length of 0.
Determines if a span only contains zeros. It returns true
if so and false
otherwise.
These constant time functions can also be used for non-secret values.
MUST be compared in constant time using ConstantTime.Equals()
. The VerifyTag()
and FinalizeAndVerify()
functions do this for you.