diff --git a/crypto/src/crypto/generators/ECKeyPairGenerator.cs b/crypto/src/crypto/generators/ECKeyPairGenerator.cs
index 49afb16dc..301349a9b 100644
--- a/crypto/src/crypto/generators/ECKeyPairGenerator.cs
+++ b/crypto/src/crypto/generators/ECKeyPairGenerator.cs
@@ -105,7 +105,7 @@ namespace Org.BouncyCastle.Crypto.Generators
}
while (d.SignValue == 0 || (d.CompareTo(n) >= 0));
- ECPoint q = new FixedPointCombMultiplier().Multiply(parameters.G, d);
+ ECPoint q = CreateBasePointMultiplier().Multiply(parameters.G, d);
if (publicKeyParamSet != null)
{
@@ -119,6 +119,11 @@ namespace Org.BouncyCastle.Crypto.Generators
new ECPrivateKeyParameters(algorithm, d, parameters));
}
+ protected virtual ECMultiplier CreateBasePointMultiplier()
+ {
+ return new FixedPointCombMultiplier();
+ }
+
internal static X9ECParameters FindECCurveByOid(DerObjectIdentifier oid)
{
// TODO ECGost3410NamedCurves support (returns ECDomainParameters though)
diff --git a/crypto/src/crypto/signers/ECDsaSigner.cs b/crypto/src/crypto/signers/ECDsaSigner.cs
index dc9c3dc87..508335149 100644
--- a/crypto/src/crypto/signers/ECDsaSigner.cs
+++ b/crypto/src/crypto/signers/ECDsaSigner.cs
@@ -67,12 +67,12 @@ namespace Org.BouncyCastle.Crypto.Signers
{
ECDomainParameters ec = key.Parameters;
BigInteger n = ec.N;
- BigInteger e = calculateE(n, message);
+ BigInteger e = CalculateE(n, message);
BigInteger d = ((ECPrivateKeyParameters)key).D;
BigInteger r, s;
- ECMultiplier basePointMultiplier = new FixedPointCombMultiplier();
+ ECMultiplier basePointMultiplier = CreateBasePointMultiplier();
// 5.3.2
do // Generate s
@@ -120,7 +120,7 @@ namespace Org.BouncyCastle.Crypto.Signers
return false;
}
- BigInteger e = calculateE(n, message);
+ BigInteger e = CalculateE(n, message);
BigInteger c = s.ModInverse(n);
BigInteger u1 = e.Multiply(c).Mod(n);
@@ -139,9 +139,7 @@ namespace Org.BouncyCastle.Crypto.Signers
return v.Equals(r);
}
- private BigInteger calculateE(
- BigInteger n,
- byte[] message)
+ protected virtual BigInteger CalculateE(BigInteger n, byte[] message)
{
int messageBitLength = message.Length * 8;
BigInteger trunc = new BigInteger(1, message);
@@ -153,5 +151,10 @@ namespace Org.BouncyCastle.Crypto.Signers
return trunc;
}
+
+ protected virtual ECMultiplier CreateBasePointMultiplier()
+ {
+ return new FixedPointCombMultiplier();
+ }
}
}
diff --git a/crypto/src/crypto/signers/ECGOST3410Signer.cs b/crypto/src/crypto/signers/ECGOST3410Signer.cs
index 872336d87..6027aa9b9 100644
--- a/crypto/src/crypto/signers/ECGOST3410Signer.cs
+++ b/crypto/src/crypto/signers/ECGOST3410Signer.cs
@@ -79,7 +79,7 @@ namespace Org.BouncyCastle.Crypto.Signers
BigInteger r, s = null;
- ECMultiplier basePointMultiplier = new FixedPointCombMultiplier();
+ ECMultiplier basePointMultiplier = CreateBasePointMultiplier();
do // generate s
{
@@ -153,5 +153,10 @@ namespace Org.BouncyCastle.Crypto.Signers
return R.Equals(r);
}
+
+ protected virtual ECMultiplier CreateBasePointMultiplier()
+ {
+ return new FixedPointCombMultiplier();
+ }
}
}
|