CryptographicOperations.FixedTimeEquals Method

Definition

Overloads

Name Description
FixedTimeEquals(ReadOnlySpan<Byte>, Byte)
FixedTimeEquals(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>)

Determines the equality of two byte sequences in an amount of time that depends on the length of the sequences, but not their values.

FixedTimeEquals(ReadOnlySpan<Byte>, Byte)

Source:
CryptographicOperations.cs
public:
 static bool FixedTimeEquals(ReadOnlySpan<System::Byte> source, System::Byte value);
public static bool FixedTimeEquals(ReadOnlySpan<byte> source, byte value);
static member FixedTimeEquals : ReadOnlySpan<byte> * byte -> bool
Public Shared Function FixedTimeEquals (source As ReadOnlySpan(Of Byte), value As Byte) As Boolean

Parameters

source
ReadOnlySpan<Byte>
value
Byte

Returns

Applies to

FixedTimeEquals(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>)

Source:
CryptographicOperations.cs
Source:
CryptographicOperations.cs
Source:
CryptographicOperations.cs
Source:
CryptographicOperations.cs
Source:
CryptographicOperations.cs

Determines the equality of two byte sequences in an amount of time that depends on the length of the sequences, but not their values.

public:
 static bool FixedTimeEquals(ReadOnlySpan<System::Byte> left, ReadOnlySpan<System::Byte> right);
public static bool FixedTimeEquals(ReadOnlySpan<byte> left, ReadOnlySpan<byte> right);
static member FixedTimeEquals : ReadOnlySpan<byte> * ReadOnlySpan<byte> -> bool
Public Shared Function FixedTimeEquals (left As ReadOnlySpan(Of Byte), right As ReadOnlySpan(Of Byte)) As Boolean

Parameters

left
ReadOnlySpan<Byte>

The first buffer to compare.

right
ReadOnlySpan<Byte>

The second buffer to compare.

Returns

true if left and right have the same values for Length and the same contents; otherwise, false.

Remarks

This method compares the contents from two buffers for equality in a way that doesn't leak timing information, making it ideal for use within cryptographic routines.

This method will short-circuit and return false only if left and right have different lengths.

Fixed-time behavior is guaranteed in all other cases, including when left and right reference the same address.

Applies to