diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-03-10 18:49:59 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-03-10 18:49:59 +0700 |
commit | 14fc40083d81fda4598efbf8f9fd29c71d825adb (patch) | |
tree | 7542e7901435791043fcfc5c4f346fb2ceecbf1a /crypto/src/math/ec/custom/sec/SecP256R1Field.cs | |
parent | Refactor temporary variables in reductions (diff) | |
download | BouncyCastle.NET-ed25519-14fc40083d81fda4598efbf8f9fd29c71d825adb.tar.xz |
Add MultiplyAddToExt method to fields
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP256R1Field.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP256R1Field.cs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs index 1ae07f341..9ed9dcd41 100644 --- a/crypto/src/math/ec/custom/sec/SecP256R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP256R1Field.cs @@ -11,8 +11,8 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec internal static readonly uint[] PExt = new uint[]{ 0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0x00000001, 0xFFFFFFFE, 0x00000001, 0xFFFFFFFE, 0x00000001, 0x00000001, 0xFFFFFFFE, 0x00000002, 0xFFFFFFFE }; - private const uint P7 = 0xFFFFFFFF; - private const uint PExt15 = 0xFFFFFFFE; + internal const uint P7 = 0xFFFFFFFF; + internal const uint PExt15 = 0xFFFFFFFE; public static void Add(uint[] x, uint[] y, uint[] z) { @@ -71,6 +71,15 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec Reduce(tt, z); } + public static void MultiplyAddToExt(uint[] x, uint[] y, uint[] zz) + { + uint c = Nat256.MulAddTo(x, y, zz); + if (c != 0 || (zz[15] >= PExt15 && Nat.Gte(16, zz, PExt))) + { + Nat.SubFrom(16, PExt, zz); + } + } + public static void Negate(uint[] x, uint[] z) { if (Nat256.IsZero(x)) |