diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-27 11:16:09 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2014-02-27 11:16:09 +0700 |
commit | 5db90811abc9f90c461c611613aad65b8cc36ac4 (patch) | |
tree | 6f5b9b657ddedacbfcaac366dfbee512a7e16e4b | |
parent | Add custom curve for secp384r1 (P-384) (diff) | |
download | BouncyCastle.NET-ed25519-5db90811abc9f90c461c611613aad65b8cc36ac4.tar.xz |
Simplify Twice()
-rw-r--r-- | crypto/src/math/ec/custom/sec/SecP521R1Field.cs | 10 |
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) |