summary refs log tree commit diff
path: root/crypto/src/math/ec/multiplier/FixedPointUtilities.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-04-10 10:16:31 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-04-10 10:16:31 +0700
commit7778cd8e510731146b4ef597787552c162dae29d (patch)
treefe8275adffd3114134d8d2c89b6e00025060c8be /crypto/src/math/ec/multiplier/FixedPointUtilities.cs
parentPort from Java many of the new TLS classes and a few minor changes (diff)
downloadBouncyCastle.NET-ed25519-7778cd8e510731146b4ef597787552c162dae29d.tar.xz
Fixed-point-comb uses existing precomputation info if it's for the same _or greater_ width as requested release-1.8.0-beta.3
Diffstat (limited to 'crypto/src/math/ec/multiplier/FixedPointUtilities.cs')
-rw-r--r--crypto/src/math/ec/multiplier/FixedPointUtilities.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crypto/src/math/ec/multiplier/FixedPointUtilities.cs b/crypto/src/math/ec/multiplier/FixedPointUtilities.cs

index 194995e08..d927d010b 100644 --- a/crypto/src/math/ec/multiplier/FixedPointUtilities.cs +++ b/crypto/src/math/ec/multiplier/FixedPointUtilities.cs
@@ -22,22 +22,22 @@ namespace Org.BouncyCastle.Math.EC.Multiplier return new FixedPointPreCompInfo(); } - public static FixedPointPreCompInfo Precompute(ECPoint p, int width) + public static FixedPointPreCompInfo Precompute(ECPoint p, int minWidth) { ECCurve c = p.Curve; - int n = 1 << width; + int n = 1 << minWidth; FixedPointPreCompInfo info = GetFixedPointPreCompInfo(c.GetPreCompInfo(p, PRECOMP_NAME)); ECPoint[] lookupTable = info.PreComp; - if (lookupTable == null || lookupTable.Length != n) + if (lookupTable == null || lookupTable.Length < n) { int bits = GetCombSize(c); - int d = (bits + width - 1) / width; + int d = (bits + minWidth - 1) / minWidth; - ECPoint[] pow2Table = new ECPoint[width]; + ECPoint[] pow2Table = new ECPoint[minWidth]; pow2Table[0] = p; - for (int i = 1; i < width; ++i) + for (int i = 1; i < minWidth; ++i) { pow2Table[i] = pow2Table[i - 1].TimesPow2(d); } @@ -47,7 +47,7 @@ namespace Org.BouncyCastle.Math.EC.Multiplier lookupTable = new ECPoint[n]; lookupTable[0] = c.Infinity; - for (int bit = width - 1; bit >= 0; --bit) + for (int bit = minWidth - 1; bit >= 0; --bit) { ECPoint pow2 = pow2Table[bit]; @@ -61,6 +61,7 @@ namespace Org.BouncyCastle.Math.EC.Multiplier c.NormalizeAll(lookupTable); info.PreComp = lookupTable; + info.Width = minWidth; c.SetPreCompInfo(p, PRECOMP_NAME, info); }