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
ac1e6e5a
Commit
ac1e6e5a
authored
Sep 06, 2014
by
Niels Möller
Browse files
Added benchmarking of curve25519 functions.
parent
df7b4aca
Changes
2
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
ac1e6e5a
2014-09-06 Niels Möller <nisse@lysator.liu.se>
* examples/hogweed-benchmark.c (bench_curve25519_mul_g)
(bench_curve25519_mul, bench_curve25519): New functions.
(main): Added benchmarking of curve25519 functions.
2014-09-03 Niels Möller <nisse@lysator.liu.se>
* Makefile.in: Revert 2013-02-06 Makefile changes: use a single
...
...
examples/hogweed-benchmark.c
View file @
ac1e6e5a
...
...
@@ -47,6 +47,7 @@
#include
"dsa.h"
#include
"rsa.h"
#include
"curve25519.h"
#include
"nettle-meta.h"
#include
"sexp.h"
...
...
@@ -649,6 +650,48 @@ bench_openssl_ecdsa_clear (void *p)
}
#endif
struct
curve25519_ctx
{
char
x
[
CURVE25519_SIZE
];
char
s
[
CURVE25519_SIZE
];
};
static
void
bench_curve25519_mul_g
(
void
*
p
)
{
struct
curve25519_ctx
*
ctx
=
p
;
char
q
[
CURVE25519_SIZE
];
curve25519_mul_g
(
q
,
ctx
->
s
);
}
static
void
bench_curve25519_mul
(
void
*
p
)
{
struct
curve25519_ctx
*
ctx
=
p
;
char
q
[
CURVE25519_SIZE
];
if
(
!
curve25519_mul
(
q
,
ctx
->
s
,
ctx
->
x
))
die
(
"Internal error, curve25519_mul failed.
\n
"
);
}
static
void
bench_curve25519
(
void
)
{
double
mul_g
;
double
mul
;
struct
knuth_lfib_ctx
lfib
;
struct
curve25519_ctx
ctx
;
knuth_lfib_init
(
&
lfib
,
2
);
knuth_lfib_random
(
&
lfib
,
sizeof
(
ctx
.
s
),
ctx
.
s
);
curve25519_mul_g
(
ctx
.
x
,
ctx
.
s
);
mul_g
=
time_function
(
bench_curve25519_mul_g
,
&
ctx
);
mul
=
time_function
(
bench_curve25519_mul
,
&
ctx
);
printf
(
"%15s %4d %9.4f %9.4f
\n
"
,
"curve25519"
,
255
,
1e-3
/
mul_g
,
1e-3
/
mul
);
}
struct
alg
alg_list
[]
=
{
{
"rsa"
,
1024
,
bench_rsa_init
,
bench_rsa_sign
,
bench_rsa_verify
,
bench_rsa_clear
},
{
"rsa"
,
2048
,
bench_rsa_init
,
bench_rsa_sign
,
bench_rsa_verify
,
bench_rsa_clear
},
...
...
@@ -693,5 +736,8 @@ main (int argc, char **argv)
if
(
!
filter
||
strstr
(
alg_list
[
i
].
name
,
filter
))
bench_alg
(
&
alg_list
[
i
]);
if
(
!
filter
||
strstr
(
"curve25519"
,
filter
))
bench_curve25519
();
return
EXIT_SUCCESS
;
}
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