chiark
/
gitweb
/
~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
symm/t/sha...: Add official NIST HMAC test vectors.
[catacomb]
/
math
/
ec-prime.c
diff --git
a/math/ec-prime.c
b/math/ec-prime.c
index f6a7f96029885899a8da2fd9be9c327d0ff07b9f..46b98856d9f18edd6dd41d5aeeee49be930678ed 100644
(file)
--- a/
math/ec-prime.c
+++ b/
math/ec-prime.c
@@
-267,7
+267,7
@@
static ec *ecprojadd(ec_curve *c, ec *d, const ec *a, const ec *b)
}
}
u = F_ADD(f, u, u, uu); /* %$t = uu + u$% */
}
}
u = F_ADD(f, u, u, uu); /* %$t = uu + u$% */
- s = F_ADD(f, s, s, ss); /* %$m = ss +
r
$% */
+ s = F_ADD(f, s, s, ss); /* %$m = ss +
s
$% */
uu = F_MUL(f, uu, a->z, w); /* %$z_0 w$% */
dz = F_MUL(f, ss, uu, b->z); /* %$z' = z_0 z_1 w$% */
uu = F_MUL(f, uu, a->z, w); /* %$z_0 w$% */
dz = F_MUL(f, ss, uu, b->z); /* %$z' = z_0 z_1 w$% */
@@
-328,6
+328,17
@@
static int ecprojcheck(ec_curve *c, const ec *p)
return (rc);
}
return (rc);
}
+static int eccompr(ec_curve *c, const ec *p)
+{
+ /* --- Just take the LSB of %$y$% ---
+ *
+ * Since @p@ is odd, either %$y$% or %$-y = p - y$% must be odd, so this
+ * disambiguates.
+ */
+
+ return (MP_ODDP(p->y));
+}
+
static void ecdestroy(ec_curve *c)
{
MP_DROP(c->a);
static void ecdestroy(ec_curve *c)
{
MP_DROP(c->a);
@@
-378,19
+389,19
@@
extern ec_curve *ec_primeproj(field *f, mp *a, mp *b)
static const ec_ops ec_primeops = {
"prime",
ecdestroy, ec_stdsamep, ec_idin, ec_idout, ec_idfix,
static const ec_ops ec_primeops = {
"prime",
ecdestroy, ec_stdsamep, ec_idin, ec_idout, ec_idfix,
- ecfind, ecneg, ecadd, ec_stdsub, ecdbl, eccheck
+ ecfind, ecneg, ecadd, ec_stdsub, ecdbl, eccheck
, eccompr
};
static const ec_ops ec_primeprojops = {
"primeproj",
ecdestroy, ec_stdsamep, ec_projin, ec_projout, ec_projfix,
};
static const ec_ops ec_primeprojops = {
"primeproj",
ecdestroy, ec_stdsamep, ec_projin, ec_projout, ec_projfix,
- ecfind, ecneg, ecprojadd, ec_stdsub, ecprojdbl, ecprojcheck
+ ecfind, ecneg, ecprojadd, ec_stdsub, ecprojdbl, ecprojcheck
, eccompr
};
static const ec_ops ec_primeprojxops = {
"primeproj",
ecdestroy, ec_stdsamep, ec_projin, ec_projout, ec_projfix,
};
static const ec_ops ec_primeprojxops = {
"primeproj",
ecdestroy, ec_stdsamep, ec_projin, ec_projout, ec_projfix,
- ecfind, ecneg, ecprojadd, ec_stdsub, ecprojxdbl, ecprojcheck
+ ecfind, ecneg, ecprojadd, ec_stdsub, ecprojxdbl, ecprojcheck
, eccompr
};
/*----- Test rig ----------------------------------------------------------*/
};
/*----- Test rig ----------------------------------------------------------*/