Skip to content
Snippets Groups Projects
Commit ac1e6e5a authored by Niels Möller's avatar Niels Möller
Browse files

Added benchmarking of curve25519 functions.

parent df7b4aca
Branches
Tags
No related merge requests found
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> 2014-09-03 Niels Möller <nisse@lysator.liu.se>
* Makefile.in: Revert 2013-02-06 Makefile changes: use a single * Makefile.in: Revert 2013-02-06 Makefile changes: use a single
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "dsa.h" #include "dsa.h"
#include "rsa.h" #include "rsa.h"
#include "curve25519.h"
#include "nettle-meta.h" #include "nettle-meta.h"
#include "sexp.h" #include "sexp.h"
...@@ -649,6 +650,48 @@ bench_openssl_ecdsa_clear (void *p) ...@@ -649,6 +650,48 @@ bench_openssl_ecdsa_clear (void *p)
} }
#endif #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[] = { struct alg alg_list[] = {
{ "rsa", 1024, bench_rsa_init, bench_rsa_sign, bench_rsa_verify, bench_rsa_clear }, { "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 }, { "rsa", 2048, bench_rsa_init, bench_rsa_sign, bench_rsa_verify, bench_rsa_clear },
...@@ -693,5 +736,8 @@ main (int argc, char **argv) ...@@ -693,5 +736,8 @@ main (int argc, char **argv)
if (!filter || strstr (alg_list[i].name, filter)) if (!filter || strstr (alg_list[i].name, filter))
bench_alg (&alg_list[i]); bench_alg (&alg_list[i]);
if (!filter || strstr("curve25519", filter))
bench_curve25519();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment