diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2018-09-25 21:55:19 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2018-09-25 21:55:19 +0700 |
commit | 04e57f9ff6d5f18189e7bfe322caa63d4a8fde0b (patch) | |
tree | 22b203e95a776919513ef637736205606494e6f7 | |
parent | Port of SM4 from Java API (diff) | |
download | BouncyCastle.NET-ed25519-04e57f9ff6d5f18189e7bfe322caa63d4a8fde0b.tar.xz |
RFC 8032: Avoid unnecessary doublings in precomputation
-rw-r--r-- | crypto/src/math/ec/rfc8032/Ed25519.cs | 7 | ||||
-rw-r--r-- | crypto/src/math/ec/rfc8032/Ed448.cs | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/crypto/src/math/ec/rfc8032/Ed25519.cs b/crypto/src/math/ec/rfc8032/Ed25519.cs index 2dd9e2f6f..f9ba1ff97 100644 --- a/crypto/src/math/ec/rfc8032/Ed25519.cs +++ b/crypto/src/math/ec/rfc8032/Ed25519.cs @@ -670,9 +670,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 ds[t] = PointCopy(p); - for (int s = 1; s < PrecompSpacing; ++s) + if (b + t != PrecompBlocks + PrecompTeeth - 2) { - PointDouble(p); + for (int s = 1; s < PrecompSpacing; ++s) + { + PointDouble(p); + } } } diff --git a/crypto/src/math/ec/rfc8032/Ed448.cs b/crypto/src/math/ec/rfc8032/Ed448.cs index f12aa0807..a1f0e93b0 100644 --- a/crypto/src/math/ec/rfc8032/Ed448.cs +++ b/crypto/src/math/ec/rfc8032/Ed448.cs @@ -622,9 +622,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 ds[t] = PointCopy(p); - for (int s = 1; s < PrecompSpacing; ++s) + if (b + t != PrecompBlocks + PrecompTeeth - 2) { - PointDouble(p); + for (int s = 1; s < PrecompSpacing; ++s) + { + PointDouble(p); + } } } |