diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-11 23:54:37 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-11 23:54:37 +0700 |
commit | 937aa8662a743eda26c1a54562d132dbeff6f917 (patch) | |
tree | e6130574a6541b339af123c316696739b51dff64 | |
parent | Increase seed size for DigestRandomGenerator uses (diff) | |
download | BouncyCastle.NET-ed25519-937aa8662a743eda26c1a54562d132dbeff6f917.tar.xz |
Refactor Wnaf
-rw-r--r-- | crypto/src/math/ec/rfc8032/Wnaf.cs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crypto/src/math/ec/rfc8032/Wnaf.cs b/crypto/src/math/ec/rfc8032/Wnaf.cs index 1b7d1465d..88319f405 100644 --- a/crypto/src/math/ec/rfc8032/Wnaf.cs +++ b/crypto/src/math/ec/rfc8032/Wnaf.cs @@ -33,25 +33,24 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 } } - uint sign = 0U; - int j = 0, lead = 32 - width; + int j = 0, lead = 32 - width, sign = 0; for (int i = 0; i < t.Length; ++i, j -= 16) { uint word = t[i]; while (j < 16) { - uint word16 = word >> j; + int word16 = (int)(word >> j); - int skip = Integers.NumberOfTrailingZeros((int)((sign ^ word16) | 0xFFFF0000U)); + int skip = Integers.NumberOfTrailingZeros((sign ^ word16) | 0x00010000); if (skip > 0) { j += skip; continue; } - int digit = ((int)word16 | 1) << lead; - sign = (uint)(digit >> 31); + int digit = (word16 | 1) << lead; + sign = digit >> 31; ws[(i << 4) + j] = (sbyte)(digit >> lead); @@ -59,7 +58,7 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 } } - Debug.Assert((int)sign == (int)n[n.Length - 1] >> 31); + Debug.Assert(sign == (int)n[n.Length - 1] >> 31); } } } |