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
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wim Lewis
nettle
Commits
8bd75960
Commit
8bd75960
authored
10 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Adapt test case to use curve25519_base.
parent
28b7678e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ChangeLog
+3
-0
3 additions, 0 deletions
ChangeLog
testsuite/curve25519-dh-test.c
+24
-42
24 additions, 42 deletions
testsuite/curve25519-dh-test.c
with
27 additions
and
42 deletions
ChangeLog
+
3
−
0
View file @
8bd75960
2014-08-06 Niels Möller <nisse@lysator.liu.se>
* testsuite/curve25519-dh-test.c (test_g): Use curve25519_base.
(test_main): Use little-endian inputs for test_g.
* curve25519-base.c (curve25519_base): New file, new function.
Analogous to NaCl's crypto_scalarmult_base.
* curve25519.h: New file.
...
...
This diff is collapsed.
Click to expand it.
testsuite/curve25519-dh-test.c
+
24
−
42
View file @
8bd75960
...
...
@@ -31,6 +31,8 @@
#include
"testutils.h"
#include
"curve25519.h"
static
int
curve25519_sqrt
(
const
struct
ecc_curve
*
ecc
,
mp_limb_t
*
rp
,
const
mp_limb_t
*
ap
)
...
...
@@ -160,39 +162,21 @@ curve_25519 (const struct ecc_curve *ecc,
}
static
void
test_g
(
const
char
*
s
z
,
const
char
*
pz
)
test_g
(
const
uint8_t
*
s
,
const
uint8_t
*
r
)
{
mpz_t
S
,
R
,
X
;
const
struct
ecc_curve
*
ecc
=
&
nettle_curve25519
;
mpz_init
(
S
);
mpz_init
(
R
);
mpz_init
(
X
);
mpz_set_str
(
S
,
sz
,
16
);
mpz_set_str
(
R
,
pz
,
16
);
ASSERT
(
mpz_size
(
S
)
==
ecc
->
size
);
curve_25519
(
ecc
,
mpz_limbs_write
(
X
,
ecc
->
size
),
mpz_limbs_read
(
S
),
NULL
);
mpz_limbs_finish
(
X
,
ecc
->
size
);
if
(
mpz_cmp
(
X
,
R
)
!=
0
)
uint8_t
p
[
CURVE25519_SIZE
];
curve25519_base
(
p
,
s
);
if
(
!
MEMEQ
(
CURVE25519_SIZE
,
p
,
r
))
{
f
printf
(
stderr
,
"curve25519 failure:
\n
s = "
);
mpz_out_str
(
stderr
,
16
,
S
);
f
printf
(
stderr
,
"
\n
X
= "
);
mpz_out_str
(
stderr
,
16
,
X
);
f
printf
(
stderr
,
" (bad)
\n
R
= "
);
mpz_out_str
(
stderr
,
16
,
R
);
f
printf
(
stderr
,
" (expected)
\n
"
);
printf
(
"curve25519
_base
failure:
\n
s = "
);
print_hex
(
CURVE25519_SIZE
,
s
);
printf
(
"
\n
p
= "
);
print_hex
(
CURVE25519_SIZE
,
p
);
printf
(
" (bad)
\n
r
= "
);
print_hex
(
CURVE25519_SIZE
,
r
);
printf
(
" (expected)
\n
"
);
abort
();
}
mpz_clear
(
S
);
mpz_clear
(
R
);
mpz_clear
(
X
);
}
static
void
...
...
@@ -240,19 +224,17 @@ test_a (const char *bz, const char *sz, const char *pz)
void
test_main
(
void
)
{
/* From draft-josefsson-tls-curve25519-05. Different endianness for
the P values, though. */
test_g
(
"6A2CB91DA5FB77B12A99C0EB872F4CDF"
"4566B25172C1163C7DA518730A6D0770"
,
"6A4E9BAA8EA9A4EBF41A38260D3ABF0D"
"5AF73EB4DC7D8B7454A7308909F02085"
);
test_g
(
"6BE088FF278B2F1CFDB6182629B13B6F"
"E60E80838B7FE1794B8A4A627E08AB58"
,
"4F2B886F147EFCAD4D67785BC843833F"
"3735E4ECC2615BD3B4C17D7B7DDB9EDE"
);
/* From draft-turner-thecurve25519function-00 (same also in
draft-josefsson-tls-curve25519-05, but the latter uses different
endianness). */
test_g
(
H
(
"77076d0a7318a57d3c16c17251b26645"
"df4c2f87ebc0992ab177fba51db92c2a"
),
H
(
"8520f0098930a754748b7ddcb43ef75a"
"0dbf3a0d26381af4eba4a98eaa9b4e6a"
));
test_g
(
H
(
"5dab087e624a8a4b79e17f8b83800ee6"
"6f3bb1292618b6fd1c2f8b27ff88e0eb"
),
H
(
"de9edb7d7b7dc1b4d35b61c2ece43537"
"3f8343c85b78674dadfc7e146f882b4f"
));
test_a
(
"4F2B886F147EFCAD4D67785BC843833F"
"3735E4ECC2615BD3B4C17D7B7DDB9EDE"
,
...
...
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