Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nettle
nettle
Commits
3fc2a5e7
Commit
3fc2a5e7
authored
Sep 15, 2014
by
Niels Möller
Browse files
Use struct ecc_curve function pointers.
parent
1b72f61d
Changes
3
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
3fc2a5e7
2014-09-14 Niels Möller <nisse@lysator.liu.se>
* testsuite/ecc-mul-a-test.c (test_main): Use struct ecc_curve
function pointers.
* testsuite/ecc-mul-g-test.c (test_main): Likewise.
2014-09-09 Niels Möller <nisse@lysator.liu.se>
* curve25519-mul.c (curve25519_mul): Switch to use Montgomery
...
...
testsuite/ecc-mul-a-test.c
View file @
3fc2a5e7
...
...
@@ -25,32 +25,32 @@ test_main (void)
mp_limb_t
*
p
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
mp_limb_t
*
q
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
mp_limb_t
*
n
=
xalloc_limbs
(
size
);
mp_limb_t
*
scratch
=
xalloc_limbs
(
ecc
_
mul_
a_
itch
(
ecc
)
);
mp_limb_t
*
scratch
=
xalloc_limbs
(
ecc
->
mul_itch
);
unsigned
j
;
mpn_zero
(
n
,
size
);
n
[
0
]
=
1
;
ecc
_
mul
_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
_j
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
ecc
->
mul
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
->
h
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
!=
0
))
die
(
"curve %d: ecc
_
mul
_a
with n = 1 failed.
\n
"
,
ecc
->
bit_size
);
die
(
"curve %d: ecc
->
mul with n = 1 failed.
\n
"
,
ecc
->
bit_size
);
for
(
n
[
0
]
=
2
;
n
[
0
]
<=
4
;
n
[
0
]
++
)
{
ecc
_
mul
_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
->
mul
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
test_ecc_mul_h
(
i
,
n
[
0
],
p
);
}
/* (order - 1) * g = - g */
mpn_sub_1
(
n
,
ecc
->
q
,
size
,
1
);
ecc
_
mul
_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
_j
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
ecc
->
mul
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
->
h
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
mpn_sub_n
(
p
+
size
,
ecc
->
p
,
p
+
size
,
size
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
)
!=
0
)
{
fprintf
(
stderr
,
"ecc
_
mul
_a
with n = order - 1 failed.
\n
"
);
fprintf
(
stderr
,
"ecc
->
mul with n = order - 1 failed.
\n
"
);
abort
();
}
...
...
@@ -67,16 +67,16 @@ test_main (void)
mpz_limbs_copy
(
n
,
r
,
size
);
n
[
size
-
1
]
%=
ecc
->
q
[
size
-
1
];
ecc
_
mul
_a
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
_j
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
ecc
->
mul
(
ecc
,
p
,
n
,
ecc
->
g
,
scratch
);
ecc
->
h
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
ecc
_
mul_g
(
ecc
,
q
,
n
,
scratch
);
ecc
_j
_to_a
(
ecc
,
0
,
q
,
q
,
scratch
);
ecc
->
mul_g
(
ecc
,
q
,
n
,
scratch
);
ecc
->
h
_to_a
(
ecc
,
0
,
q
,
q
,
scratch
);
if
(
mpn_cmp
(
p
,
q
,
2
*
size
))
{
gmp_fprintf
(
stderr
,
"Different results from ecc
_
mul
_a
and ecc
_
mul_g.
\n
"
"Different results from ecc
->
mul and ecc
->
mul_g.
\n
"
" bits = %u
\n
"
" n = %Nx
\n
"
,
ecc
->
bit_size
,
n
,
size
);
...
...
testsuite/ecc-mul-g-test.c
View file @
3fc2a5e7
...
...
@@ -25,34 +25,34 @@ test_main (void)
mp_limb_t
*
p
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
mp_limb_t
*
q
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
mp_limb_t
*
n
=
xalloc_limbs
(
size
);
mp_limb_t
*
scratch
=
xalloc_limbs
(
ecc
_
mul_g_itch
(
ecc
)
);
mp_limb_t
*
scratch
=
xalloc_limbs
(
ecc
->
mul_g_itch
);
mpn_zero
(
n
,
size
);
n
[
0
]
=
1
;
ecc
_
mul_g
(
ecc
,
p
,
n
,
scratch
);
ecc
_j
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
ecc
->
mul_g
(
ecc
,
p
,
n
,
scratch
);
ecc
->
h
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
!=
0
))
{
fprintf
(
stderr
,
"ecc
_
mul_g with n = 1 failed.
\n
"
);
fprintf
(
stderr
,
"ecc
->
mul_g with n = 1 failed.
\n
"
);
abort
();
}
for
(
n
[
0
]
=
2
;
n
[
0
]
<=
4
;
n
[
0
]
++
)
{
ecc
_
mul_g
(
ecc
,
p
,
n
,
scratch
);
ecc
->
mul_g
(
ecc
,
p
,
n
,
scratch
);
test_ecc_mul_h
(
i
,
n
[
0
],
p
);
}
/* (order - 1) * g = - g */
mpn_sub_1
(
n
,
ecc
->
q
,
size
,
1
);
ecc
_
mul_g
(
ecc
,
p
,
n
,
scratch
);
ecc
_j
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
ecc
->
mul_g
(
ecc
,
p
,
n
,
scratch
);
ecc
->
h
_to_a
(
ecc
,
0
,
p
,
p
,
scratch
);
mpn_sub_n
(
p
+
size
,
ecc
->
p
,
p
+
size
,
size
);
if
(
mpn_cmp
(
p
,
ecc
->
g
,
2
*
size
)
!=
0
)
{
fprintf
(
stderr
,
"ecc
_
mul_g with n = order - 1 failed.
\n
"
);
fprintf
(
stderr
,
"ecc
->
mul_g with n = order - 1 failed.
\n
"
);
abort
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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