aboutsummaryrefslogtreecommitdiff
path: root/src/gns/test_gns_pseu_shorten.c
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/gns/test_gns_pseu_shorten.c
parentcdd5f401a24438425da10a11992c2bfd9992df47 (diff)
downloadgnunet-d2fb255905f0c93f50db2112594307bb1265742c.tar.gz
gnunet-d2fb255905f0c93f50db2112594307bb1265742c.zip
-new short hashes, new short hash cmp
Diffstat (limited to 'src/gns/test_gns_pseu_shorten.c')
-rw-r--r--src/gns/test_gns_pseu_shorten.c55
1 files changed, 34 insertions, 21 deletions
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