From 04e57f9ff6d5f18189e7bfe322caa63d4a8fde0b Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 25 Sep 2018 21:55:19 +0700 Subject: RFC 8032: Avoid unnecessary doublings in precomputation --- crypto/src/math/ec/rfc8032/Ed25519.cs | 7 +++++-- crypto/src/math/ec/rfc8032/Ed448.cs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'crypto/src/math/ec/rfc8032') 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); + } } } -- cgit 1.4.1