summary refs log tree commit diff
path: root/crypto/src/math
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2018-09-25 21:55:19 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2018-09-25 21:55:19 +0700
commit04e57f9ff6d5f18189e7bfe322caa63d4a8fde0b (patch)
tree22b203e95a776919513ef637736205606494e6f7 /crypto/src/math
parentPort of SM4 from Java API (diff)
downloadBouncyCastle.NET-ed25519-04e57f9ff6d5f18189e7bfe322caa63d4a8fde0b.tar.xz
RFC 8032: Avoid unnecessary doublings in precomputation
Diffstat (limited to 'crypto/src/math')
-rw-r--r--crypto/src/math/ec/rfc8032/Ed25519.cs7
-rw-r--r--crypto/src/math/ec/rfc8032/Ed448.cs7
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);
+                        }
                     }
                 }