SecurityExtensionsSecureEquals(Byte, Byte, Int32, Int32) Method

Does a time constant comparison of the two byte arrays.

Definition

Namespace: SnapDB.Security
Assembly: SnapDB (in SnapDB.dll) Version: 1.0.102.0 -- Release Build+29075351d0e5aa4dea46a5c520805222f672dc2e
public static bool SecureEquals(
	this byte[] a,
	byte[] b,
	int bPosition,
	int bLength
)

Parameters

a  Byte
The first byte array to compare.
b  Byte
The second byte array to compare.
bPosition  Int32
The start position of the b byte array.
bLength  Int32
The length of the portion to compare in b.

Return Value

Boolean
true if both arrays are equal; otherwise, false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Byte. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

If a or b is null, function returns immediately with a false. Certain cryptographic attacks can occur by comparing the amount of time it takes to do certain operations. Comparing two byte arrays is one example. Therefore this method should take constant time to do a comparison of two arrays.

See Also