From 9faebd8078d8efb7a779681635ed0a0f214ef1c3 Mon Sep 17 00:00:00 2001 From: Tuomo Kriikkula Date: Sun, 11 Aug 2024 00:09:29 +0300 Subject: [PATCH] Add BIsZero_Static37 --- Classes/FCryptoBigInt.uc | 16 +++++++++++++--- Classes/FCryptoEC_Prime.uc | 3 +-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Classes/FCryptoBigInt.uc b/Classes/FCryptoBigInt.uc index 7fb53c5..757216c 100644 --- a/Classes/FCryptoBigInt.uc +++ b/Classes/FCryptoBigInt.uc @@ -1256,9 +1256,7 @@ static final function ToMonty( * This function is called "BIsZero" because * "IsZero" would clash with Object::IsZero. */ -static final function int BIsZero( - const out array X -) +static final function int BIsZero(const out array X) { local int Z; local int U; @@ -1271,6 +1269,18 @@ static final function int BIsZero( return ~(Z | -Z) >>> 31; } +static final function int BIsZero_Static37(const out int X[37]) +{ + local int Z; + local int U; + + Z = 0; + for (U = (X[0] + 15) >>> 4; U > 0; --U) + { + Z = Z | X[U]; + } + return ~(Z | -Z) >>> 31; +} /* * Negate big integer conditionally. The value consists of 'len' words, diff --git a/Classes/FCryptoEC_Prime.uc b/Classes/FCryptoEC_Prime.uc index 445f8b6..7cf0949 100644 --- a/Classes/FCryptoEC_Prime.uc +++ b/Classes/FCryptoEC_Prime.uc @@ -283,8 +283,7 @@ static final function int RunCode( case 4: break; default: - // TODO: need static variant for this too. - // R = R & (class'FCryptoBigInt'.static.BIsZero(T[D])); + R = R & class'FCryptoBigInt'.static.BIsZero_Static37(T[D].X); break; } }