diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:40:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:40:06 +0000 |
commit | 4add4c6a6302ff01539e246f68aaf13299414fd6 (patch) | |
tree | 2f5343a10726d165c35c98c48eb59247a5ab3a63 /src/util/test_crypto_ecdhe.c | |
parent | 9351b1e9bdf2b067b6db06562c26ba658cff42b8 (diff) | |
download | gnunet-4add4c6a6302ff01539e246f68aaf13299414fd6.tar.gz gnunet-4add4c6a6302ff01539e246f68aaf13299414fd6.zip |
-updated tests
Diffstat (limited to 'src/util/test_crypto_ecdhe.c')
-rw-r--r-- | src/util/test_crypto_ecdhe.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/util/test_crypto_ecdhe.c b/src/util/test_crypto_ecdhe.c new file mode 100644 index 000000000..a6f96d9f1 --- /dev/null +++ b/src/util/test_crypto_ecdhe.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2002-2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | |||
20 | */ | ||
21 | /** | ||
22 | * @file util/test_crypto_ecdhe.c | ||
23 | * @brief testcase for ECC ECDHE public key crypto | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include <gcrypt.h> | ||
29 | |||
30 | |||
31 | int | ||
32 | main (int argc, char *argv[]) | ||
33 | { | ||
34 | struct GNUNET_CRYPTO_EcdhePrivateKey *priv1; | ||
35 | struct GNUNET_CRYPTO_EcdhePrivateKey *priv2; | ||
36 | struct GNUNET_CRYPTO_EcdhePublicKey pub1; | ||
37 | struct GNUNET_CRYPTO_EcdhePublicKey pub2; | ||
38 | struct GNUNET_HashCode ecdh1; | ||
39 | struct GNUNET_HashCode ecdh2; | ||
40 | |||
41 | if (! gcry_check_version ("1.5.0")) | ||
42 | { | ||
43 | FPRINTF (stderr, | ||
44 | _ | ||
45 | ("libgcrypt has not the expected version (version %s is required).\n"), | ||
46 | "1.5.0"); | ||
47 | return 0; | ||
48 | } | ||
49 | GNUNET_log_setup ("test-crypto-ecdhe", "WARNING", NULL); | ||
50 | |||
51 | priv1 = GNUNET_CRYPTO_ecdhe_key_create (); | ||
52 | priv2 = GNUNET_CRYPTO_ecdhe_key_create (); | ||
53 | GNUNET_CRYPTO_ecdhe_key_get_public (priv1, &pub1); | ||
54 | GNUNET_CRYPTO_ecdhe_key_get_public (priv2, &pub2); | ||
55 | GNUNET_CRYPTO_ecc_ecdh (priv1, &pub2, &ecdh1); | ||
56 | GNUNET_CRYPTO_ecc_ecdh (priv2, &pub1, &ecdh2); | ||
57 | GNUNET_assert (0 == memcmp (&ecdh1, &ecdh2, | ||
58 | sizeof (struct GNUNET_HashCode))); | ||
59 | GNUNET_free (priv1); | ||
60 | GNUNET_free (priv2); | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | /* end of test_crypto_ecdhe.c */ | ||