aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r--src/gns/gnunet-service-gns.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index fcfa4b138..8200e3f87 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -382,7 +382,7 @@ publish_zone_dht_start (void *cls,
382 */ 382 */
383static void 383static void
384put_gns_record (void *cls, 384put_gns_record (void *cls,
385 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 385 const struct GNUNET_CRYPTO_EccPublicKey *key,
386 struct GNUNET_TIME_Absolute expiration, 386 struct GNUNET_TIME_Absolute expiration,
387 const char *name, 387 const char *name,
388 unsigned int rd_count, 388 unsigned int rd_count,
@@ -486,7 +486,7 @@ put_gns_record (void *cls,
486 nrb_data += namelen; 486 nrb_data += namelen;
487 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen; 487 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen;
488 GNUNET_CRYPTO_short_hash (key, 488 GNUNET_CRYPTO_short_hash (key,
489 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 489 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
490 &zhash); 490 &zhash);
491 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count, 491 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count,
492 rd, 492 rd,
@@ -637,7 +637,7 @@ send_shorten_response (void* cls, const char* name)
637 */ 637 */
638static void 638static void
639process_shorten_in_private_zone_lookup (void *cls, 639process_shorten_in_private_zone_lookup (void *cls,
640 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 640 const struct GNUNET_CRYPTO_EccPublicKey *key,
641 struct GNUNET_TIME_Absolute expiration, 641 struct GNUNET_TIME_Absolute expiration,
642 const char *name, 642 const char *name,
643 unsigned int rd_count, 643 unsigned int rd_count,
@@ -693,7 +693,7 @@ process_shorten_in_private_zone_lookup (void *cls,
693 */ 693 */
694static void 694static void
695process_shorten_in_root_zone_lookup (void *cls, 695process_shorten_in_root_zone_lookup (void *cls,
696 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 696 const struct GNUNET_CRYPTO_EccPublicKey *key,
697 struct GNUNET_TIME_Absolute expiration, 697 struct GNUNET_TIME_Absolute expiration,
698 const char *name, 698 const char *name,
699 unsigned int rd_count, 699 unsigned int rd_count,
@@ -749,7 +749,7 @@ process_shorten_in_root_zone_lookup (void *cls,
749 */ 749 */
750static void 750static void
751process_private_in_root_zone_lookup (void *cls, 751process_private_in_root_zone_lookup (void *cls,
752 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 752 const struct GNUNET_CRYPTO_EccPublicKey *key,
753 struct GNUNET_TIME_Absolute expiration, 753 struct GNUNET_TIME_Absolute expiration,
754 const char *name, 754 const char *name,
755 unsigned int rd_count, 755 unsigned int rd_count,
@@ -1075,9 +1075,7 @@ handle_lookup (void *cls,
1075 char* nameptr = name; 1075 char* nameptr = name;
1076 const char *utf_in; 1076 const char *utf_in;
1077 int only_cached; 1077 int only_cached;
1078 struct GNUNET_CRYPTO_EccPrivateKey *key; 1078 const struct GNUNET_CRYPTO_EccPrivateKey *key;
1079 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkey;
1080 char* tmp_pkey;
1081 uint16_t msg_size; 1079 uint16_t msg_size;
1082 const struct GNUNET_GNS_ClientLookupMessage *sh_msg; 1080 const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
1083 1081
@@ -1094,24 +1092,20 @@ handle_lookup (void *cls,
1094 GNUNET_SERVER_notification_context_add (nc, client); 1092 GNUNET_SERVER_notification_context_add (nc, client);
1095 if (GNUNET_YES == ntohl (sh_msg->have_key)) 1093 if (GNUNET_YES == ntohl (sh_msg->have_key))
1096 { 1094 {
1097 pkey = (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *) &sh_msg[1]; 1095 key = &sh_msg->shorten_key;
1098 tmp_pkey = (char*) &sh_msg[1];
1099 key = GNUNET_CRYPTO_ecc_decode_key (tmp_pkey, ntohs (pkey->size),
1100 GNUNET_NO);
1101 GNUNET_STRINGS_utf8_tolower (&tmp_pkey[ntohs (pkey->size)], &nameptr);
1102 } 1096 }
1103 else 1097 else
1104 { 1098 {
1105 key = NULL; 1099 key = NULL;
1106 utf_in = (const char *) &sh_msg[1];
1107 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientLookupMessage) - 1])
1108 {
1109 GNUNET_break (0);
1110 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1111 return;
1112 }
1113 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
1114 } 1100 }
1101 utf_in = (const char *) &sh_msg[1];
1102 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientLookupMessage) - 1])
1103 {
1104 GNUNET_break (0);
1105 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1106 return;
1107 }
1108 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
1115 1109
1116 namelen = strlen (name) + 1; 1110 namelen = strlen (name) + 1;
1117 clh = GNUNET_malloc (sizeof (struct ClientLookupHandle)); 1111 clh = GNUNET_malloc (sizeof (struct ClientLookupHandle));
@@ -1121,8 +1115,11 @@ handle_lookup (void *cls,
1121 strcpy (clh->name, name); 1115 strcpy (clh->name, name);
1122 clh->request_id = sh_msg->id; 1116 clh->request_id = sh_msg->id;
1123 clh->type = ntohl (sh_msg->type); 1117 clh->type = ntohl (sh_msg->type);
1124 clh->shorten_key = key; 1118 if (NULL != key)
1125 1119 {
1120 clh->shorten_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
1121 *clh->shorten_key = *key;
1122 }
1126 only_cached = ntohl (sh_msg->only_cached); 1123 only_cached = ntohl (sh_msg->only_cached);
1127 1124
1128 if (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) { 1125 if (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) {
@@ -1153,7 +1150,7 @@ handle_lookup (void *cls,
1153 return; 1150 return;
1154 } 1151 }
1155 1152
1156 if (1 == ntohl (sh_msg->use_default_zone)) 1153 if (GNUNET_NO == ntohl (sh_msg->have_zone))
1157 clh->zone = zone_hash; /* Default zone */ 1154 clh->zone = zone_hash; /* Default zone */
1158 else 1155 else
1159 clh->zone = sh_msg->zone; 1156 clh->zone = sh_msg->zone;
@@ -1196,7 +1193,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1196 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} 1193 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
1197 }; 1194 };
1198 char* keyfile; 1195 char* keyfile;
1199 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 1196 struct GNUNET_CRYPTO_EccPublicKey pkey;
1200 unsigned long long max_parallel_bg_queries = 0; 1197 unsigned long long max_parallel_bg_queries = 0;
1201 int ignore_pending = GNUNET_NO; 1198 int ignore_pending = GNUNET_NO;
1202 1199
@@ -1217,9 +1214,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1217 1214
1218 zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 1215 zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
1219 GNUNET_CRYPTO_ecc_key_get_public (zone_key, &pkey); 1216 GNUNET_CRYPTO_ecc_key_get_public (zone_key, &pkey);
1220 GNUNET_CRYPTO_short_hash(&pkey, 1217 GNUNET_CRYPTO_short_hash (&pkey,
1221 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 1218 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
1222 &zone_hash); 1219 &zone_hash);
1223 GNUNET_free(keyfile); 1220 GNUNET_free(keyfile);
1224 namestore_handle = GNUNET_NAMESTORE_connect (c); 1221 namestore_handle = GNUNET_NAMESTORE_connect (c);
1225 if (NULL == namestore_handle) 1222 if (NULL == namestore_handle)