aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-03-07 08:15:58 +0000
committerChristian Grothoff <christian@grothoff.org>2014-03-07 08:15:58 +0000
commit68c7464f2559dbebaac0e524b85811172f86f6e3 (patch)
tree4cf9a2ef3dfb2a064fa2270f29c529a65cbfde47 /src/scalarproduct
parentc0cad451859c8fa28ce1e3d50c21a208974f9e24 (diff)
downloadgnunet-68c7464f2559dbebaac0e524b85811172f86f6e3.tar.gz
gnunet-68c7464f2559dbebaac0e524b85811172f86f6e3.zip
-fix FTBFS
Diffstat (limited to 'src/scalarproduct')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index 67ddbc06a..d21ff2b96 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -23,8 +23,9 @@
23 * @brief scalarproduct service implementation 23 * @brief scalarproduct service implementation
24 * @author Christian M. Fuchs 24 * @author Christian M. Fuchs
25 */ 25 */
26#include <limits.h>
27#include "platform.h" 26#include "platform.h"
27#include <limits.h>
28#include <gcrypt.h>
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_core_service.h" 30#include "gnunet_core_service.h"
30#include "gnunet_mesh_service.h" 31#include "gnunet_mesh_service.h"
@@ -155,7 +156,7 @@ struct ServiceSession
155 /** 156 /**
156 * Public key of the remote service, only used by bob 157 * Public key of the remote service, only used by bob
157 */ 158 */
158 gcry_sexp_t remote_pubkey; 159 struct GNUNET_CRYPTO_PaillierPublicKey remote_pubkey;
159 160
160 /** 161 /**
161 * E(ai)(Bob) or ai(Alice) after applying the mask 162 * E(ai)(Bob) or ai(Alice) after applying the mask
@@ -710,11 +711,9 @@ free_session_variables (struct ServiceSession * session)
710 session->product = NULL; 711 session->product = NULL;
711 } 712 }
712 713
713 if (session->remote_pubkey) { 714 memset (&session->remote_pubkey,
714 gcry_sexp_release (session->remote_pubkey); 715 0,
715 session->remote_pubkey = NULL; 716 sizeof (session->remote_pubkey));
716 }
717
718 if (session->vector) { 717 if (session->vector) {
719 GNUNET_free_non_null (session->vector); 718 GNUNET_free_non_null (session->vector);
720 session->s = NULL; 719 session->s = NULL;
@@ -1190,11 +1189,11 @@ compute_service_response (struct ServiceSession * request,
1190 gcry_mpi_t * b_pi; 1189 gcry_mpi_t * b_pi;
1191 gcry_mpi_t * rand_pi; 1190 gcry_mpi_t * rand_pi;
1192 gcry_mpi_t * rand_pi_prime; 1191 gcry_mpi_t * rand_pi_prime;
1193 gcry_mpi_t s = NULL; 1192 gcry_mpi_t * s = NULL;
1194 struct GNUNET_CRYPTO_PaillierCiphertext * S; 1193 struct GNUNET_CRYPTO_PaillierCiphertext * S;
1195 gcry_mpi_t s_prime = NULL; 1194 gcry_mpi_t s_prime = NULL;
1196 struct GNUNET_CRYPTO_PaillierCiphertext * S_prime; 1195 struct GNUNET_CRYPTO_PaillierCiphertext * S_prime;
1197 1196
1198 uint32_t value; 1197 uint32_t value;
1199 1198
1200 count = request->used; 1199 count = request->used;
@@ -1258,7 +1257,7 @@ compute_service_response (struct ServiceSession * request,
1258 memcpy (b_pi, b, sizeof (gcry_mpi_t) * count); 1257 memcpy (b_pi, b, sizeof (gcry_mpi_t) * count);
1259 memcpy (rand_pi, rand, sizeof (gcry_mpi_t) * count); 1258 memcpy (rand_pi, rand, sizeof (gcry_mpi_t) * count);
1260 memcpy (rand_pi_prime, rand, sizeof (gcry_mpi_t) * count); 1259 memcpy (rand_pi_prime, rand, sizeof (gcry_mpi_t) * count);
1261 1260
1262 //todo get API-cryptoblocks, instead of MPI values 1261 //todo get API-cryptoblocks, instead of MPI values
1263 1262
1264 // generate p and q permutations for a, b and r 1263 // generate p and q permutations for a, b and r
@@ -1279,15 +1278,15 @@ compute_service_response (struct ServiceSession * request,
1279 // E(S - r_pi - b_pi) 1278 // E(S - r_pi - b_pi)
1280 gcry_mpi_sub (r[i], my_offset, rand_pi[i]); 1279 gcry_mpi_sub (r[i], my_offset, rand_pi[i]);
1281 gcry_mpi_sub (r[i], r[i], b_pi[i]); 1280 gcry_mpi_sub (r[i], r[i], b_pi[i]);
1282 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey, 1281 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey,
1283 r[i], 1282 r[i],
1284 2, 1283 2,
1285 &R[i]); 1284 &R[i]);
1286 1285
1287 // E(S - r_pi - b_pi) * E(S + a_pi) == E(2*S + a - r - b) 1286 // E(S - r_pi - b_pi) * E(S + a_pi) == E(2*S + a - r - b)
1288 GNUNET_CRYPTO_paillier_hom_add (&request->remote_pubkey, 1287 GNUNET_CRYPTO_paillier_hom_add (&request->remote_pubkey,
1289 &R[i], 1288 &R[i],
1290 &A_pi[i], 1289 &a_pi[i],
1291 &R[i]); 1290 &R[i]);
1292 } 1291 }
1293 GNUNET_free (a_pi); 1292 GNUNET_free (a_pi);
@@ -1299,16 +1298,15 @@ compute_service_response (struct ServiceSession * request,
1299 { 1298 {
1300 // E(S - r_qi) 1299 // E(S - r_qi)
1301 gcry_mpi_sub (r_prime[i], my_offset, rand_pi_prime[i]); 1300 gcry_mpi_sub (r_prime[i], my_offset, rand_pi_prime[i]);
1302 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey, 1301 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey,
1303 r_prime[i], 1302 r_prime[i],
1304 2, 1303 2,
1305 &R_prime[i]); 1304 &R_prime[i]);
1306 1305
1307 // E(S - r_qi) * E(S + a_qi) == E(2*S + a_qi - r_qi) 1306 // E(S - r_qi) * E(S + a_qi) == E(2*S + a_qi - r_qi)
1308 GNUNET_CRYPTO_paillier_hom_add (&request->remote_pubkey, 1307 GNUNET_CRYPTO_paillier_hom_add (&request->remote_pubkey,
1309 &R_prime[i], 1308 &R_prime[i],
1310 &A_pi_prime[i], 1309 &a_pi_prime[i],
1311 2,
1312 &R_prime[i]); 1310 &R_prime[i]);
1313 } 1311 }
1314 GNUNET_free (a_pi_prime); 1312 GNUNET_free (a_pi_prime);
@@ -1320,8 +1318,8 @@ compute_service_response (struct ServiceSession * request,
1320 1318
1321 // Calculate S' = E(SUM( r_i^2 )) 1319 // Calculate S' = E(SUM( r_i^2 ))
1322 s_prime = compute_square_sum (rand, count); 1320 s_prime = compute_square_sum (rand, count);
1323 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey, 1321 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey,
1324 s_prime, 1322 s_prime,
1325 1, 1323 1,
1326 &S_prime); 1324 &S_prime);
1327 1325
@@ -1330,7 +1328,7 @@ compute_service_response (struct ServiceSession * request,
1330 gcry_mpi_add (rand[i], rand[i], b[i]); 1328 gcry_mpi_add (rand[i], rand[i], b[i]);
1331 } 1329 }
1332 s = compute_square_sum (rand, count); 1330 s = compute_square_sum (rand, count);
1333 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey, 1331 GNUNET_CRYPTO_paillier_encrypt (&request->remote_pubkey,
1334 s[i], 1332 s[i],
1335 1, 1333 1,
1336 &S); 1334 &S);
@@ -1424,7 +1422,7 @@ prepare_service_request_multipart (void *cls)
1424 1422
1425 session->a[session->transferred + j++] = gcry_mpi_set (NULL, a); 1423 session->a[session->transferred + j++] = gcry_mpi_set (NULL, a);
1426 gcry_mpi_add (a, a, my_offset); 1424 gcry_mpi_add (a, a, my_offset);
1427 encrypt_element (a, a, my_g, my_n, my_nsquare); 1425 // FIXME: encrypt_element (a, a, my_g, my_n, my_nsquare);
1428 1426
1429 // get representation as string 1427 // get representation as string
1430 // we always supply some value, so gcry_mpi_print fails only if it can't reserve memory 1428 // we always supply some value, so gcry_mpi_print fails only if it can't reserve memory
@@ -1552,7 +1550,7 @@ prepare_service_request (void *cls,
1552 1550
1553 session->a[j++] = gcry_mpi_set (NULL, a); 1551 session->a[j++] = gcry_mpi_set (NULL, a);
1554 gcry_mpi_add (a, a, my_offset); 1552 gcry_mpi_add (a, a, my_offset);
1555 encrypt_element (a, a, my_g, my_n, my_nsquare); 1553 // FIXME: encrypt_element (a, a, my_g, my_n, my_nsquare);
1556 1554
1557 // get representation as string 1555 // get representation as string
1558 // we always supply some value, so gcry_mpi_print fails only if it can't reserve memory 1556 // we always supply some value, so gcry_mpi_print fails only if it can't reserve memory