Skip to content

Commit 9faebd8

Browse files
committed
Add BIsZero_Static37
1 parent 036d4ba commit 9faebd8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Classes/FCryptoBigInt.uc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,9 +1256,7 @@ static final function ToMonty(
12561256
* This function is called "BIsZero" because
12571257
* "IsZero" would clash with Object::IsZero.
12581258
*/
1259-
static final function int BIsZero(
1260-
const out array<int> X
1261-
)
1259+
static final function int BIsZero(const out array<int> X)
12621260
{
12631261
local int Z;
12641262
local int U;
@@ -1271,6 +1269,18 @@ static final function int BIsZero(
12711269
return ~(Z | -Z) >>> 31;
12721270
}
12731271

1272+
static final function int BIsZero_Static37(const out int X[37])
1273+
{
1274+
local int Z;
1275+
local int U;
1276+
1277+
Z = 0;
1278+
for (U = (X[0] + 15) >>> 4; U > 0; --U)
1279+
{
1280+
Z = Z | X[U];
1281+
}
1282+
return ~(Z | -Z) >>> 31;
1283+
}
12741284

12751285
/*
12761286
* Negate big integer conditionally. The value consists of 'len' words,

Classes/FCryptoEC_Prime.uc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ static final function int RunCode(
283283
case 4:
284284
break;
285285
default:
286-
// TODO: need static variant for this too.
287-
// R = R & (class'FCryptoBigInt'.static.BIsZero(T[D]));
286+
R = R & class'FCryptoBigInt'.static.BIsZero_Static37(T[D].X);
288287
break;
289288
}
290289
}

0 commit comments

Comments
 (0)