diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-07 12:56:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-07 12:56:46 +0700 |
commit | c89dd16807951633fce1e2e7d34858868a4ca076 (patch) | |
tree | c9fd16a709023572e008fd5ddac86d423ad82cd6 /crypto/src/math/ec/ECCurve.cs | |
parent | Update OCB draft references (diff) | |
download | BouncyCastle.NET-ed25519-c89dd16807951633fce1e2e7d34858868a4ca076.tar.xz |
Index precomputation info by name
Diffstat (limited to 'crypto/src/math/ec/ECCurve.cs')
-rw-r--r-- | crypto/src/math/ec/ECCurve.cs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/crypto/src/math/ec/ECCurve.cs b/crypto/src/math/ec/ECCurve.cs index 82cf1367b..5c7592a92 100644 --- a/crypto/src/math/ec/ECCurve.cs +++ b/crypto/src/math/ec/ECCurve.cs @@ -116,26 +116,40 @@ namespace Org.BouncyCastle.Math.EC return coord == COORD_AFFINE; } - public virtual PreCompInfo GetPreCompInfo(ECPoint p) + public virtual PreCompInfo GetPreCompInfo(ECPoint point, string name) { - CheckPoint(p); - return p.m_preCompInfo; + CheckPoint(point); + lock (point) + { + IDictionary table = point.m_preCompTable; + return table == null ? null : (PreCompInfo)table[name]; + } } /** - * Sets the <code>PreCompInfo</code> for a point on this curve. Used by + * Adds <code>PreCompInfo</code> for a point on this curve, under a given name. Used by * <code>ECMultiplier</code>s to save the precomputation for this <code>ECPoint</code> for use * by subsequent multiplication. * * @param point * The <code>ECPoint</code> to store precomputations for. + * @param name + * A <code>String</code> used to index precomputations of different types. * @param preCompInfo * The values precomputed by the <code>ECMultiplier</code>. */ - public virtual void SetPreCompInfo(ECPoint point, PreCompInfo preCompInfo) + public virtual void SetPreCompInfo(ECPoint point, string name, PreCompInfo preCompInfo) { CheckPoint(point); - point.m_preCompInfo = preCompInfo; + lock (point) + { + IDictionary table = point.m_preCompTable; + if (null == table) + { + point.m_preCompTable = table = Platform.CreateHashtable(4); + } + table[name] = preCompInfo; + } } public virtual ECPoint ImportPoint(ECPoint p) |