Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
3a64c5a7
Commit
3a64c5a7
authored
Aug 25, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added curve25519 special case in ecc_set_point.
parent
d583973e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
ChangeLog
ChangeLog
+5
-0
ecc-point.c
ecc-point.c
+19
-5
No files found.
ChangeLog
View file @
3a64c5a7
2014-08-25 Niels Möller <nisse@lysator.liu.se>
* ecc-point.c (ecc_point_set): Handle curve25519 as a special
case, when checking if the point is on the curve.
2014-08-24 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecdh-test.c: Test ecc_point_mul and ecc_point_mul_g,
...
...
ecc-point.c
View file @
3a64c5a7
...
...
@@ -68,12 +68,26 @@ ecc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y)
mpz_init
(
lhs
);
mpz_init
(
rhs
);
/* Check that y^2 = x^3 - 3*x + b (mod p) */
if
(
p
->
ecc
->
bit_size
==
255
)
{
/* curve25519 special case. FIXME: Do in some cleaner way? */
/* Check that y^2 = x^3 + 486662 x^2 + x (mod p)*/
mpz_mul
(
lhs
,
x
,
x
);
/* Reuse lhs as a temporary */
mpz_add_ui
(
rhs
,
x
,
486662
);
mpz_mul
(
rhs
,
rhs
,
lhs
);
mpz_add
(
rhs
,
rhs
,
x
);
}
else
{
/* Check that y^2 = x^3 - 3*x + b (mod p) */
mpz_mul
(
rhs
,
x
,
x
);
mpz_sub_ui
(
rhs
,
rhs
,
3
);
mpz_mul
(
rhs
,
rhs
,
x
);
mpz_add
(
rhs
,
rhs
,
mpz_roinit_n
(
t
,
p
->
ecc
->
b
,
size
));
}
mpz_mul
(
lhs
,
y
,
y
);
mpz_mul
(
rhs
,
x
,
x
);
mpz_sub_ui
(
rhs
,
rhs
,
3
);
mpz_mul
(
rhs
,
rhs
,
x
);
mpz_add
(
rhs
,
rhs
,
mpz_roinit_n
(
t
,
p
->
ecc
->
b
,
size
));
res
=
mpz_congruent_p
(
lhs
,
rhs
,
mpz_roinit_n
(
t
,
p
->
ecc
->
p
,
size
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment