gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r32170 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r32170 - gnunet/src/util
Date: Mon, 3 Feb 2014 20:46:56 +0100

Author: dold
Date: 2014-02-03 20:46:56 +0100 (Mon, 03 Feb 2014)
New Revision: 32170

Modified:
   gnunet/src/util/crypto_paillier.c
Log:
- encrypt even if no homomorphic operations are possible
- parse ciphertext container correctly


Modified: gnunet/src/util/crypto_paillier.c
===================================================================
--- gnunet/src/util/crypto_paillier.c   2014-02-03 18:46:22 UTC (rev 32169)
+++ gnunet/src/util/crypto_paillier.c   2014-02-03 19:46:56 UTC (rev 32170)
@@ -93,8 +93,7 @@
  * @param public_key Public key to use.
  * @param m Plaintext to encrypt.
  * @param[out] ciphertext Encrytion of @a plaintext with @a public_key.
- * @return guaranteed number of supported homomorphic operations >= 1, 
- *         -1 if less than one homomorphic operation is possible
+ * @return guaranteed number of supported homomorphic operations, can be zero
  */
 int
 GNUNET_CRYPTO_paillier_encrypt (const struct GNUNET_CRYPTO_PaillierPublicKey 
*public_key,
@@ -126,12 +125,9 @@
   gcry_mpi_release (tmp1);
   gcry_mpi_release (tmp2);
   
-  // can we do at least one homomorphic operation with this value?
   if (possible_opts < 1)
-    // no, don't use paillier please!
-    return -1;
-  else
-    ciphertext->remaining_ops = htonl (possible_opts);
+    possible_opts = 0;
+  ciphertext->remaining_ops = htonl (possible_opts);
 
   GNUNET_assert (0 != (n_square = gcry_mpi_new (0)));
   GNUNET_assert (0 != (r = gcry_mpi_new (0)));
@@ -193,7 +189,7 @@
   GNUNET_CRYPTO_mpi_scan_unsigned (&lambda, private_key->lambda, sizeof 
private_key->lambda);
   GNUNET_CRYPTO_mpi_scan_unsigned (&mu, private_key->mu, sizeof 
private_key->mu);
   GNUNET_CRYPTO_mpi_scan_unsigned (&n, public_key, sizeof *public_key);
-  GNUNET_CRYPTO_mpi_scan_unsigned (&c, ciphertext, sizeof *ciphertext);
+  GNUNET_CRYPTO_mpi_scan_unsigned (&c, ciphertext->bits, sizeof 
ciphertext->bits);
 
   gcry_mpi_mul (n_square, n, n);
   // m = c^lambda mod n^2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]