aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-19 18:51:32 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-19 18:51:32 +0000
commitd2fb255905f0c93f50db2112594307bb1265742c (patch)
treee3e9c7387e66ebae147ff4e32224baea046b5ff8 /src
parentcdd5f401a24438425da10a11992c2bfd9992df47 (diff)
downloadgnunet-d2fb255905f0c93f50db2112594307bb1265742c.tar.gz
gnunet-d2fb255905f0c93f50db2112594307bb1265742c.zip
-new short hashes, new short hash cmp
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c15
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c4
-rw-r--r--src/gns/gnunet-service-gns_interceptor.h2
-rw-r--r--src/gns/gnunet-service-gns_resolver.c90
-rw-r--r--src/gns/gnunet-service-gns_resolver.h14
-rw-r--r--src/gns/plugin_block_gns.c15
-rw-r--r--src/gns/test_gns_dht_delegated_lookup.c20
-rw-r--r--src/gns/test_gns_pseu_shorten.c55
-rw-r--r--src/gns/test_gns_simple_delegated_lookup.c6
-rw-r--r--src/gns/test_gns_simple_get_authority.c10
-rw-r--r--src/gns/test_gns_simple_mx_lookup.c6
-rw-r--r--src/gns/test_gns_simple_shorten.c12
-rw-r--r--src/gns/test_gns_simple_zkey_lookup.c10
-rw-r--r--src/include/gnunet_crypto_lib.h12
-rw-r--r--src/util/crypto_hash.c26
15 files changed, 187 insertions, 110 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 9332eba93..bc1a713b6 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -139,7 +139,7 @@ static struct GNUNET_SERVER_NotificationContext *nc;
139/** 139/**
140 * Our zone hash 140 * Our zone hash
141 */ 141 */
142GNUNET_HashCode zone_hash; 142struct GNUNET_CRYPTO_ShortHashCode zone_hash;
143 143
144/** 144/**
145 * Useful for zone update for DHT put 145 * Useful for zone update for DHT put
@@ -228,8 +228,10 @@ put_gns_record(void *cls,
228{ 228{
229 229
230 struct GNSNameRecordBlock *nrb; 230 struct GNSNameRecordBlock *nrb;
231 GNUNET_HashCode name_hash; 231 struct GNUNET_CRYPTO_ShortHashCode name_hash;
232 GNUNET_HashCode xor_hash; 232 GNUNET_HashCode xor_hash;
233 GNUNET_HashCode name_hash_double;
234 GNUNET_HashCode zone_hash_double;
233 struct GNUNET_CRYPTO_HashAsciiEncoded xor_hash_string; 235 struct GNUNET_CRYPTO_HashAsciiEncoded xor_hash_string;
234 uint32_t rd_payload_length; 236 uint32_t rd_payload_length;
235 char* nrb_data = NULL; 237 char* nrb_data = NULL;
@@ -302,8 +304,10 @@ put_gns_record(void *cls,
302 /* 304 /*
303 * calculate DHT key: H(name) xor H(pubkey) 305 * calculate DHT key: H(name) xor H(pubkey)
304 */ 306 */
305 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); 307 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
306 GNUNET_CRYPTO_hash_xor(&zone_hash, &name_hash, &xor_hash); 308 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
309 GNUNET_CRYPTO_short_hash_double (&zone_hash, &zone_hash_double);
310 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
307 GNUNET_CRYPTO_hash_to_enc (&xor_hash, &xor_hash_string); 311 GNUNET_CRYPTO_hash_to_enc (&xor_hash, &xor_hash_string);
308 312
309 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 313 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -757,7 +761,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
757 zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); 761 zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
758 GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey); 762 GNUNET_CRYPTO_rsa_key_get_public (zone_key, &pkey);
759 763
760 GNUNET_CRYPTO_hash(&pkey, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 764 GNUNET_CRYPTO_short_hash(&pkey,
765 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
761 &zone_hash); 766 &zone_hash);
762 GNUNET_free(keyfile); 767 GNUNET_free(keyfile);
763 768
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index 7f34c93ce..e50e8e626 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -59,7 +59,7 @@ static struct GNUNET_DNS_Handle *dns_handle;
59/** 59/**
60 * The root zone for this interceptor 60 * The root zone for this interceptor
61 */ 61 */
62static GNUNET_HashCode our_zone; 62static struct GNUNET_CRYPTO_ShortHashCode our_zone;
63 63
64/** 64/**
65 * Our priv key 65 * Our priv key
@@ -336,7 +336,7 @@ handle_dns_request(void *cls,
336 * @return GNUNET_OK on success 336 * @return GNUNET_OK on success
337 */ 337 */
338int 338int
339gns_interceptor_init(GNUNET_HashCode zone, 339gns_interceptor_init(struct GNUNET_CRYPTO_ShortHashCode zone,
340 struct GNUNET_CRYPTO_RsaPrivateKey *key, 340 struct GNUNET_CRYPTO_RsaPrivateKey *key,
341 const struct GNUNET_CONFIGURATION_Handle *c) 341 const struct GNUNET_CONFIGURATION_Handle *c)
342{ 342{
diff --git a/src/gns/gnunet-service-gns_interceptor.h b/src/gns/gnunet-service-gns_interceptor.h
index 855b034b1..be7250b52 100644
--- a/src/gns/gnunet-service-gns_interceptor.h
+++ b/src/gns/gnunet-service-gns_interceptor.h
@@ -9,7 +9,7 @@
9 * @return GNUNET_YES on success GNUNET_SYSERR on error 9 * @return GNUNET_YES on success GNUNET_SYSERR on error
10 */ 10 */
11int 11int
12gns_interceptor_init(GNUNET_HashCode zone, 12gns_interceptor_init(struct GNUNET_CRYPTO_ShortHashCode zone,
13 struct GNUNET_CRYPTO_RsaPrivateKey *key, 13 struct GNUNET_CRYPTO_RsaPrivateKey *key,
14 const struct GNUNET_CONFIGURATION_Handle *c); 14 const struct GNUNET_CONFIGURATION_Handle *c);
15 15
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 4ac6cea36..ca7a5ea85 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -106,7 +106,7 @@ process_pseu_lookup_ns(void* cls,
106 "Name %s not taken in NS! Adding\n", gph->new_name); 106 "Name %s not taken in NS! Adding\n", gph->new_name);
107 107
108 new_pkey.expiration = GNUNET_TIME_absolute_get_forever (); 108 new_pkey.expiration = GNUNET_TIME_absolute_get_forever ();
109 new_pkey.data_size = sizeof(GNUNET_HashCode); 109 new_pkey.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
110 new_pkey.data = &gph->new_zone; 110 new_pkey.data = &gph->new_zone;
111 new_pkey.record_type = GNUNET_GNS_RECORD_PKEY; 111 new_pkey.record_type = GNUNET_GNS_RECORD_PKEY;
112 GNUNET_NAMESTORE_record_create (namestore_handle, 112 GNUNET_NAMESTORE_record_create (namestore_handle,
@@ -294,12 +294,16 @@ process_zone_to_name_discover(void *cls,
294 * check dht 294 * check dht
295 */ 295 */
296 uint32_t xquery; 296 uint32_t xquery;
297 GNUNET_HashCode name_hash; 297 struct GNUNET_CRYPTO_ShortHashCode name_hash;
298 GNUNET_HashCode lookup_key; 298 GNUNET_HashCode lookup_key;
299 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; 299 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string;
300 GNUNET_HashCode name_hash_double;
301 GNUNET_HashCode zone_hash_double;
300 302
301 GNUNET_CRYPTO_hash("+", strlen("+"), &name_hash); 303 GNUNET_CRYPTO_short_hash("+", strlen("+"), &name_hash);
302 GNUNET_CRYPTO_hash_xor(&name_hash, &gph->new_zone, &lookup_key); 304 GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double);
305 GNUNET_CRYPTO_short_hash_double (&gph->new_zone, &zone_hash_double);
306 GNUNET_CRYPTO_hash_xor(&name_hash_double, &zone_hash_double, &lookup_key);
303 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string); 307 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
304 308
305 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 309 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -333,8 +337,8 @@ process_zone_to_name_discover(void *cls,
333 * @param zone the authority 337 * @param zone the authority
334 * @param the private key of our authority 338 * @param the private key of our authority
335 */ 339 */
336static void process_discovered_authority(char* name, GNUNET_HashCode zone, 340static void process_discovered_authority(char* name, struct GNUNET_CRYPTO_ShortHashCode zone,
337 GNUNET_HashCode our_zone, 341 struct GNUNET_CRYPTO_ShortHashCode our_zone,
338 struct GNUNET_CRYPTO_RsaPrivateKey *key) 342 struct GNUNET_CRYPTO_RsaPrivateKey *key)
339{ 343{
340 struct GetPseuAuthorityHandle *gph; 344 struct GetPseuAuthorityHandle *gph;
@@ -490,7 +494,6 @@ process_record_result_dht(void* cls,
490 int i; 494 int i;
491 int rd_size; 495 int rd_size;
492 496
493 GNUNET_HashCode zone, name_hash;
494 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "got dht result (size=%d)\n", size); 497 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "got dht result (size=%d)\n", size);
495 498
496 if (data == NULL) 499 if (data == NULL)
@@ -544,9 +547,6 @@ process_record_result_dht(void* cls,
544 547
545 } 548 }
546 549
547 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
548 GNUNET_CRYPTO_hash_xor(key, &name_hash, &zone);
549
550 /** 550 /**
551 * FIXME check pubkey against existing key in namestore? 551 * FIXME check pubkey against existing key in namestore?
552 * https://gnunet.org/bugs/view.php?id=2179 552 * https://gnunet.org/bugs/view.php?id=2179
@@ -582,13 +582,17 @@ static void
582resolve_record_dht(struct ResolverHandle *rh) 582resolve_record_dht(struct ResolverHandle *rh)
583{ 583{
584 uint32_t xquery; 584 uint32_t xquery;
585 GNUNET_HashCode name_hash; 585 struct GNUNET_CRYPTO_ShortHashCode name_hash;
586 GNUNET_HashCode lookup_key; 586 GNUNET_HashCode lookup_key;
587 GNUNET_HashCode name_hash_double;
588 GNUNET_HashCode zone_hash_double;
587 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; 589 struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string;
588 struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls; 590 struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls;
589 591
590 GNUNET_CRYPTO_hash(rh->name, strlen(rh->name), &name_hash); 592 GNUNET_CRYPTO_short_hash(rh->name, strlen(rh->name), &name_hash);
591 GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key); 593 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
594 GNUNET_CRYPTO_short_hash_double(&rh->authority, &zone_hash_double);
595 GNUNET_CRYPTO_hash_xor(&name_hash_double, &zone_hash_double, &lookup_key);
592 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string); 596 GNUNET_CRYPTO_hash_to_enc (&lookup_key, &lookup_key_string);
593 597
594 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 598 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -636,11 +640,11 @@ process_record_result_ns(void* cls,
636 struct ResolverHandle *rh; 640 struct ResolverHandle *rh;
637 struct RecordLookupHandle *rlh; 641 struct RecordLookupHandle *rlh;
638 struct GNUNET_TIME_Relative remaining_time; 642 struct GNUNET_TIME_Relative remaining_time;
639 GNUNET_HashCode zone; 643 struct GNUNET_CRYPTO_ShortHashCode zone;
640 644
641 rh = (struct ResolverHandle *) cls; 645 rh = (struct ResolverHandle *) cls;
642 rlh = (struct RecordLookupHandle *)rh->proc_cls; 646 rlh = (struct RecordLookupHandle *)rh->proc_cls;
643 GNUNET_CRYPTO_hash(key, 647 GNUNET_CRYPTO_short_hash(key,
644 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 648 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
645 &zone); 649 &zone);
646 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); 650 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
@@ -809,7 +813,8 @@ process_delegation_result_dht(void* cls,
809 char* rd_data = (char*) data; 813 char* rd_data = (char*) data;
810 int i; 814 int i;
811 int rd_size; 815 int rd_size;
812 GNUNET_HashCode zone, name_hash; 816 struct GNUNET_CRYPTO_ShortHashCode zone, name_hash;
817 GNUNET_HashCode zone_hash_double, name_hash_double;
813 818
814 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got DHT result\n"); 819 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got DHT result\n");
815 820
@@ -863,7 +868,7 @@ process_delegation_result_dht(void* cls,
863 { 868 {
864 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Authority found in DHT\n"); 869 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Authority found in DHT\n");
865 rh->answered = 1; 870 rh->answered = 1;
866 memcpy(&rh->authority, rd[i].data, sizeof(GNUNET_HashCode)); 871 memcpy(&rh->authority, rd[i].data, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
867 struct AuthorityChain *auth = 872 struct AuthorityChain *auth =
868 GNUNET_malloc(sizeof(struct AuthorityChain)); 873 GNUNET_malloc(sizeof(struct AuthorityChain));
869 auth->zone = rh->authority; 874 auth->zone = rh->authority;
@@ -883,11 +888,14 @@ process_delegation_result_dht(void* cls,
883 } 888 }
884 889
885 890
886 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); 891 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
887 GNUNET_CRYPTO_hash_xor(key, &name_hash, &zone); 892 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
893 GNUNET_CRYPTO_hash_xor(key, &name_hash_double, &zone_hash_double);
894 GNUNET_CRYPTO_short_hash_from_truncation (&zone_hash_double, &zone);
888 895
889 /* Save to namestore */ 896 /* Save to namestore */
890 if (0 != GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_tail->zone, &zone)) 897 if (0 != GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_tail->zone,
898 &zone))
891 { 899 {
892 GNUNET_NAMESTORE_record_put (namestore_handle, 900 GNUNET_NAMESTORE_record_put (namestore_handle,
893 &nrb->public_key, 901 &nrb->public_key,
@@ -1083,8 +1091,8 @@ handle_record_ns(void* cls, struct ResolverHandle *rh,
1083 { 1091 {
1084 /* ns entry expired and not ours. try dht */ 1092 /* ns entry expired and not ours. try dht */
1085 if (rh->status & (EXPIRED | !EXISTS) && 1093 if (rh->status & (EXPIRED | !EXISTS) &&
1086 GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone, 1094 GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
1087 &rh->authority_chain_tail->zone)) 1095 &rh->authority_chain_tail->zone))
1088 { 1096 {
1089 rh->proc = &handle_record_dht; 1097 rh->proc = &handle_record_dht;
1090 resolve_record_dht(rh); 1098 resolve_record_dht(rh);
@@ -1254,13 +1262,17 @@ static void
1254resolve_delegation_dht(struct ResolverHandle *rh) 1262resolve_delegation_dht(struct ResolverHandle *rh)
1255{ 1263{
1256 uint32_t xquery; 1264 uint32_t xquery;
1257 GNUNET_HashCode name_hash; 1265 struct GNUNET_CRYPTO_ShortHashCode name_hash;
1266 GNUNET_HashCode name_hash_double;
1267 GNUNET_HashCode zone_hash_double;
1258 GNUNET_HashCode lookup_key; 1268 GNUNET_HashCode lookup_key;
1259 1269
1260 GNUNET_CRYPTO_hash(rh->authority_name, 1270 GNUNET_CRYPTO_short_hash(rh->authority_name,
1261 strlen(rh->authority_name), 1271 strlen(rh->authority_name),
1262 &name_hash); 1272 &name_hash);
1263 GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key); 1273 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
1274 GNUNET_CRYPTO_short_hash_double(&rh->authority, &zone_hash_double);
1275 GNUNET_CRYPTO_hash_xor(&name_hash_double, &zone_hash_double, &lookup_key);
1264 1276
1265 rh->dht_timeout_task = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT, 1277 rh->dht_timeout_task = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT,
1266 &dht_authority_lookup_timeout, 1278 &dht_authority_lookup_timeout,
@@ -1324,7 +1336,7 @@ handle_delegation_ns(void* cls, struct ResolverHandle *rh,
1324 * or we are authority 1336 * or we are authority
1325 **/ 1337 **/
1326 if ((rh->status & (EXISTS | !EXPIRED)) || 1338 if ((rh->status & (EXISTS | !EXPIRED)) ||
1327 !GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone, 1339 !GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
1328 &rh->authority_chain_tail->zone)) 1340 &rh->authority_chain_tail->zone))
1329 { 1341 {
1330 if (is_canonical(rh->name)) 1342 if (is_canonical(rh->name))
@@ -1381,14 +1393,14 @@ process_delegation_result_ns(void* cls,
1381{ 1393{
1382 struct ResolverHandle *rh; 1394 struct ResolverHandle *rh;
1383 struct GNUNET_TIME_Relative remaining_time; 1395 struct GNUNET_TIME_Relative remaining_time;
1384 GNUNET_HashCode zone; 1396 struct GNUNET_CRYPTO_ShortHashCode zone;
1385 char new_name[MAX_DNS_NAME_LENGTH]; 1397 char new_name[MAX_DNS_NAME_LENGTH];
1386 1398
1387 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got %d records from authority lookup\n", 1399 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got %d records from authority lookup\n",
1388 rd_count); 1400 rd_count);
1389 1401
1390 rh = (struct ResolverHandle *)cls; 1402 rh = (struct ResolverHandle *)cls;
1391 GNUNET_CRYPTO_hash(key, 1403 GNUNET_CRYPTO_short_hash(key,
1392 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1404 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
1393 &zone); 1405 &zone);
1394 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); 1406 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
@@ -1474,7 +1486,7 @@ process_delegation_result_ns(void* cls,
1474 * Resolve rest of query with new authority 1486 * Resolve rest of query with new authority
1475 */ 1487 */
1476 GNUNET_assert(rd[i].record_type == GNUNET_GNS_RECORD_PKEY); 1488 GNUNET_assert(rd[i].record_type == GNUNET_GNS_RECORD_PKEY);
1477 memcpy(&rh->authority, rd[i].data, sizeof(GNUNET_HashCode)); 1489 memcpy(&rh->authority, rd[i].data, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
1478 struct AuthorityChain *auth = GNUNET_malloc(sizeof(struct AuthorityChain)); 1490 struct AuthorityChain *auth = GNUNET_malloc(sizeof(struct AuthorityChain));
1479 auth->zone = rh->authority; 1491 auth->zone = rh->authority;
1480 memset(auth->name, 0, strlen(rh->authority_name)+1); 1492 memset(auth->name, 0, strlen(rh->authority_name)+1);
@@ -1535,7 +1547,7 @@ resolve_delegation_ns(struct ResolverHandle *rh)
1535 * @param cls the closure to pass to proc 1547 * @param cls the closure to pass to proc
1536 */ 1548 */
1537void 1549void
1538gns_resolver_lookup_record(GNUNET_HashCode zone, 1550gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone,
1539 uint32_t record_type, 1551 uint32_t record_type,
1540 const char* name, 1552 const char* name,
1541 struct GNUNET_CRYPTO_RsaPrivateKey *key, 1553 struct GNUNET_CRYPTO_RsaPrivateKey *key,
@@ -1594,7 +1606,7 @@ gns_resolver_lookup_record(GNUNET_HashCode zone,
1594 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1606 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1595 "ZKEY is %s!\n", string_hash); 1607 "ZKEY is %s!\n", string_hash);
1596 1608
1597 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string(string_hash, 1609 if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(string_hash,
1598 &rh->authority)) 1610 &rh->authority))
1599 { 1611 {
1600 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1612 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1698,8 +1710,8 @@ process_zone_to_name_shorten(void *cls,
1698 GNUNET_free(nsh); 1710 GNUNET_free(nsh);
1699 free_resolver_handle(rh); 1711 free_resolver_handle(rh);
1700 } 1712 }
1701 else if (GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone, 1713 else if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
1702 &rh->authority_chain_tail->zone)) 1714 &rh->authority_chain_tail->zone))
1703 { 1715 {
1704 /* our zone, just append .gnunet */ 1716 /* our zone, just append .gnunet */
1705 answer_len = strlen(rh->name) + strlen(GNUNET_GNS_TLD) + 2; 1717 answer_len = strlen(rh->name) + strlen(GNUNET_GNS_TLD) + 2;
@@ -1774,8 +1786,8 @@ handle_delegation_ns_shorten(void* cls,
1774 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1786 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1775 "PKEY resolved as far as possible in ns up to %s!\n", rh->name); 1787 "PKEY resolved as far as possible in ns up to %s!\n", rh->name);
1776 1788
1777 if (GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone, 1789 if (GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
1778 &rh->authority_chain_tail->zone) == 0) 1790 &rh->authority_chain_tail->zone) == 0)
1779 { 1791 {
1780 /** 1792 /**
1781 * This is our zone append .gnunet unless name is empty 1793 * This is our zone append .gnunet unless name is empty
@@ -1816,7 +1828,7 @@ handle_delegation_ns_shorten(void* cls,
1816 * @param cls closure to pass to proc 1828 * @param cls closure to pass to proc
1817 */ 1829 */
1818void 1830void
1819gns_resolver_shorten_name(GNUNET_HashCode zone, 1831gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone,
1820 const char* name, 1832 const char* name,
1821 ShortenResultProcessor proc, 1833 ShortenResultProcessor proc,
1822 void* cls) 1834 void* cls)
@@ -1864,8 +1876,8 @@ gns_resolver_shorten_name(GNUNET_HashCode zone,
1864 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1876 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1865 "ZKEY is %s!\n", string_hash); 1877 "ZKEY is %s!\n", string_hash);
1866 1878
1867 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string(string_hash, 1879 if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(string_hash,
1868 &rh->authority)) 1880 &rh->authority))
1869 { 1881 {
1870 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1882 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1871 "Cannot convert ZKEY %s to hash!\n", string_hash); 1883 "Cannot convert ZKEY %s to hash!\n", string_hash);
@@ -1985,7 +1997,7 @@ handle_delegation_result_ns_get_auth(void* cls,
1985 * @param cls the closure to pass to the processor 1997 * @param cls the closure to pass to the processor
1986 */ 1998 */
1987void 1999void
1988gns_resolver_get_authority(GNUNET_HashCode zone, 2000gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone,
1989 const char* name, 2001 const char* name,
1990 GetAuthorityResultProcessor proc, 2002 GetAuthorityResultProcessor proc,
1991 void* cls) 2003 void* cls)
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index 4f857825c..326aff22d 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -19,7 +19,7 @@ struct AuthorityChain
19 struct AuthorityChain *next; 19 struct AuthorityChain *next;
20 20
21 /* the zone hash of the authority */ 21 /* the zone hash of the authority */
22 GNUNET_HashCode zone; 22 struct GNUNET_CRYPTO_ShortHashCode zone;
23 23
24 /* (local) name of the authority */ 24 /* (local) name of the authority */
25 char name[MAX_DNS_LABEL_LENGTH]; 25 char name[MAX_DNS_LABEL_LENGTH];
@@ -99,7 +99,7 @@ struct ResolverHandle
99 int answered; 99 int answered;
100 100
101 /* the authoritative zone to query */ 101 /* the authoritative zone to query */
102 GNUNET_HashCode authority; 102 struct GNUNET_CRYPTO_ShortHashCode authority;
103 103
104 /* the name of the authoritative zone to query */ 104 /* the name of the authoritative zone to query */
105 char authority_name[MAX_DNS_LABEL_LENGTH]; 105 char authority_name[MAX_DNS_LABEL_LENGTH];
@@ -200,10 +200,10 @@ struct GetPseuAuthorityHandle
200 char new_name[MAX_DNS_LABEL_LENGTH]; 200 char new_name[MAX_DNS_LABEL_LENGTH];
201 201
202 /* the zone of discovered authority */ 202 /* the zone of discovered authority */
203 GNUNET_HashCode new_zone; 203 struct GNUNET_CRYPTO_ShortHashCode new_zone;
204 204
205 /* the zone of our authority */ 205 /* the zone of our authority */
206 GNUNET_HashCode zone; 206 struct GNUNET_CRYPTO_ShortHashCode zone;
207 207
208 /* the private key of the zone to store the pseu in */ 208 /* the private key of the zone to store the pseu in */
209 struct GNUNET_CRYPTO_RsaPrivateKey *key; 209 struct GNUNET_CRYPTO_RsaPrivateKey *key;
@@ -238,7 +238,7 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh,
238 * @param cls the closure to pass to proc 238 * @param cls the closure to pass to proc
239 */ 239 */
240void 240void
241gns_resolver_lookup_record(GNUNET_HashCode zone, 241gns_resolver_lookup_record(struct GNUNET_CRYPTO_ShortHashCode zone,
242 uint32_t record_type, 242 uint32_t record_type,
243 const char* name, 243 const char* name,
244 struct GNUNET_CRYPTO_RsaPrivateKey *key, 244 struct GNUNET_CRYPTO_RsaPrivateKey *key,
@@ -246,7 +246,7 @@ gns_resolver_lookup_record(GNUNET_HashCode zone,
246 void* cls); 246 void* cls);
247 247
248void 248void
249gns_resolver_shorten_name(GNUNET_HashCode zone, 249gns_resolver_shorten_name(struct GNUNET_CRYPTO_ShortHashCode zone,
250 const char* name, 250 const char* name,
251 ShortenResultProcessor proc, 251 ShortenResultProcessor proc,
252 void* cls); 252 void* cls);
@@ -261,7 +261,7 @@ gns_resolver_shorten_name(GNUNET_HashCode zone,
261 * @param cls the closure to pass to the processor 261 * @param cls the closure to pass to the processor
262 */ 262 */
263void 263void
264gns_resolver_get_authority(GNUNET_HashCode zone, 264gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone,
265 const char* name, 265 const char* name,
266 GetAuthorityResultProcessor proc, 266 GetAuthorityResultProcessor proc,
267 void* cls); 267 void* cls);
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 19495f243..7dfaab0fa 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -63,11 +63,13 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
63 size_t reply_block_size) 63 size_t reply_block_size)
64{ 64{
65 char* name; 65 char* name;
66 GNUNET_HashCode pkey_hash; 66 GNUNET_HashCode pkey_hash_double;
67 GNUNET_HashCode query_key; 67 GNUNET_HashCode query_key;
68 GNUNET_HashCode name_hash; 68 GNUNET_HashCode name_hash_double;
69 GNUNET_HashCode mhash; 69 GNUNET_HashCode mhash;
70 GNUNET_HashCode chash; 70 GNUNET_HashCode chash;
71 struct GNUNET_CRYPTO_ShortHashCode pkey_hash;
72 struct GNUNET_CRYPTO_ShortHashCode name_hash;
71 struct GNSNameRecordBlock *nrb; 73 struct GNSNameRecordBlock *nrb;
72 uint32_t rd_count; 74 uint32_t rd_count;
73 char* rd_data = NULL; 75 char* rd_data = NULL;
@@ -95,13 +97,16 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
95 97
96 nrb = (struct GNSNameRecordBlock *)reply_block; 98 nrb = (struct GNSNameRecordBlock *)reply_block;
97 name = (char*)&nrb[1]; 99 name = (char*)&nrb[1];
98 GNUNET_CRYPTO_hash(&nrb->public_key, 100 GNUNET_CRYPTO_short_hash(&nrb->public_key,
99 sizeof(nrb->public_key), 101 sizeof(nrb->public_key),
100 &pkey_hash); 102 &pkey_hash);
101 103
102 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); 104 GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash);
105
106 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
107 GNUNET_CRYPTO_short_hash_double(&pkey_hash, &pkey_hash_double);
103 108
104 GNUNET_CRYPTO_hash_xor(&pkey_hash, &name_hash, &query_key); 109 GNUNET_CRYPTO_hash_xor(&pkey_hash_double, &name_hash_double, &query_key);
105 110
106 struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp; 111 struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
107 struct GNUNET_CRYPTO_HashAsciiEncoded xor_got; 112 struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c
index 469ae36be..2a541e4eb 100644
--- a/src/gns/test_gns_dht_delegated_lookup.c
+++ b/src/gns/test_gns_dht_delegated_lookup.c
@@ -211,9 +211,11 @@ static void
211put_dht(void *cls, int32_t success, const char *emsg) 211put_dht(void *cls, int32_t success, const char *emsg)
212{ 212{
213 struct GNSNameRecordBlock *nrb; 213 struct GNSNameRecordBlock *nrb;
214 GNUNET_HashCode name_hash; 214 struct GNUNET_CRYPTO_ShortHashCode name_hash;
215 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
215 GNUNET_HashCode xor_hash; 216 GNUNET_HashCode xor_hash;
216 GNUNET_HashCode zone_hash; 217 GNUNET_HashCode name_hash_double;
218 GNUNET_HashCode zone_hash_double;
217 uint32_t rd_payload_length; 219 uint32_t rd_payload_length;
218 char* nrb_data = NULL; 220 char* nrb_data = NULL;
219 struct GNUNET_CRYPTO_RsaSignature *sig; 221 struct GNUNET_CRYPTO_RsaSignature *sig;
@@ -250,11 +252,13 @@ put_dht(void *cls, int32_t success, const char *emsg)
250 GNUNET_free (nrb); 252 GNUNET_free (nrb);
251 return; 253 return;
252 } 254 }
253 GNUNET_CRYPTO_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash); 255 GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash);
254 GNUNET_CRYPTO_hash(&bob_pkey, 256 GNUNET_CRYPTO_short_hash(&bob_pkey,
255 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 257 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
256 &zone_hash); 258 &zone_hash);
257 GNUNET_CRYPTO_hash_xor(&zone_hash, &name_hash, &xor_hash); 259 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
260 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
261 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
258 262
259 rd_payload_length += sizeof(struct GNSNameRecordBlock) + 263 rd_payload_length += sizeof(struct GNSNameRecordBlock) +
260 strlen(TEST_RECORD_NAME) + 1; 264 strlen(TEST_RECORD_NAME) + 1;
@@ -280,7 +284,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
280 284
281 285
282 char* alice_keyfile; 286 char* alice_keyfile;
283 GNUNET_HashCode bob_hash; 287 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
284 288
285 289
286 GNUNET_SCHEDULER_cancel (die_task); 290 GNUNET_SCHEDULER_cancel (die_task);
@@ -319,11 +323,11 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
319 323
320 GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); 324 GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
321 GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); 325 GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey);
322 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 326 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
323 327
324 struct GNUNET_NAMESTORE_RecordData rd; 328 struct GNUNET_NAMESTORE_RecordData rd;
325 rd.expiration = GNUNET_TIME_absolute_get_forever (); 329 rd.expiration = GNUNET_TIME_absolute_get_forever ();
326 rd.data_size = sizeof(GNUNET_HashCode); 330 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
327 rd.data = &bob_hash; 331 rd.data = &bob_hash;
328 rd.record_type = GNUNET_GNS_RECORD_PKEY; 332 rd.record_type = GNUNET_GNS_RECORD_PKEY;
329 333
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c
index ee19f59d0..ce2511f32 100644
--- a/src/gns/test_gns_pseu_shorten.c
+++ b/src/gns/test_gns_pseu_shorten.c
@@ -84,8 +84,8 @@ struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded our_pkey;
84struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; 84struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
85struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; 85struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
86struct GNUNET_CRYPTO_RsaPrivateKey *our_key; 86struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
87GNUNET_HashCode alice_hash; 87struct GNUNET_CRYPTO_ShortHashCode alice_hash;
88GNUNET_HashCode bob_hash; 88struct GNUNET_CRYPTO_ShortHashCode bob_hash;
89 89
90/** 90/**
91 * Check whether peers successfully shut down. 91 * Check whether peers successfully shut down.
@@ -246,9 +246,11 @@ static void
246put_pseu_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 246put_pseu_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
247{ 247{
248 struct GNSNameRecordBlock *nrb; 248 struct GNSNameRecordBlock *nrb;
249 GNUNET_HashCode name_hash; 249 struct GNUNET_CRYPTO_ShortHashCode name_hash;
250 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
250 GNUNET_HashCode xor_hash; 251 GNUNET_HashCode xor_hash;
251 GNUNET_HashCode zone_hash; 252 GNUNET_HashCode name_hash_double;
253 GNUNET_HashCode zone_hash_double;
252 uint32_t rd_payload_length; 254 uint32_t rd_payload_length;
253 char* nrb_data = NULL; 255 char* nrb_data = NULL;
254 struct GNUNET_CRYPTO_RsaSignature *sig; 256 struct GNUNET_CRYPTO_RsaSignature *sig;
@@ -291,11 +293,14 @@ put_pseu_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
291 GNUNET_free (nrb); 293 GNUNET_free (nrb);
292 return; 294 return;
293 } 295 }
294 GNUNET_CRYPTO_hash("+", strlen("+"), &name_hash); 296 GNUNET_CRYPTO_short_hash("+", strlen("+"), &name_hash);
295 GNUNET_CRYPTO_hash(&alice_pkey, 297 GNUNET_CRYPTO_short_hash(&alice_pkey,
296 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 298 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
297 &zone_hash); 299 &zone_hash);
298 GNUNET_CRYPTO_hash_xor(&zone_hash, &name_hash, &xor_hash); 300
301 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
302 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
303 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
299 304
300 rd_payload_length += sizeof(struct GNSNameRecordBlock) + 305 rd_payload_length += sizeof(struct GNSNameRecordBlock) +
301 strlen("+") + 1; 306 strlen("+") + 1;
@@ -319,9 +324,11 @@ static void
319put_www_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 324put_www_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
320{ 325{
321 struct GNSNameRecordBlock *nrb; 326 struct GNSNameRecordBlock *nrb;
322 GNUNET_HashCode name_hash; 327 struct GNUNET_CRYPTO_ShortHashCode name_hash;
328 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
323 GNUNET_HashCode xor_hash; 329 GNUNET_HashCode xor_hash;
324 GNUNET_HashCode zone_hash; 330 GNUNET_HashCode name_hash_double;
331 GNUNET_HashCode zone_hash_double;
325 uint32_t rd_payload_length; 332 uint32_t rd_payload_length;
326 char* nrb_data = NULL; 333 char* nrb_data = NULL;
327 struct GNUNET_CRYPTO_RsaSignature *sig; 334 struct GNUNET_CRYPTO_RsaSignature *sig;
@@ -366,11 +373,13 @@ put_www_dht(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
366 GNUNET_free (nrb); 373 GNUNET_free (nrb);
367 return; 374 return;
368 } 375 }
369 GNUNET_CRYPTO_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash); 376 GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash);
370 GNUNET_CRYPTO_hash(&alice_pkey, 377 GNUNET_CRYPTO_short_hash(&alice_pkey,
371 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 378 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
372 &zone_hash); 379 &zone_hash);
373 GNUNET_CRYPTO_hash_xor(&zone_hash, &name_hash, &xor_hash); 380 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
381 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
382 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
374 383
375 rd_payload_length += sizeof(struct GNSNameRecordBlock) + 384 rd_payload_length += sizeof(struct GNSNameRecordBlock) +
376 strlen(TEST_RECORD_NAME) + 1; 385 strlen(TEST_RECORD_NAME) + 1;
@@ -395,16 +404,18 @@ static void
395put_pkey_dht(void *cls, int32_t success, const char *emsg) 404put_pkey_dht(void *cls, int32_t success, const char *emsg)
396{ 405{
397 struct GNSNameRecordBlock *nrb; 406 struct GNSNameRecordBlock *nrb;
398 GNUNET_HashCode name_hash; 407 struct GNUNET_CRYPTO_ShortHashCode name_hash;
408 struct GNUNET_CRYPTO_ShortHashCode zone_hash;
399 GNUNET_HashCode xor_hash; 409 GNUNET_HashCode xor_hash;
400 GNUNET_HashCode zone_hash; 410 GNUNET_HashCode name_hash_double;
411 GNUNET_HashCode zone_hash_double;
401 uint32_t rd_payload_length; 412 uint32_t rd_payload_length;
402 char* nrb_data = NULL; 413 char* nrb_data = NULL;
403 struct GNUNET_CRYPTO_RsaSignature *sig; 414 struct GNUNET_CRYPTO_RsaSignature *sig;
404 struct GNUNET_NAMESTORE_RecordData rd; 415 struct GNUNET_NAMESTORE_RecordData rd;
405 416
406 rd.expiration = GNUNET_TIME_absolute_get_forever (); 417 rd.expiration = GNUNET_TIME_absolute_get_forever ();
407 rd.data_size = sizeof(GNUNET_HashCode); 418 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
408 rd.data = &alice_hash; 419 rd.data = &alice_hash;
409 rd.record_type = GNUNET_GNS_RECORD_PKEY; 420 rd.record_type = GNUNET_GNS_RECORD_PKEY;
410 421
@@ -442,12 +453,14 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg)
442 } 453 }
443 454
444 455
445 GNUNET_CRYPTO_hash(TEST_AUTHORITY_ALICE, 456 GNUNET_CRYPTO_short_hash(TEST_AUTHORITY_ALICE,
446 strlen(TEST_AUTHORITY_ALICE), &name_hash); 457 strlen(TEST_AUTHORITY_ALICE), &name_hash);
447 GNUNET_CRYPTO_hash(&bob_pkey, 458 GNUNET_CRYPTO_short_hash(&bob_pkey,
448 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 459 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
449 &zone_hash); 460 &zone_hash);
450 GNUNET_CRYPTO_hash_xor(&zone_hash, &name_hash, &xor_hash); 461 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
462 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
463 GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash);
451 464
452 rd_payload_length += sizeof(struct GNSNameRecordBlock) + 465 rd_payload_length += sizeof(struct GNSNameRecordBlock) +
453 strlen(TEST_AUTHORITY_ALICE) + 1; 466 strlen(TEST_AUTHORITY_ALICE) + 1;
@@ -513,12 +526,12 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
513 GNUNET_CRYPTO_rsa_key_get_public (our_key, &our_pkey); 526 GNUNET_CRYPTO_rsa_key_get_public (our_key, &our_pkey);
514 GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); 527 GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey);
515 GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); 528 GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
516 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 529 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
517 GNUNET_CRYPTO_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); 530 GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
518 531
519 struct GNUNET_NAMESTORE_RecordData rd; 532 struct GNUNET_NAMESTORE_RecordData rd;
520 rd.expiration = GNUNET_TIME_absolute_get_forever (); 533 rd.expiration = GNUNET_TIME_absolute_get_forever ();
521 rd.data_size = sizeof(GNUNET_HashCode); 534 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
522 rd.data = &bob_hash; 535 rd.data = &bob_hash;
523 rd.record_type = GNUNET_GNS_RECORD_PKEY; 536 rd.record_type = GNUNET_GNS_RECORD_PKEY;
524 537
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c
index ea1206b9b..2006754da 100644
--- a/src/gns/test_gns_simple_delegated_lookup.c
+++ b/src/gns/test_gns_simple_delegated_lookup.c
@@ -204,7 +204,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
204 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; 204 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
205 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; 205 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
206 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; 206 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
207 GNUNET_HashCode bob_hash; 207 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
208 struct GNUNET_CRYPTO_RsaSignature *sig; 208 struct GNUNET_CRYPTO_RsaSignature *sig;
209 char* alice_keyfile; 209 char* alice_keyfile;
210 210
@@ -240,9 +240,9 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
240 rd.expiration = GNUNET_TIME_absolute_get_forever (); 240 rd.expiration = GNUNET_TIME_absolute_get_forever ();
241 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 241 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
242 242
243 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 243 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
244 244
245 rd.data_size = sizeof(GNUNET_HashCode); 245 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
246 rd.data = &bob_hash; 246 rd.data = &bob_hash;
247 rd.record_type = GNUNET_GNS_RECORD_PKEY; 247 rd.record_type = GNUNET_GNS_RECORD_PKEY;
248 248
diff --git a/src/gns/test_gns_simple_get_authority.c b/src/gns/test_gns_simple_get_authority.c
index 32bb39463..7ad890d95 100644
--- a/src/gns/test_gns_simple_get_authority.c
+++ b/src/gns/test_gns_simple_get_authority.c
@@ -196,8 +196,8 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
196 struct GNUNET_CRYPTO_RsaPrivateKey *our_key; 196 struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
197 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; 197 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
198 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; 198 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
199 GNUNET_HashCode bob_hash; 199 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
200 GNUNET_HashCode alice_hash; 200 struct GNUNET_CRYPTO_ShortHashCode alice_hash;
201 struct GNUNET_CRYPTO_RsaSignature *sig; 201 struct GNUNET_CRYPTO_RsaSignature *sig;
202 char* our_keyfile; 202 char* our_keyfile;
203 203
@@ -237,9 +237,9 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
237 rd.expiration = GNUNET_TIME_absolute_get_forever (); 237 rd.expiration = GNUNET_TIME_absolute_get_forever ();
238 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 238 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
239 239
240 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 240 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
241 241
242 rd.data_size = sizeof(GNUNET_HashCode); 242 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
243 rd.data = &bob_hash; 243 rd.data = &bob_hash;
244 rd.record_type = GNUNET_GNS_RECORD_PKEY; 244 rd.record_type = GNUNET_GNS_RECORD_PKEY;
245 245
@@ -252,7 +252,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
252 NULL); 252 NULL);
253 253
254 /* put alice into bobs zone */ 254 /* put alice into bobs zone */
255 GNUNET_CRYPTO_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); 255 GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
256 rd.data = &alice_hash; 256 rd.data = &alice_hash;
257 sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_AUTHORITY_ALICE, 257 sig = GNUNET_NAMESTORE_create_signature(bob_key, GNUNET_TIME_absolute_get_forever(), TEST_AUTHORITY_ALICE,
258 &rd, 1); 258 &rd, 1);
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c
index 7f854c6f3..dbdc5b6eb 100644
--- a/src/gns/test_gns_simple_mx_lookup.c
+++ b/src/gns/test_gns_simple_mx_lookup.c
@@ -220,7 +220,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
220 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; 220 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
221 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; 221 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
222 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; 222 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
223 GNUNET_HashCode bob_hash; 223 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
224 struct GNUNET_CRYPTO_RsaSignature *sig; 224 struct GNUNET_CRYPTO_RsaSignature *sig;
225 char* alice_keyfile; 225 char* alice_keyfile;
226 226
@@ -257,9 +257,9 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
257 rd.expiration = GNUNET_TIME_absolute_get_forever (); 257 rd.expiration = GNUNET_TIME_absolute_get_forever ();
258 GNUNET_assert(1 == inet_pton (AF_INET, ip, mail)); 258 GNUNET_assert(1 == inet_pton (AF_INET, ip, mail));
259 259
260 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 260 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
261 261
262 rd.data_size = sizeof(GNUNET_HashCode); 262 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
263 rd.data = &bob_hash; 263 rd.data = &bob_hash;
264 rd.record_type = GNUNET_GNS_RECORD_PKEY; 264 rd.record_type = GNUNET_GNS_RECORD_PKEY;
265 265
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c
index 27a0024dc..8a4dd2ec9 100644
--- a/src/gns/test_gns_simple_shorten.c
+++ b/src/gns/test_gns_simple_shorten.c
@@ -196,8 +196,8 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
196 struct GNUNET_CRYPTO_RsaPrivateKey *our_key; 196 struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
197 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; 197 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
198 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; 198 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
199 GNUNET_HashCode bob_hash; 199 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
200 GNUNET_HashCode alice_hash; 200 struct GNUNET_CRYPTO_ShortHashCode alice_hash;
201 struct GNUNET_CRYPTO_RsaSignature *sig; 201 struct GNUNET_CRYPTO_RsaSignature *sig;
202 char* our_keyfile; 202 char* our_keyfile;
203 203
@@ -237,9 +237,9 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
237 rd.expiration = GNUNET_TIME_absolute_get_forever (); 237 rd.expiration = GNUNET_TIME_absolute_get_forever ();
238 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 238 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
239 239
240 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 240 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
241 241
242 rd.data_size = sizeof(GNUNET_HashCode); 242 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
243 rd.data = &bob_hash; 243 rd.data = &bob_hash;
244 rd.record_type = GNUNET_GNS_RECORD_PKEY; 244 rd.record_type = GNUNET_GNS_RECORD_PKEY;
245 245
@@ -252,7 +252,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
252 NULL); 252 NULL);
253 253
254 /* put alice into bobs zone */ 254 /* put alice into bobs zone */
255 GNUNET_CRYPTO_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash); 255 GNUNET_CRYPTO_short_hash(&alice_pkey, sizeof(alice_pkey), &alice_hash);
256 rd.data = &alice_hash; 256 rd.data = &alice_hash;
257 sig = GNUNET_NAMESTORE_create_signature(bob_key, 257 sig = GNUNET_NAMESTORE_create_signature(bob_key,
258 GNUNET_TIME_absolute_get_forever(), 258 GNUNET_TIME_absolute_get_forever(),
@@ -289,7 +289,7 @@ do_shorten(void *cls, const struct GNUNET_PeerIdentity *id,
289 NULL, 289 NULL,
290 NULL); 290 NULL);
291 291
292 rd.data_size = sizeof(GNUNET_HashCode); 292 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
293 rd.data = &alice_hash; 293 rd.data = &alice_hash;
294 rd.record_type = GNUNET_GNS_RECORD_PKEY; 294 rd.record_type = GNUNET_GNS_RECORD_PKEY;
295 GNUNET_free(sig); 295 GNUNET_free(sig);
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c
index f8db33973..a24e605b9 100644
--- a/src/gns/test_gns_simple_zkey_lookup.c
+++ b/src/gns/test_gns_simple_zkey_lookup.c
@@ -70,7 +70,7 @@ static struct GNUNET_GNS_Handle *gns_handle;
70 70
71const struct GNUNET_CONFIGURATION_Handle *cfg; 71const struct GNUNET_CONFIGURATION_Handle *cfg;
72 72
73GNUNET_HashCode bob_hash; 73struct GNUNET_CRYPTO_ShortHashCode bob_hash;
74 74
75/** 75/**
76 * Check whether peers successfully shut down. 76 * Check whether peers successfully shut down.
@@ -143,7 +143,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
143{ 143{
144 char name[MAX_DNS_NAME_LENGTH]; 144 char name[MAX_DNS_NAME_LENGTH];
145 char* pos; 145 char* pos;
146 struct GNUNET_CRYPTO_HashAsciiEncoded hash_str; 146 struct GNUNET_CRYPTO_ShortHashAsciiEncoded hash_str;
147 147
148 GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES); 148 GNUNET_NAMESTORE_disconnect(namestore_handle, GNUNET_YES);
149 149
@@ -160,7 +160,7 @@ commence_testing (void *cls, int32_t success, const char *emsg)
160 pos += strlen(TEST_RECORD_NAME); 160 pos += strlen(TEST_RECORD_NAME);
161 strcpy(pos, "."); 161 strcpy(pos, ".");
162 pos++; 162 pos++;
163 GNUNET_CRYPTO_hash_to_enc(&bob_hash, &hash_str); 163 GNUNET_CRYPTO_short_hash_to_enc(&bob_hash, &hash_str);
164 strcpy(pos, (char*)&hash_str); 164 strcpy(pos, (char*)&hash_str);
165 pos += strlen((char*)&hash_str); 165 pos += strlen((char*)&hash_str);
166 strcpy(pos, "."); 166 strcpy(pos, ".");
@@ -243,9 +243,9 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
243 rd.expiration = GNUNET_TIME_absolute_get_forever (); 243 rd.expiration = GNUNET_TIME_absolute_get_forever ();
244 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 244 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
245 245
246 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash); 246 GNUNET_CRYPTO_short_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
247 247
248 rd.data_size = sizeof(GNUNET_HashCode); 248 rd.data_size = sizeof(struct GNUNET_CRYPTO_ShortHashCode);
249 rd.data = &bob_hash; 249 rd.data = &bob_hash;
250 rd.record_type = GNUNET_GNS_RECORD_PKEY; 250 rd.record_type = GNUNET_GNS_RECORD_PKEY;
251 251
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 86b862563..777ddd97e 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -513,6 +513,18 @@ GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
513 513
514 514
515/** 515/**
516 * Compare function for ShortHashCodes, producing a total ordering
517 * of all hashcodes.
518 *
519 * @param h1 some hash code
520 * @param h2 some hash code
521 * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
522 */
523int
524GNUNET_CRYPTO_short_hash_cmp (const struct GNUNET_CRYPTO_ShortHashCode * h1,
525 const struct GNUNET_CRYPTO_ShortHashCode * h2);
526
527/**
516 * Compute the distance between 2 hashcodes. 528 * Compute the distance between 2 hashcodes.
517 * The computation must be fast, not involve 529 * The computation must be fast, not involve
518 * a.a or a.e (they're used elsewhere), and 530 * a.a or a.e (they're used elsewhere), and
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index 57e37f3fd..9f8c4b9cf 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -669,6 +669,32 @@ GNUNET_CRYPTO_short_hash_to_enc (const struct GNUNET_CRYPTO_ShortHashCode * bloc
669 *np = '\0'; 669 *np = '\0';
670} 670}
671 671
672/**
673 * Compare function for ShortHashCodes, producing a total ordering
674 * of all hashcodes.
675 *
676 * @param h1 some hash code
677 * @param h2 some hash code
678 * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
679 */
680int
681GNUNET_CRYPTO_short_hash_cmp (const struct GNUNET_CRYPTO_ShortHashCode * h1,
682 const struct GNUNET_CRYPTO_ShortHashCode * h2)
683{
684 unsigned int *i1;
685 unsigned int *i2;
686 int i;
672 687
688 i1 = (unsigned int *) h1;
689 i2 = (unsigned int *) h2;
690 for (i = (sizeof (struct GNUNET_CRYPTO_ShortHashCode) / sizeof (unsigned int)) - 1; i >= 0; i--)
691 {
692 if (i1[i] > i2[i])
693 return 1;
694 if (i1[i] < i2[i])
695 return -1;
696 }
697 return 0;
698}
673 699
674/* end of crypto_hash.c */ 700/* end of crypto_hash.c */