aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2014-05-07 17:03:09 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2014-05-07 17:03:09 +0000
commit8046158a912f5f2283f2f2e821934df41d4d9b5e (patch)
tree81da4bd6c6a53dc1e3d5db5563e2912e32eb7876 /src/scalarproduct
parent841877d9c42928f3dd34d2b595c0c0ccd7b959f4 (diff)
downloadgnunet-8046158a912f5f2283f2f2e821934df41d4d9b5e.tar.gz
gnunet-8046158a912f5f2283f2f2e821934df41d4d9b5e.zip
- session->remote_pubkey is not kept independently from the service structure
Diffstat (limited to 'src/scalarproduct')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index 5e40f2d65..e3a2d5513 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -56,9 +56,24 @@ enum PeerRole
56 */ 56 */
57struct SortedValue 57struct SortedValue
58{ 58{
59 /**
60 * Sorted Values are kept in a DLL
61 */
59 struct SortedValue * next; 62 struct SortedValue * next;
63
64 /**
65 * Sorted Values are kept in a DLL
66 */
60 struct SortedValue * prev; 67 struct SortedValue * prev;
68
69 /**
70 * The element's id+integer-value
71 */
61 struct GNUNET_SCALARPRODUCT_Element * elem; 72 struct GNUNET_SCALARPRODUCT_Element * elem;
73
74 /**
75 * the element's value converted to MPI
76 */
62 gcry_mpi_t val; 77 gcry_mpi_t val;
63}; 78};
64 79
@@ -96,7 +111,7 @@ struct ServiceSession
96 * Alice or Bob's peerID 111 * Alice or Bob's peerID
97 */ 112 */
98 struct GNUNET_PeerIdentity peer; 113 struct GNUNET_PeerIdentity peer;
99 114
100 /** 115 /**
101 * the client this request is related to 116 * the client this request is related to
102 */ 117 */
@@ -152,7 +167,7 @@ struct ServiceSession
152 /** 167 /**
153 * Public key of the remote service, only used by bob 168 * Public key of the remote service, only used by bob
154 */ 169 */
155 struct GNUNET_CRYPTO_PaillierPublicKey remote_pubkey; 170 struct GNUNET_CRYPTO_PaillierPublicKey * remote_pubkey;
156 171
157 /** 172 /**
158 * DLL for sorting elements after intersection 173 * DLL for sorting elements after intersection
@@ -463,6 +478,10 @@ free_session_variables (struct ServiceSession * session)
463 GNUNET_free (session->e_a); 478 GNUNET_free (session->e_a);
464 session->e_a = NULL; 479 session->e_a = NULL;
465 } 480 }
481 if (session->remote_pubkey){
482 GNUNET_free(session->remote_pubkey);
483 session->remote_pubkey=NULL;
484 }
466 if (session->sorted_elements) { 485 if (session->sorted_elements) {
467 GNUNET_free (session->sorted_elements); 486 GNUNET_free (session->sorted_elements);
468 session->sorted_elements = NULL; 487 session->sorted_elements = NULL;
@@ -914,13 +933,13 @@ compute_service_response (struct ServiceSession * session)
914 // E(S - r_pi - b_pi) 933 // E(S - r_pi - b_pi)
915 gcry_mpi_sub (tmp, my_offset, rand[p[i]]); 934 gcry_mpi_sub (tmp, my_offset, rand[p[i]]);
916 gcry_mpi_sub (tmp, tmp, b[p[i]]); 935 gcry_mpi_sub (tmp, tmp, b[p[i]]);
917 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 936 GNUNET_CRYPTO_paillier_encrypt (session->remote_pubkey,
918 tmp, 937 tmp,
919 2, 938 2,
920 &r[i]); 939 &r[i]);
921 940
922 // E(S - r_pi - b_pi) * E(S + a_pi) == E(2*S + a - r - b) 941 // E(S - r_pi - b_pi) * E(S + a_pi) == E(2*S + a - r - b)
923 GNUNET_CRYPTO_paillier_hom_add (&session->remote_pubkey, 942 GNUNET_CRYPTO_paillier_hom_add (session->remote_pubkey,
924 &r[i], 943 &r[i],
925 &a[p[i]], 944 &a[p[i]],
926 &r[i]); 945 &r[i]);
@@ -930,13 +949,13 @@ compute_service_response (struct ServiceSession * session)
930 for (i = 0; i < count; i++) { 949 for (i = 0; i < count; i++) {
931 // E(S - r_qi) 950 // E(S - r_qi)
932 gcry_mpi_sub (tmp, my_offset, rand[q[i]]); 951 gcry_mpi_sub (tmp, my_offset, rand[q[i]]);
933 GNUNET_assert (2 == GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 952 GNUNET_assert (2 == GNUNET_CRYPTO_paillier_encrypt (session->remote_pubkey,
934 tmp, 953 tmp,
935 2, 954 2,
936 &r_prime[i])); 955 &r_prime[i]));
937 956
938 // E(S - r_qi) * E(S + a_qi) == E(2*S + a_qi - r_qi) 957 // E(S - r_qi) * E(S + a_qi) == E(2*S + a_qi - r_qi)
939 GNUNET_assert (1 == GNUNET_CRYPTO_paillier_hom_add (&session->remote_pubkey, 958 GNUNET_assert (1 == GNUNET_CRYPTO_paillier_hom_add (session->remote_pubkey,
940 &r_prime[i], 959 &r_prime[i],
941 &a[q[i]], 960 &a[q[i]],
942 &r_prime[i])); 961 &r_prime[i]));
@@ -944,7 +963,7 @@ compute_service_response (struct ServiceSession * session)
944 963
945 // Calculate S' = E(SUM( r_i^2 )) 964 // Calculate S' = E(SUM( r_i^2 ))
946 tmp = compute_square_sum (rand, count); 965 tmp = compute_square_sum (rand, count);
947 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 966 GNUNET_CRYPTO_paillier_encrypt (session->remote_pubkey,
948 tmp, 967 tmp,
949 1, 968 1,
950 s_prime); 969 s_prime);
@@ -953,7 +972,7 @@ compute_service_response (struct ServiceSession * session)
953 for (i = 0; i < count; i++) 972 for (i = 0; i < count; i++)
954 gcry_mpi_add (rand[i], rand[i], b[i]); 973 gcry_mpi_add (rand[i], rand[i], b[i]);
955 tmp = compute_square_sum (rand, count); 974 tmp = compute_square_sum (rand, count);
956 GNUNET_CRYPTO_paillier_encrypt (&session->remote_pubkey, 975 GNUNET_CRYPTO_paillier_encrypt (session->remote_pubkey,
957 tmp, 976 tmp,
958 1, 977 1,
959 s); 978 s);
@@ -2058,7 +2077,8 @@ handle_alices_computation_request (void *cls,
2058 memcpy (&session->session_id, &msg->session_id, sizeof (struct GNUNET_HashCode)); 2077 memcpy (&session->session_id, &msg->session_id, sizeof (struct GNUNET_HashCode));
2059 2078
2060 // public key 2079 // public key
2061 memcpy (&session->remote_pubkey, &msg->public_key, sizeof (struct GNUNET_CRYPTO_PaillierPublicKey)); 2080 session->remote_pubkey = GNUNET_new (struct GNUNET_CRYPTO_PaillierPublicKey);
2081 memcpy (session->remote_pubkey, &msg->public_key, sizeof (struct GNUNET_CRYPTO_PaillierPublicKey));
2062 2082
2063 //check if service queue contains a matching request 2083 //check if service queue contains a matching request
2064 client_session = find_matching_session (from_client_tail, 2084 client_session = find_matching_session (from_client_tail,