aboutsummaryrefslogtreecommitdiff
path: root/src/multicast
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-10 17:49:53 +0000
committerGabor X Toth <*@tg-x.net>2014-07-10 17:49:53 +0000
commita8133f3ff80aaaccc904e4bbaf69bc53dee499cb (patch)
treec10edd7a8156280c61357ccf9e0f1f27c7a0d6db /src/multicast
parent6c75526e936fcc74ee79b13831b2b6dda57f293d (diff)
downloadgnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.tar.gz
gnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.zip
PSYC(store), Multicast: use ECDSA slave/member keys; PSYC: add GNUNET_PSYC_message_create()
Diffstat (limited to 'src/multicast')
-rw-r--r--src/multicast/gnunet-service-multicast.c25
-rw-r--r--src/multicast/multicast.h13
-rw-r--r--src/multicast/multicast_api.c4
3 files changed, 25 insertions, 17 deletions
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c
index 5421c1b2b..1bb27f96e 100644
--- a/src/multicast/gnunet-service-multicast.c
+++ b/src/multicast/gnunet-service-multicast.c
@@ -148,12 +148,12 @@ struct Member
148 /** 148 /**
149 * Private key of the member. 149 * Private key of the member.
150 */ 150 */
151 struct GNUNET_CRYPTO_EddsaPrivateKey priv_key; 151 struct GNUNET_CRYPTO_EcdsaPrivateKey priv_key;
152 152
153 /** 153 /**
154 * Public key of the member. 154 * Public key of the member.
155 */ 155 */
156 struct GNUNET_CRYPTO_EddsaPublicKey pub_key; 156 struct GNUNET_CRYPTO_EcdsaPublicKey pub_key;
157 157
158 /** 158 /**
159 * Hash of @a pub_key. 159 * Hash of @a pub_key.
@@ -458,11 +458,12 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client,
458{ 458{
459 const struct MulticastMemberJoinMessage * 459 const struct MulticastMemberJoinMessage *
460 msg = (const struct MulticastMemberJoinMessage *) m; 460 msg = (const struct MulticastMemberJoinMessage *) m;
461 uint16_t msg_size = ntohs (msg->header.size);
461 462
462 struct GNUNET_CRYPTO_EddsaPublicKey mem_pub_key; 463 struct GNUNET_CRYPTO_EcdsaPublicKey mem_pub_key;
463 struct GNUNET_HashCode pub_key_hash, mem_pub_key_hash; 464 struct GNUNET_HashCode pub_key_hash, mem_pub_key_hash;
464 465
465 GNUNET_CRYPTO_eddsa_key_get_public (&msg->member_key, &mem_pub_key); 466 GNUNET_CRYPTO_ecdsa_key_get_public (&msg->member_key, &mem_pub_key);
466 GNUNET_CRYPTO_hash (&mem_pub_key, sizeof (mem_pub_key), &mem_pub_key_hash); 467 GNUNET_CRYPTO_hash (&mem_pub_key, sizeof (mem_pub_key), &mem_pub_key_hash);
467 GNUNET_CRYPTO_hash (&msg->group_key, sizeof (msg->group_key), &pub_key_hash); 468 GNUNET_CRYPTO_hash (&msg->group_key, sizeof (msg->group_key), &pub_key_hash);
468 469
@@ -532,12 +533,18 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client,
532 struct GNUNET_MessageHeader *join_msg = NULL; 533 struct GNUNET_MessageHeader *join_msg = NULL;
533 uint16_t join_msg_size = 0; 534 uint16_t join_msg_size = 0;
534 if (sizeof (*msg) + relay_size + sizeof (struct GNUNET_MessageHeader) 535 if (sizeof (*msg) + relay_size + sizeof (struct GNUNET_MessageHeader)
535 <= ntohs (msg->header.size)) 536 <= msg_size)
536 { 537 {
537 join_msg = (struct GNUNET_MessageHeader *) 538 join_msg = (struct GNUNET_MessageHeader *)
538 (((char *) &msg[1]) + relay_size); 539 (((char *) &msg[1]) + relay_size);
539 join_msg_size = ntohs (join_msg->size); 540 join_msg_size = ntohs (join_msg->size);
540 } 541 }
542 if (sizeof (*msg) + relay_size + join_msg_size != msg_size)
543 {
544 GNUNET_break (0);
545 GNUNET_SERVER_client_disconnect (client);
546 return;
547 }
541 548
542 struct MulticastJoinRequestMessage * 549 struct MulticastJoinRequestMessage *
543 req = GNUNET_malloc (sizeof (*req) + join_msg_size); 550 req = GNUNET_malloc (sizeof (*req) + join_msg_size);
@@ -545,7 +552,7 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client,
545 req->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST); 552 req->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST);
546 req->group_key = grp->pub_key; 553 req->group_key = grp->pub_key;
547 req->member_peer = this_peer; 554 req->member_peer = this_peer;
548 GNUNET_CRYPTO_eddsa_key_get_public (&mem->priv_key, &req->member_key); 555 GNUNET_CRYPTO_ecdsa_key_get_public (&mem->priv_key, &req->member_key);
549 if (0 < join_msg_size) 556 if (0 < join_msg_size)
550 memcpy (&req[1], join_msg, join_msg_size); 557 memcpy (&req[1], join_msg, join_msg_size);
551 558
@@ -554,7 +561,7 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client,
554 - sizeof (req->signature)); 561 - sizeof (req->signature));
555 req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); 562 req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST);
556 563
557 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&mem->priv_key, &req->purpose, 564 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose,
558 &req->signature)) 565 &req->signature))
559 { 566 {
560 /* FIXME: handle error */ 567 /* FIXME: handle error */
@@ -700,7 +707,7 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client,
700 - sizeof (req->signature)); 707 - sizeof (req->signature));
701 req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); 708 req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST);
702 709
703 if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&mem->priv_key, &req->purpose, 710 if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose,
704 &req->signature)) 711 &req->signature))
705 { 712 {
706 /* FIXME: handle error */ 713 /* FIXME: handle error */
@@ -721,7 +728,7 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client,
721 728
722 729
723/** 730/**
724 * Core connected. 731 * Connected to core service.
725 */ 732 */
726static void 733static void
727core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) 734core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity)
diff --git a/src/multicast/multicast.h b/src/multicast/multicast.h
index 76492e868..9abf3802c 100644
--- a/src/multicast/multicast.h
+++ b/src/multicast/multicast.h
@@ -50,7 +50,7 @@ struct MulticastJoinRequestMessage
50 * 50 *
51 * Signature must match the public key of the joining member. 51 * Signature must match the public key of the joining member.
52 */ 52 */
53 struct GNUNET_CRYPTO_EddsaSignature signature; 53 struct GNUNET_CRYPTO_EcdsaSignature signature;
54 54
55 /** 55 /**
56 * Purpose for the signature and size of the signed data. 56 * Purpose for the signature and size of the signed data.
@@ -65,7 +65,7 @@ struct MulticastJoinRequestMessage
65 /** 65 /**
66 * Public key of the joining member. 66 * Public key of the joining member.
67 */ 67 */
68 struct GNUNET_CRYPTO_EddsaPublicKey member_key; 68 struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
69 69
70 /** 70 /**
71 * Peer identity of the joining member. 71 * Peer identity of the joining member.
@@ -125,7 +125,7 @@ struct MulticastJoinDecisionMessageHeader
125 * C->S: Public key of the member requesting join. 125 * C->S: Public key of the member requesting join.
126 * S->C: Unused. 126 * S->C: Unused.
127 */ 127 */
128 struct GNUNET_CRYPTO_EddsaPublicKey member_key; 128 struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
129 129
130 /* Followed by struct MulticastJoinDecisionMessage */ 130 /* Followed by struct MulticastJoinDecisionMessage */
131}; 131};
@@ -244,12 +244,13 @@ struct MulticastMemberJoinMessage
244 244
245 struct GNUNET_CRYPTO_EddsaPublicKey group_key; 245 struct GNUNET_CRYPTO_EddsaPublicKey group_key;
246 246
247 struct GNUNET_CRYPTO_EddsaPrivateKey member_key; 247 struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
248 248
249 struct GNUNET_PeerIdentity origin; 249 struct GNUNET_PeerIdentity origin;
250 250
251 /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ 251 /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */
252 /* Followed by struct GNUNET_MessageHeader join_request */ 252
253 /* Followed by struct GNUNET_MessageHeader join_msg */
253}; 254};
254 255
255 256
@@ -313,7 +314,7 @@ struct MulticastJoinMessage
313 /** 314 /**
314 * Our private key for the group. 315 * Our private key for the group.
315 */ 316 */
316 struct GNUNET_CRYPTO_EddsaPrivateKey member_key; 317 struct GNUNET_CRYPTO_EcdsaPrivateKey member_key;
317 318
318 /* followed by 'relay_count' `struct GNUNET_PeerIdentity`s */ 319 /* followed by 'relay_count' `struct GNUNET_PeerIdentity`s */
319 320
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c
index b6d51896d..d2a0412bb 100644
--- a/src/multicast/multicast_api.c
+++ b/src/multicast/multicast_api.c
@@ -138,7 +138,7 @@ struct GNUNET_MULTICAST_JoinHandle
138 /** 138 /**
139 * Public key of the member requesting join. 139 * Public key of the member requesting join.
140 */ 140 */
141 struct GNUNET_CRYPTO_EddsaPublicKey member_key; 141 struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
142 142
143 /** 143 /**
144 * Peer identity of the member requesting join. 144 * Peer identity of the member requesting join.
@@ -714,7 +714,7 @@ GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginTransmitHan
714struct GNUNET_MULTICAST_Member * 714struct GNUNET_MULTICAST_Member *
715GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 715GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
716 const struct GNUNET_CRYPTO_EddsaPublicKey *group_key, 716 const struct GNUNET_CRYPTO_EddsaPublicKey *group_key,
717 const struct GNUNET_CRYPTO_EddsaPrivateKey *member_key, 717 const struct GNUNET_CRYPTO_EcdsaPrivateKey *member_key,
718 const struct GNUNET_PeerIdentity *origin, 718 const struct GNUNET_PeerIdentity *origin,
719 uint16_t relay_count, 719 uint16_t relay_count,
720 const struct GNUNET_PeerIdentity *relays, 720 const struct GNUNET_PeerIdentity *relays,