Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
cc86df70
Commit
cc86df70
authored
Aug 25, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
curve25519 support for ecc_point_mul, ecc_point_mul_g, and ecdh-test.
parent
a45118aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
+26
-14
ChangeLog
ChangeLog
+9
-0
ecc-point-mul-g.c
ecc-point-mul-g.c
+6
-5
ecc-point-mul.c
ecc-point-mul.c
+7
-6
testsuite/ecdh-test.c
testsuite/ecdh-test.c
+4
-3
No files found.
ChangeLog
View file @
cc86df70
2014-08-25 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecdh-test.c (set_point): Check return value of
ecc_point_set.
(test_main): Enable curve25519 test.
* ecc-point-mul-g.c (ecc_point_mul_g): Use ecc->mul_g and
ecc->h_to_a function pointers.
* ecc-point-mul.c (ecc_point_mul): Use the ecc->mul and
ecc->h_to_a function pointers.
* ecc-internal.h (ecc_mul_g_func, ecc_mul_func, ecc_h_to_a_func):
New typedefs.
(struct ecc_curve): New function pointers mul, mul_g, h_to_a, and
...
...
ecc-point-mul-g.c
View file @
cc86df70
...
...
@@ -45,13 +45,14 @@ void
ecc_point_mul_g
(
struct
ecc_point
*
r
,
const
struct
ecc_scalar
*
n
)
{
TMP_DECL
(
scratch
,
mp_limb_t
,
3
*
ECC_MAX_SIZE
+
ECC_MUL_G_ITCH
(
ECC_MAX_SIZE
));
mp_limb_t
size
=
r
->
ecc
->
size
;
mp_size_t
itch
=
3
*
size
+
ECC_MUL_G_ITCH
(
size
);
const
struct
ecc_curve
*
ecc
=
r
->
ecc
;
mp_limb_t
size
=
ecc
->
size
;
mp_size_t
itch
=
3
*
size
+
ecc
->
mul_g_itch
;
assert
(
r
->
ecc
==
n
->
ecc
);
assert
(
n
->
ecc
==
ecc
);
TMP_ALLOC
(
scratch
,
itch
);
ecc
_mul_g
(
r
->
ecc
,
scratch
,
n
->
p
,
scratch
+
3
*
size
);
ecc
_j_to_a
(
r
->
ecc
,
1
,
r
->
p
,
scratch
,
scratch
+
3
*
size
);
ecc
->
mul_g
(
ecc
,
scratch
,
n
->
p
,
scratch
+
3
*
size
);
ecc
->
h_to_a
(
ecc
,
1
,
r
->
p
,
scratch
,
scratch
+
3
*
size
);
}
ecc-point-mul.c
View file @
cc86df70
...
...
@@ -44,14 +44,15 @@ void
ecc_point_mul
(
struct
ecc_point
*
r
,
const
struct
ecc_scalar
*
n
,
const
struct
ecc_point
*
p
)
{
mp_limb_t
size
=
p
->
ecc
->
size
;
mp_size_t
itch
=
3
*
size
+
ECC_MUL_A_ITCH
(
size
);
const
struct
ecc_curve
*
ecc
=
r
->
ecc
;
mp_limb_t
size
=
ecc
->
size
;
mp_size_t
itch
=
3
*
size
+
ecc
->
mul_itch
;
mp_limb_t
*
scratch
=
gmp_alloc_limbs
(
itch
);
assert
(
n
->
ecc
==
p
->
ecc
);
assert
(
r
->
ecc
==
p
->
ecc
);
assert
(
n
->
ecc
==
ecc
);
assert
(
p
->
ecc
==
ecc
);
ecc
_mul_a
(
p
->
ecc
,
scratch
,
n
->
p
,
p
->
p
,
scratch
+
3
*
size
);
ecc
_j_to_a
(
r
->
ecc
,
1
,
r
->
p
,
scratch
,
scratch
+
3
*
size
);
ecc
->
mul
(
ecc
,
scratch
,
n
->
p
,
p
->
p
,
scratch
+
3
*
size
);
ecc
->
h_to_a
(
ecc
,
1
,
r
->
p
,
scratch
,
scratch
+
3
*
size
);
gmp_free_limbs
(
scratch
,
itch
);
}
testsuite/ecdh-test.c
View file @
cc86df70
...
...
@@ -38,7 +38,9 @@ set_point (struct ecc_point *p,
mpz_t
X
,
Y
;
mpz_init_set_str
(
X
,
x
,
0
);
mpz_init_set_str
(
Y
,
y
,
0
);
ecc_point_set
(
p
,
X
,
Y
);
if
(
!
ecc_point_set
(
p
,
X
,
Y
))
die
(
"Test point not on curve!
\n
"
);
mpz_clear
(
X
);
mpz_clear
(
Y
);
}
...
...
@@ -185,7 +187,7 @@ test_main(void)
"4488572162727491199625798812850846214916160870437505769058530973184916706326908828109446998319674522651965593412129100088877891410841200092694907512496020182"
,
"2126311732129869456512627735193938710331935978955001830871465201548004444073866677974896970734635601049909886616595755762740651165670628002084824920216966370"
,
"4803556648772727869384704240411011976585308117802975396033423138930126997561438092192867119930177133880625991019440171972612468402200399449807843995563872782"
);
#if 0
/* NOTE: This isn't quite the standard way to do curve25519
diffie-hellman, but it tests that the ecc_point interface works
also with curve25519. FIXME: Which it doesn't yet do. */
...
...
@@ -198,5 +200,4 @@ test_main(void)
"45040108202870901856797106334440548809561721639881101469282515918034252408802"
,
"12684624775789228333626692483521764247362476074160626230698999100180553618972"
,
"22635121008463339848034566659860493350277619617839914078958064757823336329514"
);
#endif
}
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