diff options
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r-- | src/dht/dht_api.c | 101 |
1 files changed, 19 insertions, 82 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index a16db6d4b..474198004 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -1300,8 +1300,7 @@ GNUNET_DHT_pp2s (const struct GNUNET_DHT_PathElement *path, | |||
1300 | 1300 | ||
1301 | 1301 | ||
1302 | unsigned int | 1302 | unsigned int |
1303 | GNUNET_DHT_verify_path (const struct GNUNET_HashCode *query_hash, | 1303 | GNUNET_DHT_verify_path (const void *data, |
1304 | const void *data, | ||
1305 | size_t data_size, | 1304 | size_t data_size, |
1306 | struct GNUNET_TIME_Absolute exp_time, | 1305 | struct GNUNET_TIME_Absolute exp_time, |
1307 | const struct GNUNET_DHT_PathElement *put_path, | 1306 | const struct GNUNET_DHT_PathElement *put_path, |
@@ -1310,40 +1309,29 @@ GNUNET_DHT_verify_path (const struct GNUNET_HashCode *query_hash, | |||
1310 | unsigned int get_path_len, | 1309 | unsigned int get_path_len, |
1311 | const struct GNUNET_PeerIdentity *me) | 1310 | const struct GNUNET_PeerIdentity *me) |
1312 | { | 1311 | { |
1313 | struct GNUNET_DHT_PutHopSignature phs = { | 1312 | struct GNUNET_DHT_HopSignature hs = { |
1314 | .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DHT_PUT_HOP), | 1313 | .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DHT_HOP), |
1315 | .purpose.size = htonl (sizeof (phs)), | 1314 | .purpose.size = htonl (sizeof (hs)), |
1316 | .expiration_time = GNUNET_TIME_absolute_hton (exp_time) | 1315 | .expiration_time = GNUNET_TIME_absolute_hton (exp_time) |
1317 | }; | 1316 | }; |
1318 | struct GNUNET_DHT_ResultHopSignature ghs = { | ||
1319 | .purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_DHT_RESULT_HOP), | ||
1320 | .purpose.size = htonl (sizeof (ghs)), | ||
1321 | .expiration_time = GNUNET_TIME_absolute_hton (exp_time), | ||
1322 | }; | ||
1323 | const struct GNUNET_PeerIdentity *pred; | 1317 | const struct GNUNET_PeerIdentity *pred; |
1324 | const struct GNUNET_PeerIdentity *succ; | 1318 | const struct GNUNET_PeerIdentity *succ; |
1325 | unsigned int i; | 1319 | unsigned int i; |
1326 | 1320 | ||
1327 | if (0 == get_path_len + put_path_len) | 1321 | if (0 == get_path_len + put_path_len) |
1328 | return 0; | 1322 | return 0; |
1329 | if (0 != get_path_len) | 1323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1330 | { | 1324 | "%s is verifying signatures with GPL: %u PPL: %u!\n", |
1331 | GNUNET_assert (NULL != query_hash); | ||
1332 | ghs.query_hash = *query_hash; | ||
1333 | } | ||
1334 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1335 | "%s is verifying signatures for %s with GPL: %u PPL: %u!\n", | ||
1336 | GNUNET_i2s (me), | 1325 | GNUNET_i2s (me), |
1337 | NULL != query_hash ? GNUNET_h2s (query_hash) : "<null>", | ||
1338 | get_path_len, | 1326 | get_path_len, |
1339 | put_path_len); | 1327 | put_path_len); |
1340 | for (unsigned int j = 0; j<put_path_len; j++) | 1328 | for (unsigned int j = 0; j<put_path_len; j++) |
1341 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1329 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1342 | "PP%u=%s\n", | 1330 | "PP%u=%s\n", |
1343 | j, | 1331 | j, |
1344 | GNUNET_i2s (&put_path[j].pred)); | 1332 | GNUNET_i2s (&put_path[j].pred)); |
1345 | for (unsigned int j = 0; j<get_path_len; j++) | 1333 | for (unsigned int j = 0; j<get_path_len; j++) |
1346 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1347 | "GP%u=%s\n", | 1335 | "GP%u=%s\n", |
1348 | j, | 1336 | j, |
1349 | GNUNET_i2s (&get_path[j].pred)); | 1337 | GNUNET_i2s (&get_path[j].pred)); |
@@ -1351,8 +1339,7 @@ GNUNET_DHT_verify_path (const struct GNUNET_HashCode *query_hash, | |||
1351 | i = put_path_len + get_path_len - 1; | 1339 | i = put_path_len + get_path_len - 1; |
1352 | GNUNET_CRYPTO_hash (data, | 1340 | GNUNET_CRYPTO_hash (data, |
1353 | data_size, | 1341 | data_size, |
1354 | &phs.h_data); | 1342 | &hs.h_data); |
1355 | ghs.h_data = phs.h_data; | ||
1356 | while (i > 0) | 1343 | while (i > 0) |
1357 | { | 1344 | { |
1358 | pred = (i - 1 >= put_path_len) | 1345 | pred = (i - 1 >= put_path_len) |
@@ -1364,71 +1351,21 @@ GNUNET_DHT_verify_path (const struct GNUNET_HashCode *query_hash, | |||
1364 | succ = (i + 1 >= put_path_len) | 1351 | succ = (i + 1 >= put_path_len) |
1365 | ? &get_path[i + 1 - put_path_len].pred | 1352 | ? &get_path[i + 1 - put_path_len].pred |
1366 | : &put_path[i + 1].pred; | 1353 | : &put_path[i + 1].pred; |
1367 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1354 | hs.pred = *pred; |
1368 | "PRED: %s\n", | 1355 | hs.succ = *succ; |
1369 | GNUNET_i2s (pred)); | 1356 | if (GNUNET_OK != |
1370 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1357 | GNUNET_CRYPTO_eddsa_verify ( |
1371 | "SUCC: %s\n", | 1358 | GNUNET_SIGNATURE_PURPOSE_DHT_HOP, |
1372 | GNUNET_i2s (succ)); | 1359 | &hs, |
1373 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1360 | (i - 1 >= put_path_len) |
1374 | "SIGNER: %s\n", | ||
1375 | GNUNET_i2s ((i >= put_path_len) | ||
1376 | ? &get_path[i - put_path_len].pred | ||
1377 | : &put_path[i].pred)); | ||
1378 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1379 | "SIG: %s\n", | ||
1380 | GNUNET_B2S ((i - 1 >= put_path_len) | ||
1381 | ? &get_path[i - put_path_len - 1].sig | ||
1382 | : &put_path[i - 1].sig)); | ||
1383 | if ( (i + 1 >= put_path_len) && | ||
1384 | (0 != get_path_len) ) | ||
1385 | { | ||
1386 | /* NOTE: the last signature inside the 'PUT' | ||
1387 | path is from the cross-over point and already | ||
1388 | of type RESULT_HOP, but only if we have | ||
1389 | a non-empty 'GET' path! */ | ||
1390 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1391 | "Key: %s offset %u\n", | ||
1392 | GNUNET_h2s (query_hash), | ||
1393 | i); | ||
1394 | ghs.pred = *pred; | ||
1395 | ghs.succ = *succ; | ||
1396 | if (GNUNET_OK != | ||
1397 | GNUNET_CRYPTO_eddsa_verify ( | ||
1398 | GNUNET_SIGNATURE_PURPOSE_DHT_RESULT_HOP, | ||
1399 | &ghs, | ||
1400 | (i - 1 >= put_path_len) | ||
1401 | ? &get_path[i - put_path_len - 1].sig | 1361 | ? &get_path[i - put_path_len - 1].sig |
1402 | : &put_path[i - 1].sig, | 1362 | : &put_path[i - 1].sig, |
1403 | (i >= put_path_len) | 1363 | (i >= put_path_len) |
1404 | ? &get_path[i - put_path_len].pred.public_key | 1364 | ? &get_path[i - put_path_len].pred.public_key |
1405 | : &put_path[i].pred.public_key)) | 1365 | : &put_path[i].pred.public_key)) |
1406 | { | ||
1407 | GNUNET_break_op (0); | ||
1408 | return i; | ||
1409 | } | ||
1410 | } | ||
1411 | else | ||
1412 | { | 1366 | { |
1413 | phs.pred = *pred; | 1367 | GNUNET_break_op (0); |
1414 | phs.succ = *succ; | 1368 | return i; |
1415 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1416 | "offset %u\n", | ||
1417 | i); | ||
1418 | if (GNUNET_OK != | ||
1419 | GNUNET_CRYPTO_eddsa_verify ( | ||
1420 | GNUNET_SIGNATURE_PURPOSE_DHT_PUT_HOP, | ||
1421 | &phs, | ||
1422 | (i - 1 >= put_path_len) | ||
1423 | ? &get_path[i - put_path_len - 1].sig | ||
1424 | : &put_path[i - 1].sig, | ||
1425 | (i >= put_path_len) | ||
1426 | ? &get_path[i - put_path_len].pred.public_key | ||
1427 | : &put_path[i].pred.public_key)) | ||
1428 | { | ||
1429 | GNUNET_break_op (0); | ||
1430 | return i; | ||
1431 | } | ||
1432 | } | 1369 | } |
1433 | i--; | 1370 | i--; |
1434 | } | 1371 | } |