aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_bug.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_bug.c')
-rw-r--r--src/util/crypto_bug.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/util/crypto_bug.c b/src/util/crypto_bug.c
deleted file mode 100644
index aea801d40..000000000
--- a/src/util/crypto_bug.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2018 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/**
20 * @file util/crypto_bug.c
21 * @brief work around unidentified public key cryptography bug
22 * @author Christian Grothoff
23 */
24
25/**
26 * Enable work-around. Will cause code to call #check_eddsa_key() to
27 * see if we have a bad key, and if so, create a new one.
28 */
29#define CRYPTO_BUG 0
30
31
32#if CRYPTO_BUG
33/**
34 * Check if ECDH works with @a priv_dsa and this version
35 * of libgcrypt.
36 *
37 * @param priv_dsa key to check
38 * @return #GNUNET_OK if key passes
39 */
40static int
41check_eddsa_key (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv_dsa)
42{
43 struct GNUNET_CRYPTO_EcdhePrivateKey *priv_ecdh;
44 struct GNUNET_CRYPTO_EddsaPublicKey id1;
45 struct GNUNET_CRYPTO_EcdhePublicKey id2;
46 struct GNUNET_HashCode dh[2];
47
48 GNUNET_CRYPTO_eddsa_key_get_public (priv_dsa,
49 &id1);
50 for (unsigned int j=0;j<4;j++)
51 {
52 priv_ecdh = GNUNET_CRYPTO_ecdhe_key_create ();
53 /* Extract public keys */
54 GNUNET_CRYPTO_ecdhe_key_get_public (priv_ecdh,
55 &id2);
56 /* Do ECDH */
57 GNUNET_assert (GNUNET_OK ==
58 GNUNET_CRYPTO_eddsa_ecdh (priv_dsa,
59 &id2,
60 &dh[0]));
61 GNUNET_assert (GNUNET_OK ==
62 GNUNET_CRYPTO_ecdh_eddsa (priv_ecdh,
63 &id1,
64 &dh[1]));
65 /* Check that both DH results are equal. */
66 if (0 != memcmp (&dh[0],
67 &dh[1],
68 sizeof (struct GNUNET_HashCode)))
69 {
70 GNUNET_break (0); /* bad EdDSA key! */
71 return GNUNET_SYSERR;
72 }
73 GNUNET_free (priv_ecdh);
74 }
75 return GNUNET_OK;
76}
77#endif