From 8cc2da3a37a777927f9d683b0b57bfffcc8195c9 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 2 Mar 2023 22:53:02 +0700 Subject: BIKE refactoring --- crypto/src/util/Arrays.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'crypto/src/util') diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs index a9ae6724a..da74d467a 100644 --- a/crypto/src/util/Arrays.cs +++ b/crypto/src/util/Arrays.cs @@ -97,6 +97,24 @@ namespace Org.BouncyCastle.Utilities return true; } + [CLSCompliant(false)] + public static bool AreEqual(ulong[] a, int aFromIndex, int aToIndex, ulong[] b, int bFromIndex, int bToIndex) + { + int aLength = aToIndex - aFromIndex; + int bLength = bToIndex - bFromIndex; + + if (aLength != bLength) + return false; + + for (int i = 0; i < aLength; ++i) + { + if (a[aFromIndex + i] != b[bFromIndex + i]) + return false; + } + + return true; + } + [Obsolete("Use 'FixedTimeEquals' instead")] public static bool ConstantTimeAreEqual(byte[] a, byte[] b) { -- cgit 1.4.1