mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
donn't calculate routing keys for routers anymore
This commit is contained in:
parent
030c04de81
commit
09dc649101
7 changed files with 19 additions and 50 deletions
20
Identity.cpp
20
Identity.cpp
|
@ -301,7 +301,7 @@ namespace data
|
|||
dh.GenerateKeyPair(rnd, keys->privateKey, keys->publicKey);
|
||||
}
|
||||
|
||||
RoutingKey CreateRoutingKey (const IdentHash& ident)
|
||||
IdentHash CreateRoutingKey (const IdentHash& ident)
|
||||
{
|
||||
uint8_t buf[41]; // ident + yyyymmdd
|
||||
memcpy (buf, (const uint8_t *)ident, 32);
|
||||
|
@ -310,26 +310,24 @@ namespace data
|
|||
// WARNING!!! check if it is correct
|
||||
#ifdef _WIN32
|
||||
gmtime_s(&tm, &t);
|
||||
// òóò âîçâðàùàåòñÿ êàêîå-òî çíà÷åíèå sprintf'îì. ìîæåò ñòîèò åãî ïðîâåðÿòü?
|
||||
// http://msdn.microsoft.com/en-us/library/ce3zzk1k.aspx
|
||||
sprintf_s((char *)(buf + 32), 9, "%4i%2i%2i", tm.tm_year, tm.tm_mon, tm.tm_mday);
|
||||
#else
|
||||
gmtime_r(&t, &tm);
|
||||
// òóò âîçâðàùàåòñÿ êàêîå-òî çíà÷åíèå sprintf'îì. ìîæåò ñòîèò åãî ïðîâåðÿòü?
|
||||
sprintf((char *)(buf + 32), "%4i%2i%2i", tm.tm_year, tm.tm_mon, tm.tm_mday);
|
||||
#endif
|
||||
RoutingKey key;
|
||||
CryptoPP::SHA256().CalculateDigest(key.hash, buf, 40);
|
||||
IdentHash key;
|
||||
CryptoPP::SHA256().CalculateDigest((uint8_t *)key, buf, 40);
|
||||
return key;
|
||||
}
|
||||
|
||||
XORMetric operator^(const RoutingKey& key1, const RoutingKey& key2)
|
||||
XORMetric operator^(const IdentHash& key1, const IdentHash& key2)
|
||||
{
|
||||
XORMetric m;
|
||||
m.metric_ll[0] = key1.hash_ll[0] ^ key2.hash_ll[0];
|
||||
m.metric_ll[1] = key1.hash_ll[1] ^ key2.hash_ll[1];
|
||||
m.metric_ll[2] = key1.hash_ll[2] ^ key2.hash_ll[2];
|
||||
m.metric_ll[3] = key1.hash_ll[3] ^ key2.hash_ll[3];
|
||||
const uint64_t * hash1 = key1.GetLL (), * hash2 = key2.GetLL ();
|
||||
m.metric_ll[0] = hash1[0] ^ hash2[0];
|
||||
m.metric_ll[1] = hash1[1] ^ hash2[1];
|
||||
m.metric_ll[2] = hash1[2] ^ hash2[2];
|
||||
m.metric_ll[3] = hash1[3] ^ hash2[3];
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue