2 This file is part of GNUnet.
3 Copyright (C) 2002-2015 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file util/test_crypto_ecdh_eddsa.c
23 * @brief testcase for ECC DH key exchange with EdDSA private keys.
24 * @author Christian Grothoff
28 #include "gnunet_util_lib.h"
35 struct GNUNET_CRYPTO_EddsaPrivateKey *priv_dsa;
36 struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ecdh;
37 struct GNUNET_CRYPTO_EddsaPublicKey id1;
38 struct GNUNET_CRYPTO_EcdhePublicKey id2;
39 struct GNUNET_HashCode dh[2];
42 priv_dsa = GNUNET_CRYPTO_eddsa_key_create ();
43 GNUNET_CRYPTO_eddsa_key_get_public (priv_dsa,
45 for (unsigned int j=0;j<10;j++)
47 fprintf (stderr, ",");
48 priv_ecdh = GNUNET_CRYPTO_ecdhe_key_create ();
49 /* Extract public keys */
50 GNUNET_CRYPTO_ecdhe_key_get_public (priv_ecdh,
53 GNUNET_assert (GNUNET_OK ==
54 GNUNET_CRYPTO_eddsa_ecdh (priv_dsa,
57 GNUNET_assert (GNUNET_OK ==
58 GNUNET_CRYPTO_ecdh_eddsa (priv_ecdh,
61 /* Check that both DH results are equal. */
62 GNUNET_assert (0 == memcmp (&dh[0],
64 sizeof (struct GNUNET_HashCode)));
65 GNUNET_free (priv_ecdh);
67 GNUNET_free (priv_dsa);
73 main (int argc, char *argv[])
75 if (! gcry_check_version ("1.6.0"))
78 _("libgcrypt has not the expected version (version %s is required).\n"),
82 if (getenv ("GNUNET_GCRYPT_DEBUG"))
83 gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
84 GNUNET_log_setup ("test-crypto-ecdh-eddsa", "WARNING", NULL);
85 for (unsigned int i=0;i<100;i++)
96 /* end of test_crypto_ecdh_eddsa.c */