aboutsummaryrefslogtreecommitdiff
path: root/src/secretsharing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-10-05 01:24:47 +0000
committerChristian Grothoff <christian@grothoff.org>2014-10-05 01:24:47 +0000
commitf0074725870c977dd31576a150b7305d044c272f (patch)
treee6ff442a806ecfdee20b2b8c08a693d7340fd17d /src/secretsharing
parentba9069e308aaf55f2bb434709a0a95b039728844 (diff)
downloadgnunet-f0074725870c977dd31576a150b7305d044c272f.tar.gz
gnunet-f0074725870c977dd31576a150b7305d044c272f.zip
-check return value
Diffstat (limited to 'src/secretsharing')
-rw-r--r--src/secretsharing/gnunet-service-secretsharing.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/secretsharing/gnunet-service-secretsharing.c b/src/secretsharing/gnunet-service-secretsharing.c
index c286f81cc..97d2a86ad 100644
--- a/src/secretsharing/gnunet-service-secretsharing.c
+++ b/src/secretsharing/gnunet-service-secretsharing.c
@@ -723,7 +723,7 @@ generate_presecret_polynomial (struct KeygenSession *ks)
723 GNUNET_assert (NULL != v); 723 GNUNET_assert (NULL != v);
724 // Randomize v such that 0 < v < elgamal_q. 724 // Randomize v such that 0 < v < elgamal_q.
725 // The '- 1' is necessary as bitlength(q) = bitlength(p) - 1. 725 // The '- 1' is necessary as bitlength(q) = bitlength(p) - 1.
726 do 726 do
727 { 727 {
728 gcry_mpi_randomize (v, GNUNET_SECRETSHARING_ELGAMAL_BITS - 1, GCRY_WEAK_RANDOM); 728 gcry_mpi_randomize (v, GNUNET_SECRETSHARING_ELGAMAL_BITS - 1, GCRY_WEAK_RANDOM);
729 } while ((gcry_mpi_cmp_ui (v, 0) == 0) || (gcry_mpi_cmp (v, elgamal_q) >= 0)); 729 } while ((gcry_mpi_cmp_ui (v, 0) == 0) || (gcry_mpi_cmp (v, elgamal_q) >= 0));
@@ -1326,7 +1326,10 @@ insert_round2_element (struct KeygenSession *ks)
1326 1326
1327 d->purpose.size = htonl (element_size - offsetof (struct GNUNET_SECRETSHARING_KeygenRevealData, purpose)); 1327 d->purpose.size = htonl (element_size - offsetof (struct GNUNET_SECRETSHARING_KeygenRevealData, purpose));
1328 d->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2); 1328 d->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2);
1329 GNUNET_CRYPTO_eddsa_sign (my_peer_private_key, &d->purpose, &d->signature); 1329 GNUNET_assert (GNUNET_OK ==
1330 GNUNET_CRYPTO_eddsa_sign (my_peer_private_key,
1331 &d->purpose,
1332 &d->signature));
1330 1333
1331 GNUNET_CONSENSUS_insert (ks->consensus, element, NULL, NULL); 1334 GNUNET_CONSENSUS_insert (ks->consensus, element, NULL, NULL);
1332 GNUNET_free (element); /* FIXME: maybe stack-allocate instead? */ 1335 GNUNET_free (element); /* FIXME: maybe stack-allocate instead? */
@@ -1477,7 +1480,7 @@ keygen_round2_new_element (void *cls,
1477 gcry_mpi_set_ui (ks->public_key, 1); 1480 gcry_mpi_set_ui (ks->public_key, 1);
1478 } 1481 }
1479 gcry_mpi_mulm (ks->public_key, ks->public_key, public_key_share, elgamal_p); 1482 gcry_mpi_mulm (ks->public_key, ks->public_key, public_key_share, elgamal_p);
1480 1483
1481 gcry_mpi_release (public_key_share); 1484 gcry_mpi_release (public_key_share);
1482 public_key_share = NULL; 1485 public_key_share = NULL;
1483 1486
@@ -1551,7 +1554,7 @@ keygen_round2_new_element (void *cls,
1551 // Using pow(double,double) is a bit sketchy. 1554 // Using pow(double,double) is a bit sketchy.
1552 // We count players from 1, but shares from 0. 1555 // We count players from 1, but shares from 0.
1553 gcry_mpi_t tmp; 1556 gcry_mpi_t tmp;
1554 gcry_mpi_set_ui (j_to_k, (unsigned int) pow(j+1, k)); 1557 gcry_mpi_set_ui (j_to_k, (unsigned int) pow(j+1, k));
1555 tmp = keygen_reveal_get_exp_coeff (ks, d, k); 1558 tmp = keygen_reveal_get_exp_coeff (ks, d, k);
1556 gcry_mpi_powm (tmp, tmp, j_to_k, elgamal_p); 1559 gcry_mpi_powm (tmp, tmp, j_to_k, elgamal_p);
1557 gcry_mpi_mulm (prod, prod, tmp, elgamal_p); 1560 gcry_mpi_mulm (prod, prod, tmp, elgamal_p);
@@ -1583,7 +1586,7 @@ keygen_round2_new_element (void *cls,
1583 } 1586 }
1584 1587
1585 } 1588 }
1586 1589
1587 info->round2_valid = GNUNET_YES; 1590 info->round2_valid = GNUNET_YES;
1588 1591
1589 gcry_mpi_release (preshare); 1592 gcry_mpi_release (preshare);
@@ -1876,7 +1879,7 @@ decrypt_new_element (void *cls,
1876 d = element->data; 1879 d = element->data;
1877 1880
1878 info = get_decrypt_peer_info (session, &d->peer); 1881 info = get_decrypt_peer_info (session, &d->peer);
1879 1882
1880 if (NULL == info) 1883 if (NULL == info)
1881 { 1884 {
1882 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt element from invalid peer (%s)\n", 1885 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "decrypt element from invalid peer (%s)\n",
@@ -1901,7 +1904,7 @@ decrypt_new_element (void *cls,
1901 1904
1902 1905
1903 GNUNET_CRYPTO_hash (offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext) + (char *) d, 1906 GNUNET_CRYPTO_hash (offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext) + (char *) d,
1904 offsetof (struct GNUNET_SECRETSHARING_DecryptData, nizk_response) - 1907 offsetof (struct GNUNET_SECRETSHARING_DecryptData, nizk_response) -
1905 offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext), 1908 offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext),
1906 &challenge_hash); 1909 &challenge_hash);
1907 1910
@@ -2044,7 +2047,7 @@ insert_decrypt_element (struct DecryptSession *ds)
2044 2047
2045 // create the zero knowledge proof 2048 // create the zero knowledge proof
2046 // randomly choose beta such that 0 < beta < q 2049 // randomly choose beta such that 0 < beta < q
2047 do 2050 do
2048 { 2051 {
2049 gcry_mpi_randomize (beta, GNUNET_SECRETSHARING_ELGAMAL_BITS - 1, GCRY_WEAK_RANDOM); 2052 gcry_mpi_randomize (beta, GNUNET_SECRETSHARING_ELGAMAL_BITS - 1, GCRY_WEAK_RANDOM);
2050 } while ((gcry_mpi_cmp_ui (beta, 0) == 0) || (gcry_mpi_cmp (beta, elgamal_q) >= 0)); 2053 } while ((gcry_mpi_cmp_ui (beta, 0) == 0) || (gcry_mpi_cmp (beta, elgamal_q) >= 0));
@@ -2057,7 +2060,7 @@ insert_decrypt_element (struct DecryptSession *ds)
2057 2060
2058 // the challenge is the hash of everything up to the response 2061 // the challenge is the hash of everything up to the response
2059 GNUNET_CRYPTO_hash (offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext) + (char *) &d, 2062 GNUNET_CRYPTO_hash (offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext) + (char *) &d,
2060 offsetof (struct GNUNET_SECRETSHARING_DecryptData, nizk_response) - 2063 offsetof (struct GNUNET_SECRETSHARING_DecryptData, nizk_response) -
2061 offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext), 2064 offsetof (struct GNUNET_SECRETSHARING_DecryptData, ciphertext),
2062 &challenge_hash); 2065 &challenge_hash);
2063 2066
@@ -2073,7 +2076,7 @@ insert_decrypt_element (struct DecryptSession *ds)
2073 2076
2074 d.purpose.size = htonl (element.size - offsetof (struct GNUNET_SECRETSHARING_DecryptData, purpose)); 2077 d.purpose.size = htonl (element.size - offsetof (struct GNUNET_SECRETSHARING_DecryptData, purpose));
2075 d.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DECRYPTION); 2078 d.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DECRYPTION);
2076 2079
2077 GNUNET_CRYPTO_eddsa_sign (my_peer_private_key, &d.purpose, &d.signature); 2080 GNUNET_CRYPTO_eddsa_sign (my_peer_private_key, &d.purpose, &d.signature);
2078 2081
2079 GNUNET_CONSENSUS_insert (ds->consensus, &element, NULL, NULL); 2082 GNUNET_CONSENSUS_insert (ds->consensus, &element, NULL, NULL);