summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2014-02-27 11:16:09 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2014-02-27 11:16:09 +0700
commit5db90811abc9f90c461c611613aad65b8cc36ac4 (patch)
tree6f5b9b657ddedacbfcaac366dfbee512a7e16e4b /crypto/src
parentAdd custom curve for secp384r1 (P-384) (diff)
downloadBouncyCastle.NET-ed25519-5db90811abc9f90c461c611613aad65b8cc36ac4.tar.xz
Simplify Twice()
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/math/ec/custom/sec/SecP521R1Field.cs10
1 files changed, 3 insertions, 7 deletions
diff --git a/crypto/src/math/ec/custom/sec/SecP521R1Field.cs b/crypto/src/math/ec/custom/sec/SecP521R1Field.cs

index f57804778..7b2c7bada 100644 --- a/crypto/src/math/ec/custom/sec/SecP521R1Field.cs +++ b/crypto/src/math/ec/custom/sec/SecP521R1Field.cs
@@ -130,13 +130,9 @@ namespace Org.BouncyCastle.Math.EC.Custom.Sec public static void Twice(uint[] x, uint[] z) { - uint c = Nat.ShiftUpBit(16, x, 0, z) | (x[16] << 1); - if (c > P16 || (c == P16 && Nat.Eq(16, z, P))) - { - c += Nat.Inc(16, z, 0); - c &= P16; - } - z[16] = c; + uint x16 = x[16]; + uint c = Nat.ShiftUpBit(16, x, x16 << 23, z) | (x16 << 1); + z[16] = c & P16; } protected static void ImplMultiply(uint[] x, uint[] y, uint[] zz)