/*
This file is part of GNUnet.
- (C) 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
static int
peer_id_cmp (const void *p1, const void *p2)
{
- return memcmp (p1, p2, sizeof (struct GNUNET_PeerIdentity));
+ return memcmp (p1,
+ p2,
+ sizeof (struct GNUNET_PeerIdentity));
}
const struct GNUNET_PeerIdentity *needle)
{
unsigned int i;
+
for (i = 0; i < n; i++)
- if (0 == memcmp (&haystack[i], needle, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 == memcmp (&haystack[i],
+ needle,
+ sizeof (struct GNUNET_PeerIdentity)))
return i;
return -1;
}
if (GNUNET_NO == local_peer_in_list)
normalized[n - 1] = my_peer;
- memcpy (normalized, listed, num_listed * sizeof (struct GNUNET_PeerIdentity));
- qsort (normalized, n, sizeof (struct GNUNET_PeerIdentity), &peer_id_cmp);
+ GNUNET_memcpy (normalized,
+ listed,
+ num_listed * sizeof (struct GNUNET_PeerIdentity));
+ qsort (normalized,
+ n,
+ sizeof (struct GNUNET_PeerIdentity),
+ &peer_id_cmp);
if (NULL != my_peer_idx)
*my_peer_idx = peer_find (normalized, n, &my_peer);
GNUNET_free (ds);
}
+
static void
keygen_info_destroy (struct KeygenPeerInfo *info)
{
if (NULL != info->preshare_commitment)
{
gcry_mpi_release (info->preshare_commitment);
- info->presecret_commitment = NULL;
+ info->preshare_commitment = NULL;
}
}
* @param tc unused
*/
static void
-cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+cleanup_task (void *cls)
{
while (NULL != decrypt_sessions_head)
decrypt_session_destroy (decrypt_sessions_head);
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"keygen commit data with wrong size (%u) in consensus, "
- " %u expected\n",
+ " %lu expected\n",
element->size, sizeof (struct GNUNET_SECRETSHARING_KeygenCommitData));
return;
}
} hash_data;
struct GNUNET_HashCode e_hash;
- memcpy (&hash_data.c, &fe->c, sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
- memcpy (&hash_data.h, &fe->h, GNUNET_SECRETSHARING_ELGAMAL_BITS / 8);
- memcpy (&hash_data.t1, &fe->t1, GNUNET_SECRETSHARING_ELGAMAL_BITS / 8);
- memcpy (&hash_data.t2, &fe->t2, GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8);
+ GNUNET_memcpy (&hash_data.c, &fe->c, sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
+ GNUNET_memcpy (&hash_data.h, &fe->h, GNUNET_SECRETSHARING_ELGAMAL_BITS / 8);
+ GNUNET_memcpy (&hash_data.t1, &fe->t1, GNUNET_SECRETSHARING_ELGAMAL_BITS / 8);
+ GNUNET_memcpy (&hash_data.t2, &fe->t2, GNUNET_CRYPTO_PAILLIER_BITS * 2 / 8);
GNUNET_CRYPTO_mpi_scan_unsigned (&e, &e_hash, sizeof (struct GNUNET_HashCode));
gcry_mpi_mod (e, e, elgamal_q);
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"keygen round2 data with wrong size (%u) in consensus, "
- " %u expected\n",
+ " %lu expected\n",
element->size, expected_element_size);
return;
}
d->purpose.size = htonl ((sizeof *d) - offsetof (struct GNUNET_SECRETSHARING_KeygenCommitData, purpose));
d->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1);
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (my_peer_private_key, &d->purpose, &d->signature));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_sign (my_peer_private_key,
+ &d->purpose,
+ &d->signature));
GNUNET_CONSENSUS_insert (ks->consensus, element, NULL, NULL);
if (NULL != info->partial_decryption)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt element duplicate\n",
- GNUNET_i2s (&d->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt element duplicate\n");
return;
}
char *tmp2_str;
tmp1_str = mpi_to_str (tmp1);
tmp2_str = mpi_to_str (tmp2);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "P%u: Received invalid partial decryption from P%u (eqn 1), expected %s got %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "P%u: Received invalid partial decryption from P%ld (eqn 1), expected %s got %s\n",
session->share->my_peer, info - session->info, tmp1_str, tmp2_str);
GNUNET_free (tmp1_str);
GNUNET_free (tmp2_str);
if (0 != gcry_mpi_cmp (tmp1, tmp2))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "P%u: Received invalid partial decryption from P%u (eqn 2)\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "P%u: Received invalid partial decryption from P%ld (eqn 2)\n",
session->share->my_peer, info - session->info);
goto cleanup;
}
element.data = (void *) &d;
element.size = sizeof (struct GNUNET_SECRETSHARING_DecryptData);
- element.type = 0;
+ element.element_type = 0;
d.ciphertext = ds->ciphertext;
d.peer = my_peer;
d.purpose.size = htonl (element.size - offsetof (struct GNUNET_SECRETSHARING_DecryptData, purpose));
d.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DECRYPTION);
- GNUNET_CRYPTO_eddsa_sign (my_peer_private_key, &d.purpose, &d.signature);
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_eddsa_sign (my_peer_private_key,
+ &d.purpose,
+ &d.signature));
GNUNET_CONSENSUS_insert (ds->consensus, &element, NULL, NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "P%u: Inserting decrypt element done!\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "P%u: Inserting decrypt element done!\n",
ds->share->my_peer);
gcry_mpi_release (s);
}
GNUNET_SERVER_add_handlers (server, handlers);
GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
- NULL);
+ GNUNET_SCHEDULER_add_shutdown (&cleanup_task,
+ NULL);
}
GNUNET_SERVICE_run (argc, argv, "secretsharing",
GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
}
-