diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-23 15:17:12 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-07-23 15:17:12 +0700 |
commit | 6e306046568f9a4d13639b913f0ff6d5879fa165 (patch) | |
tree | 994b8711674bb146ff578c1f0dff649282962acb /crypto/src/math/ec/custom/sec/SecP384R1Curve.cs | |
parent | Update encrypt_then_mac entry (diff) | |
download | BouncyCastle.NET-ed25519-6e306046568f9a4d13639b913f0ff6d5879fa165.tar.xz |
Add automatic EC point validation for decoded points and for multiplier outputs
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP384R1Curve.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP384R1Curve.cs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs b/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs index f3dec05c9..7fd58276a 100644 --- a/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs +++ b/crypto/src/math/ec/custom/sec/SecP384R1Curve.cs @@ -1,12 +1,11 @@ using System; -using Org.BouncyCastle.Math.Field; using Org.BouncyCastle.Utilities.Encoders; namespace Org.BouncyCastle.Math.EC.Custom.Sec { internal class SecP384R1Curve - : ECCurve + : AbstractFpCurve { public static readonly BigInteger q = new BigInteger(1, Hex.Decode("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF")); @@ -16,7 +15,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec protected readonly SecP384R1Point m_infinity; public SecP384R1Curve() - : base(FiniteFields.GetPrimeField(q)) + : base(q) { this.m_infinity = new SecP384R1Point(this, null, null); @@ -74,27 +73,5 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec { return new SecP384R1Point(this, x, y, zs, withCompression); } - - protected override ECPoint DecompressPoint(int yTilde, BigInteger X1) - { - ECFieldElement x = FromBigInteger(X1); - ECFieldElement alpha = x.Square().Add(A).Multiply(x).Add(B); - ECFieldElement beta = alpha.Sqrt(); - - // - // if we can't find a sqrt we haven't got a point on the - // curve - run! - // - if (beta == null) - throw new ArithmeticException("Invalid point compression"); - - if (beta.TestBitZero() != (yTilde == 1)) - { - // Use the other root - beta = beta.Negate(); - } - - return new SecP384R1Point(this, x, beta, true); - } } } |