diff options
author | Florian Dold <florian.dold@gmail.com> | 2014-02-03 19:46:56 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2014-02-03 19:46:56 +0000 |
commit | b3c8b53879e535dae0a6eb8a05e5157386f9cd41 (patch) | |
tree | 8fe902a91ec6406fddd1d84a6677b9ef09a54f6c /src/util/crypto_paillier.c | |
parent | 5d1bc37b4b364d593e53a7e17038dca722ee3b6f (diff) | |
download | gnunet-b3c8b53879e535dae0a6eb8a05e5157386f9cd41.tar.gz gnunet-b3c8b53879e535dae0a6eb8a05e5157386f9cd41.zip |
- encrypt even if no homomorphic operations are possible
- parse ciphertext container correctly
Diffstat (limited to 'src/util/crypto_paillier.c')
-rw-r--r-- | src/util/crypto_paillier.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/util/crypto_paillier.c b/src/util/crypto_paillier.c index 12acefbbe..d47823905 100644 --- a/src/util/crypto_paillier.c +++ b/src/util/crypto_paillier.c | |||
@@ -93,8 +93,7 @@ GNUNET_CRYPTO_paillier_create (struct GNUNET_CRYPTO_PaillierPublicKey *public_ke | |||
93 | * @param public_key Public key to use. | 93 | * @param public_key Public key to use. |
94 | * @param m Plaintext to encrypt. | 94 | * @param m Plaintext to encrypt. |
95 | * @param[out] ciphertext Encrytion of @a plaintext with @a public_key. | 95 | * @param[out] ciphertext Encrytion of @a plaintext with @a public_key. |
96 | * @return guaranteed number of supported homomorphic operations >= 1, | 96 | * @return guaranteed number of supported homomorphic operations, can be zero |
97 | * -1 if less than one homomorphic operation is possible | ||
98 | */ | 97 | */ |
99 | int | 98 | int |
100 | GNUNET_CRYPTO_paillier_encrypt (const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 99 | GNUNET_CRYPTO_paillier_encrypt (const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
@@ -126,12 +125,9 @@ GNUNET_CRYPTO_paillier_encrypt (const struct GNUNET_CRYPTO_PaillierPublicKey *pu | |||
126 | gcry_mpi_release (tmp1); | 125 | gcry_mpi_release (tmp1); |
127 | gcry_mpi_release (tmp2); | 126 | gcry_mpi_release (tmp2); |
128 | 127 | ||
129 | // can we do at least one homomorphic operation with this value? | ||
130 | if (possible_opts < 1) | 128 | if (possible_opts < 1) |
131 | // no, don't use paillier please! | 129 | possible_opts = 0; |
132 | return -1; | 130 | ciphertext->remaining_ops = htonl (possible_opts); |
133 | else | ||
134 | ciphertext->remaining_ops = htonl (possible_opts); | ||
135 | 131 | ||
136 | GNUNET_assert (0 != (n_square = gcry_mpi_new (0))); | 132 | GNUNET_assert (0 != (n_square = gcry_mpi_new (0))); |
137 | GNUNET_assert (0 != (r = gcry_mpi_new (0))); | 133 | GNUNET_assert (0 != (r = gcry_mpi_new (0))); |
@@ -193,7 +189,7 @@ GNUNET_CRYPTO_paillier_decrypt (const struct GNUNET_CRYPTO_PaillierPrivateKey *p | |||
193 | GNUNET_CRYPTO_mpi_scan_unsigned (&lambda, private_key->lambda, sizeof private_key->lambda); | 189 | GNUNET_CRYPTO_mpi_scan_unsigned (&lambda, private_key->lambda, sizeof private_key->lambda); |
194 | GNUNET_CRYPTO_mpi_scan_unsigned (&mu, private_key->mu, sizeof private_key->mu); | 190 | GNUNET_CRYPTO_mpi_scan_unsigned (&mu, private_key->mu, sizeof private_key->mu); |
195 | GNUNET_CRYPTO_mpi_scan_unsigned (&n, public_key, sizeof *public_key); | 191 | GNUNET_CRYPTO_mpi_scan_unsigned (&n, public_key, sizeof *public_key); |
196 | GNUNET_CRYPTO_mpi_scan_unsigned (&c, ciphertext, sizeof *ciphertext); | 192 | GNUNET_CRYPTO_mpi_scan_unsigned (&c, ciphertext->bits, sizeof ciphertext->bits); |
197 | 193 | ||
198 | gcry_mpi_mul (n_square, n, n); | 194 | gcry_mpi_mul (n_square, n, n); |
199 | // m = c^lambda mod n^2 | 195 | // m = c^lambda mod n^2 |