Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nettle
nettle
Commits
9abc94de
Commit
9abc94de
authored
Sep 16, 2014
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
New test case for ecc_dup_jj and ecc_dup_eh (latter test currently not exercised).
parent
3fc2a5e7
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
testsuite/.test-rules.make
+3
-0
3 additions, 0 deletions
testsuite/.test-rules.make
testsuite/Makefile.in
+1
-1
1 addition, 1 deletion
testsuite/Makefile.in
testsuite/ecc-dup-test.c
+75
-0
75 additions, 0 deletions
testsuite/ecc-dup-test.c
with
79 additions
and
1 deletion
testsuite/.test-rules.make
+
3
−
0
View file @
9abc94de
...
@@ -205,6 +205,9 @@ ecc-modinv-test$(EXEEXT): ecc-modinv-test.$(OBJEXT)
...
@@ -205,6 +205,9 @@ ecc-modinv-test$(EXEEXT): ecc-modinv-test.$(OBJEXT)
ecc-redc-test$(EXEEXT)
:
ecc-redc-test.$(OBJEXT)
ecc-redc-test$(EXEEXT)
:
ecc-redc-test.$(OBJEXT)
$(
LINK
)
ecc-redc-test.
$(
OBJEXT
)
$(
TEST_OBJS
)
-o
ecc-redc-test
$(
EXEEXT
)
$(
LINK
)
ecc-redc-test.
$(
OBJEXT
)
$(
TEST_OBJS
)
-o
ecc-redc-test
$(
EXEEXT
)
ecc-dup-test$(EXEEXT)
:
ecc-dup-test.$(OBJEXT)
$(
LINK
)
ecc-dup-test.
$(
OBJEXT
)
$(
TEST_OBJS
)
-o
ecc-dup-test
$(
EXEEXT
)
ecc-mul-g-test$(EXEEXT)
:
ecc-mul-g-test.$(OBJEXT)
ecc-mul-g-test$(EXEEXT)
:
ecc-mul-g-test.$(OBJEXT)
$(
LINK
)
ecc-mul-g-test.
$(
OBJEXT
)
$(
TEST_OBJS
)
-o
ecc-mul-g-test
$(
EXEEXT
)
$(
LINK
)
ecc-mul-g-test.
$(
OBJEXT
)
$(
TEST_OBJS
)
-o
ecc-mul-g-test
$(
EXEEXT
)
...
...
This diff is collapsed.
Click to expand it.
testsuite/Makefile.in
+
1
−
1
View file @
9abc94de
...
@@ -41,7 +41,7 @@ TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
...
@@ -41,7 +41,7 @@ TS_HOGWEED_SOURCES = sexp-test.c sexp-format-test.c \
curve25519-dup-test.c curve25519-add-test.c
\
curve25519-dup-test.c curve25519-add-test.c
\
curve25519-dh-test.c
\
curve25519-dh-test.c
\
ecc-mod-test.c ecc-modinv-test.c ecc-redc-test.c
\
ecc-mod-test.c ecc-modinv-test.c ecc-redc-test.c
\
ecc-mul-g-test.c ecc-mul-a-test.c
\
ecc-dup-test.c
ecc-mul-g-test.c ecc-mul-a-test.c
\
ecdsa-sign-test.c ecdsa-verify-test.c
\
ecdsa-sign-test.c ecdsa-verify-test.c
\
ecdsa-keygen-test.c ecdh-test.c
ecdsa-keygen-test.c ecdh-test.c
...
...
This diff is collapsed.
Click to expand it.
testsuite/ecc-dup-test.c
0 → 100644
+
75
−
0
View file @
9abc94de
#include
"testutils.h"
/* For curve25519 (or other edwards curves) only. */
static
int
point_zero_p
(
const
struct
ecc_curve
*
ecc
,
const
mp_limb_t
*
p
)
{
mp_limb_t
*
d
;
int
ret
;
mp_size_t
i
;
/* Zero point has Y = Z (mod p), or y = Y/Z = 1, which also implies
x == 0. */
d
=
xalloc_limbs
(
ecc
->
size
);
ecc_modp_sub
(
ecc
,
d
,
p
+
ecc
->
size
,
p
+
2
*
ecc
->
size
);
while
(
mpn_cmp
(
d
,
ecc
->
p
,
ecc
->
size
)
>=
0
)
mpn_sub_n
(
d
,
d
,
ecc
->
p
,
ecc
->
size
);
for
(
i
=
0
,
ret
=
1
;
i
<
ecc
->
size
;
i
++
)
if
(
d
[
i
])
{
ret
=
0
;
break
;
}
free
(
d
);
return
ret
;
}
void
test_main
(
void
)
{
unsigned
i
;
for
(
i
=
0
;
ecc_curves
[
i
];
i
++
)
{
const
struct
ecc_curve
*
ecc
=
ecc_curves
[
i
];
mp_limb_t
*
g
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
mp_limb_t
*
p
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
mp_limb_t
*
scratch
=
xalloc_limbs
(
ECC_DUP_EH_ITCH
(
ecc
->
size
));;
if
(
ecc
->
bit_size
==
255
)
{
mp_limb_t
*
z
=
xalloc_limbs
(
ecc_size_j
(
ecc
));
/* Zero point has x = 0, y = 1, z = 1 */
mpn_zero
(
z
,
3
*
ecc
->
size
);
z
[
ecc
->
size
]
=
z
[
2
*
ecc
->
size
]
=
1
;
ecc_a_to_j
(
ecc
,
g
,
ecc
->
g
);
ecc_dup_eh
(
ecc
,
p
,
z
,
scratch
);
if
(
!
point_zero_p
(
ecc
,
p
))
die
(
"dup of zero point failed.
\n
"
);
ecc_dup_eh
(
ecc
,
p
,
g
,
scratch
);
test_ecc_mul_h
(
i
,
2
,
p
);
ecc_dup_eh
(
ecc
,
p
,
p
,
scratch
);
test_ecc_mul_h
(
i
,
4
,
p
);
free
(
z
);
}
else
{
ecc_a_to_j
(
ecc
,
g
,
ecc
->
g
);
ecc_dup_jj
(
ecc
,
p
,
g
,
scratch
);
test_ecc_mul_h
(
i
,
2
,
p
);
ecc_dup_jj
(
ecc
,
p
,
p
,
scratch
);
test_ecc_mul_h
(
i
,
4
,
p
);
}
free
(
p
);
free
(
g
);
free
(
scratch
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment