diff options
Diffstat (limited to 'crypto/src/math/ec/custom/sec/SecP224R1Point.cs')
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP224R1Point.cs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP224R1Point.cs b/crypto/src/math/ec/custom/sec/SecP224R1Point.cs index 31cef6929..3b339720d 100644 --- a/crypto/src/math/ec/custom/sec/SecP224R1Point.cs +++ b/crypto/src/math/ec/custom/sec/SecP224R1Point.cs @@ -76,8 +76,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec SecP224R1FieldElement Z1 = (SecP224R1FieldElement)this.RawZCoords[0]; SecP224R1FieldElement Z2 = (SecP224R1FieldElement)b.RawZCoords[0]; + uint c; uint[] tt1 = Nat224.CreateExt(); - uint[] tt2 = Nat224.CreateExt(); + uint[] t2 = Nat224.Create(); uint[] t3 = Nat224.Create(); uint[] t4 = Nat224.Create(); @@ -93,7 +94,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec S2 = t3; SecP224R1Field.Square(Z1.x, S2); - U2 = tt2; + U2 = t2; SecP224R1Field.Multiply(S2, X2.x, U2); SecP224R1Field.Multiply(S2, Z1.x, S2); @@ -122,7 +123,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec uint[] H = Nat224.Create(); SecP224R1Field.Subtract(U1, U2, H); - uint[] R = tt2; + uint[] R = t2; SecP224R1Field.Subtract(S1, S2, R); // Check if b == this or b == -this @@ -147,19 +148,20 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec uint[] V = t3; SecP224R1Field.Multiply(HSquared, U1, V); + SecP224R1Field.Negate(G, G); Nat224.Mul(S1, G, tt1); + c = Nat224.AddBothTo(V, V, G); + SecP224R1Field.Reduce32(c, G); + SecP224R1FieldElement X3 = new SecP224R1FieldElement(t4); SecP224R1Field.Square(R, X3.x); - SecP224R1Field.Add(X3.x, G, X3.x); - SecP224R1Field.Subtract(X3.x, V, X3.x); - SecP224R1Field.Subtract(X3.x, V, X3.x); + SecP224R1Field.Subtract(X3.x, G, X3.x); SecP224R1FieldElement Y3 = new SecP224R1FieldElement(G); SecP224R1Field.Subtract(V, X3.x, Y3.x); - Nat224.Mul(Y3.x, R, tt2); - SecP224R1Field.SubtractExt(tt2, tt1, tt2); - SecP224R1Field.Reduce(tt2, Y3.x); + SecP224R1Field.MultiplyAddToExt(Y3.x, R, tt1); + SecP224R1Field.Reduce(tt1, Y3.x); SecP224R1FieldElement Z3 = new SecP224R1FieldElement(H); if (!Z1IsOne) @@ -189,6 +191,7 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec SecP224R1FieldElement X1 = (SecP224R1FieldElement)this.RawXCoord, Z1 = (SecP224R1FieldElement)this.RawZCoords[0]; + uint c; uint[] t1 = Nat224.Create(); uint[] t2 = Nat224.Create(); @@ -212,12 +215,12 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec uint[] M = t2; SecP224R1Field.Add(X1.x, Z1Squared, M); SecP224R1Field.Multiply(M, t1, M); - SecP224R1Field.Twice(M, t1); - SecP224R1Field.Add(M, t1, M); + c = Nat224.AddBothTo(M, M, M); + SecP224R1Field.Reduce32(c, M); uint[] S = Y1Squared; SecP224R1Field.Multiply(Y1Squared, X1.x, S); - uint c = Nat.ShiftUpBits(7, S, 2, 0); + c = Nat.ShiftUpBits(7, S, 2, 0); SecP224R1Field.Reduce32(c, S); c = Nat.ShiftUpBits(7, T, 3, 0, t1); |