зеркало из https://github.com/github/putty.git
New query function ecc_montgomery_is_identity.
To begin with, this allows me to add a regression test for the change in the previous commit.
This commit is contained in:
Родитель
141b75a71a
Коммит
c9a8fa639e
5
ecc.c
5
ecc.c
|
@ -833,6 +833,11 @@ void ecc_montgomery_get_affine(MontgomeryPoint *mp, mp_int **x)
|
|||
*x = monty_export(mc->mc, mp->X);
|
||||
}
|
||||
|
||||
unsigned ecc_montgomery_is_identity(MontgomeryPoint *mp)
|
||||
{
|
||||
return mp_eq_integer(mp->Z, 0);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Twisted Edwards curves.
|
||||
*/
|
||||
|
|
5
ecc.h
5
ecc.h
|
@ -170,6 +170,11 @@ MontgomeryPoint *ecc_montgomery_multiply(MontgomeryPoint *, mp_int *);
|
|||
*/
|
||||
void ecc_montgomery_get_affine(MontgomeryPoint *mp, mp_int **x);
|
||||
|
||||
/*
|
||||
* Test whether a point is the curve identity.
|
||||
*/
|
||||
unsigned ecc_montgomery_is_identity(MontgomeryPoint *mp);
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Twisted Edwards curves.
|
||||
*
|
||||
|
|
|
@ -769,6 +769,12 @@ class ecc(MyTestBase):
|
|||
check_point(ecc_montgomery_double(mP), rP + rP)
|
||||
check_point(ecc_montgomery_double(mQ), rQ + rQ)
|
||||
|
||||
zero = ecc_montgomery_point_new(mc, 0)
|
||||
self.assertEqual(ecc_montgomery_is_identity(zero), False)
|
||||
identity = ecc_montgomery_double(zero)
|
||||
ecc_montgomery_get_affine(identity)
|
||||
self.assertEqual(ecc_montgomery_is_identity(identity), True)
|
||||
|
||||
def testEdwardsSimple(self):
|
||||
p, d, a = 3141592661, 2688750488, 367934288
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ FUNC3(val_mpoint, ecc_montgomery_diff_add, val_mpoint, val_mpoint, val_mpoint)
|
|||
FUNC1(val_mpoint, ecc_montgomery_double, val_mpoint)
|
||||
FUNC2(val_mpoint, ecc_montgomery_multiply, val_mpoint, val_mpint)
|
||||
FUNC2(void, ecc_montgomery_get_affine, val_mpoint, out_val_mpint)
|
||||
FUNC1(boolean, ecc_montgomery_is_identity, val_mpoint)
|
||||
FUNC4(val_ecurve, ecc_edwards_curve, val_mpint, val_mpint, val_mpint, opt_val_mpint)
|
||||
FUNC3(val_epoint, ecc_edwards_point_new, val_ecurve, val_mpint, val_mpint)
|
||||
FUNC3(val_epoint, ecc_edwards_point_new_from_y, val_ecurve, val_mpint, uint)
|
||||
|
|
Загрузка…
Ссылка в новой задаче