/* This file is part of GNUnet. Copyright (C) 2015 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ /** * @file util/test_crypto_ecc_dlog.c * @brief testcase for ECC DLOG calculation * @author Christian Grothoff */ #include "platform.h" #include "gnunet_util_lib.h" #include /** * Name of the curve we are using. Note that we have hard-coded * structs that use 256 bits, so using a bigger curve will require * changes that break stuff badly. The name of the curve given here * must be agreed by all peers and be supported by libgcrypt. */ #define CURVE "Ed25519" /** * Maximum value we test dlog for. */ #define MAX_FACT 100 /** * Maximum memory to use, sqrt(MAX_FACT) is a good choice. */ #define MAX_MEM 10 /** * How many values do we test? */ #define TEST_ITER 10 /** * Range of values to use for MATH tests. */ #define MATH_MAX 5 /** * Do some DLOG operations for testing. * * @param edc context for ECC operations */ static void test_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc) { gcry_mpi_t fact; gcry_mpi_t n; gcry_ctx_t ctx; gcry_mpi_point_t q; gcry_mpi_point_t g; unsigned int i; int x; int iret; GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, CURVE)); g = gcry_mpi_ec_get_point ("g", ctx, 0); GNUNET_assert (NULL != g); n = gcry_mpi_ec_get_mpi ("n", ctx, 0); q = gcry_mpi_point_new (0); fact = gcry_mpi_new (0); for (i=0;i