summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2019-12-15 19:01:45 +0100
committerNiels Möller <nisse@lysator.liu.se>2019-12-15 19:01:45 +0100
commit0a8fb3bbf006119a3409891fcba27434d1f236fc (patch)
tree8c896a506e6985ae4b5ef7a5d51dbda1cd8d0a8f
parent5828ed16b94555ca31926a00e96ac4ac9ae06b6d (diff)
downloadnettle-0a8fb3bbf006119a3409891fcba27434d1f236fc.tar.gz
Eliminate one unneeded ecc_modp_add in ecc_dup_eh.
-rw-r--r--ChangeLog4
-rw-r--r--ecc-dup-eh.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0516a040..0f0e2173 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-12-15 Niels Möller <nisse@lysator.liu.se>
+
+ * ecc-dup-eh.c (ecc_dup_eh): Eliminate one unneeded ecc_modp_add.
+
2019-12-14 Niels Möller <nisse@lysator.liu.se>
* ecc-mul-m.c (ecc_mul_m): New file and function. Implements
diff --git a/ecc-dup-eh.c b/ecc-dup-eh.c
index a850346c..6b678a40 100644
--- a/ecc-dup-eh.c
+++ b/ecc-dup-eh.c
@@ -67,12 +67,13 @@ ecc_dup_eh (const struct ecc_curve *ecc,
F = -C+D B, C, D, F
H = Z1^2 sqr B, C, D, F, H
J = 2*H - F B, C, D, F, J
- X3 = (B-C-D)*J mul C, D, F, J
+ X3 = (B-C-D)*J mul C, F, J (Replace C <-- C+D)
Y3 = F*(C+D) mul F, J
Z3 = F*J mul
3M+4S
*/
+ /* FIXME: Could reduce scratch need by reusing D storage. */
#define B scratch
#define C (scratch + ecc->p.size)
#define D (scratch + 2*ecc->p.size)
@@ -92,8 +93,8 @@ ecc_dup_eh (const struct ecc_curve *ecc,
/* F, */
ecc_modp_sub (ecc, F, D, C);
/* B - C - D */
+ ecc_modp_add (ecc, C, C, D);
ecc_modp_sub (ecc, B, B, C);
- ecc_modp_sub (ecc, B, B, D);
/* J */
ecc_modp_add (ecc, r, r, r);
ecc_modp_sub (ecc, J, r, F);
@@ -101,7 +102,6 @@ ecc_dup_eh (const struct ecc_curve *ecc,
/* x' */
ecc_modp_mul (ecc, r, B, J);
/* y' */
- ecc_modp_add (ecc, C, C, D); /* Redundant */
ecc_modp_mul (ecc, r + ecc->p.size, F, C);
/* z' */
ecc_modp_mul (ecc, B, F, J);