summaryrefslogtreecommitdiff
path: root/src/gns/gnunet-service-gns.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-05-29 08:18:55 +0000
committerChristian Grothoff <christian@grothoff.org>2013-05-29 08:18:55 +0000
commit022002438e4047d235a688cfd9da7b63ab990103 (patch)
tree8d0cb444a3ab376b5a8f614fb87bdeb31e7b3327 /src/gns/gnunet-service-gns.c
parentb62eb443ee3af84f87030fad9fd11a948b1a2503 (diff)
downloadgnunet-022002438e4047d235a688cfd9da7b63ab990103.tar.gz
gnunet-022002438e4047d235a688cfd9da7b63ab990103.zip
-switching GNS from RSA to ECC
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r--src/gns/gnunet-service-gns.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 16887c62d..517722643 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -168,7 +168,7 @@ struct ClientLookupHandle
168 /** 168 /**
169 * optional zone private key used for shorten 169 * optional zone private key used for shorten
170 */ 170 */
171 struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key; 171 struct GNUNET_CRYPTO_EccPrivateKey *shorten_key;
172 172
173 /** 173 /**
174 * the name to look up 174 * the name to look up
@@ -205,7 +205,7 @@ static struct GNUNET_DHT_Handle *dht_handle;
205/** 205/**
206 * Our zone's private key 206 * Our zone's private key
207 */ 207 */
208static struct GNUNET_CRYPTO_RsaPrivateKey *zone_key; 208static struct GNUNET_CRYPTO_EccPrivateKey *zone_key;
209 209
210/** 210/**
211 * Our handle to the namestore service 211 * Our handle to the namestore service
@@ -382,12 +382,12 @@ 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_RsaPublicKeyBinaryEncoded *key, 385 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *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,
389 const struct GNUNET_NAMESTORE_RecordData *rd, 389 const struct GNUNET_NAMESTORE_RecordData *rd,
390 const struct GNUNET_CRYPTO_RsaSignature *signature) 390 const struct GNUNET_CRYPTO_EccSignature *signature)
391{ 391{
392 struct GNSNameRecordBlock *nrb; 392 struct GNSNameRecordBlock *nrb;
393 struct GNUNET_CRYPTO_ShortHashCode zhash; 393 struct GNUNET_CRYPTO_ShortHashCode zhash;
@@ -475,7 +475,7 @@ put_gns_record (void *cls,
475 nrb_data += namelen; 475 nrb_data += namelen;
476 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen; 476 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen;
477 GNUNET_CRYPTO_short_hash (key, 477 GNUNET_CRYPTO_short_hash (key,
478 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 478 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded),
479 &zhash); 479 &zhash);
480 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count, 480 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count,
481 rd, 481 rd,
@@ -626,12 +626,12 @@ send_shorten_response (void* cls, const char* name)
626 */ 626 */
627static void 627static void
628process_shorten_in_private_zone_lookup (void *cls, 628process_shorten_in_private_zone_lookup (void *cls,
629 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 629 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key,
630 struct GNUNET_TIME_Absolute expiration, 630 struct GNUNET_TIME_Absolute expiration,
631 const char *name, 631 const char *name,
632 unsigned int rd_count, 632 unsigned int rd_count,
633 const struct GNUNET_NAMESTORE_RecordData *rd, 633 const struct GNUNET_NAMESTORE_RecordData *rd,
634 const struct GNUNET_CRYPTO_RsaSignature *signature) 634 const struct GNUNET_CRYPTO_EccSignature *signature)
635{ 635{
636 struct ClientShortenHandle *csh = cls; 636 struct ClientShortenHandle *csh = cls;
637 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone; 637 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
@@ -682,12 +682,12 @@ process_shorten_in_private_zone_lookup (void *cls,
682 */ 682 */
683static void 683static void
684process_shorten_in_root_zone_lookup (void *cls, 684process_shorten_in_root_zone_lookup (void *cls,
685 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 685 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key,
686 struct GNUNET_TIME_Absolute expiration, 686 struct GNUNET_TIME_Absolute expiration,
687 const char *name, 687 const char *name,
688 unsigned int rd_count, 688 unsigned int rd_count,
689 const struct GNUNET_NAMESTORE_RecordData *rd, 689 const struct GNUNET_NAMESTORE_RecordData *rd,
690 const struct GNUNET_CRYPTO_RsaSignature *signature) 690 const struct GNUNET_CRYPTO_EccSignature *signature)
691{ 691{
692 struct ClientShortenHandle *csh = cls; 692 struct ClientShortenHandle *csh = cls;
693 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone; 693 struct GNUNET_CRYPTO_ShortHashCode *szone = &csh->shorten_zone;
@@ -738,12 +738,12 @@ process_shorten_in_root_zone_lookup (void *cls,
738 */ 738 */
739static void 739static void
740process_private_in_root_zone_lookup (void *cls, 740process_private_in_root_zone_lookup (void *cls,
741 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 741 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key,
742 struct GNUNET_TIME_Absolute expiration, 742 struct GNUNET_TIME_Absolute expiration,
743 const char *name, 743 const char *name,
744 unsigned int rd_count, 744 unsigned int rd_count,
745 const struct GNUNET_NAMESTORE_RecordData *rd, 745 const struct GNUNET_NAMESTORE_RecordData *rd,
746 const struct GNUNET_CRYPTO_RsaSignature *signature) 746 const struct GNUNET_CRYPTO_EccSignature *signature)
747{ 747{
748 struct ClientShortenHandle *csh = cls; 748 struct ClientShortenHandle *csh = cls;
749 749
@@ -1036,7 +1036,7 @@ send_lookup_response (void* cls,
1036 GNUNET_free(clh->name); 1036 GNUNET_free(clh->name);
1037 1037
1038 if (NULL != clh->shorten_key) 1038 if (NULL != clh->shorten_key)
1039 GNUNET_CRYPTO_rsa_key_free (clh->shorten_key); 1039 GNUNET_CRYPTO_ecc_key_free (clh->shorten_key);
1040 GNUNET_free (clh); 1040 GNUNET_free (clh);
1041 GNUNET_STATISTICS_update (statistics, 1041 GNUNET_STATISTICS_update (statistics,
1042 "Completed lookups", 1, GNUNET_NO); 1042 "Completed lookups", 1, GNUNET_NO);
@@ -1064,8 +1064,8 @@ handle_lookup (void *cls,
1064 char* nameptr = name; 1064 char* nameptr = name;
1065 const char *utf_in; 1065 const char *utf_in;
1066 int only_cached; 1066 int only_cached;
1067 struct GNUNET_CRYPTO_RsaPrivateKey *key; 1067 struct GNUNET_CRYPTO_EccPrivateKey *key;
1068 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pkey; 1068 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkey;
1069 char* tmp_pkey; 1069 char* tmp_pkey;
1070 uint16_t msg_size; 1070 uint16_t msg_size;
1071 const struct GNUNET_GNS_ClientLookupMessage *sh_msg; 1071 const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
@@ -1083,10 +1083,11 @@ handle_lookup (void *cls,
1083 GNUNET_SERVER_notification_context_add (nc, client); 1083 GNUNET_SERVER_notification_context_add (nc, client);
1084 if (GNUNET_YES == ntohl (sh_msg->have_key)) 1084 if (GNUNET_YES == ntohl (sh_msg->have_key))
1085 { 1085 {
1086 pkey = (struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *) &sh_msg[1]; 1086 pkey = (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *) &sh_msg[1];
1087 tmp_pkey = (char*) &sh_msg[1]; 1087 tmp_pkey = (char*) &sh_msg[1];
1088 key = GNUNET_CRYPTO_rsa_decode_key (tmp_pkey, ntohs (pkey->len)); 1088 key = GNUNET_CRYPTO_ecc_decode_key (tmp_pkey, ntohs (pkey->size),
1089 GNUNET_STRINGS_utf8_tolower (&tmp_pkey[ntohs (pkey->len)], &nameptr); 1089 GNUNET_NO);
1090 GNUNET_STRINGS_utf8_tolower (&tmp_pkey[ntohs (pkey->size)], &nameptr);
1090 } 1091 }
1091 else 1092 else
1092 { 1093 {
@@ -1184,7 +1185,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1184 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} 1185 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
1185 }; 1186 };
1186 char* keyfile; 1187 char* keyfile;
1187 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; 1188 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey;
1188 unsigned long long max_parallel_bg_queries = 0; 1189 unsigned long long max_parallel_bg_queries = 0;
1189 int ignore_pending = GNUNET_NO; 1190 int ignore_pending = GNUNET_NO;
1190 1191
@@ -1203,10 +1204,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1203 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1204 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1204 "Using keyfile %s for root zone.\n", keyfile); 1205 "Using keyfile %s for root zone.\n", keyfile);
1205 1206
1206 zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 1207 zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
1207 GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey); 1208 GNUNET_CRYPTO_ecc_key_get_public (zone_key, &pkey);
1208 GNUNET_CRYPTO_short_hash(&pkey, 1209 GNUNET_CRYPTO_short_hash(&pkey,
1209 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1210 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded),
1210 &zone_hash); 1211 &zone_hash);
1211 GNUNET_free(keyfile); 1212 GNUNET_free(keyfile);
1212 namestore_handle = GNUNET_NAMESTORE_connect (c); 1213 namestore_handle = GNUNET_NAMESTORE_connect (c);