+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
#include "dsa.h"
#include "rsa.h"
+#include "curve25519.h"
#include "nettle-meta.h"
#include "sexp.h"
}
#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 },
if (!filter || strstr (alg_list[i].name, filter))
bench_alg (&alg_list[i]);
+ if (!filter || strstr("curve25519", filter))
+ bench_curve25519();
+
return EXIT_SUCCESS;
}