mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-06-04 00:01:35 +00:00
reuse previously calculated peer ordering group
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#include "I2PEndian.h"
|
||||
#include "Base.h"
|
||||
#include "Crypto.h"
|
||||
#include "Siphash.h"
|
||||
#include "Log.h"
|
||||
#include "Timestamp.h"
|
||||
#include "I2NPProtocol.h"
|
||||
@@ -1407,22 +1406,5 @@ namespace data
|
||||
if (r->GetBuffer ()) return true;
|
||||
return r->LoadBuffer (m_Storage.Path (r->GetIdentHashBase64 ()));
|
||||
}
|
||||
|
||||
int CalculatePeerOrderingGroup (i2p::data::Tag<16> key, const i2p::data::IdentHash& routerIdent)
|
||||
{
|
||||
uint8_t hash[16];
|
||||
#if OPENSSL_SIPHASH
|
||||
EVP_PKEY * sipKey = EVP_PKEY_new_raw_private_key (EVP_PKEY_SIPHASH, nullptr, key, 16);
|
||||
EVP_MD_CTX * ctx = EVP_MD_CTX_create ();
|
||||
EVP_DigestSignInit (ctx, nullptr, nullptr, nullptr, sipKey);
|
||||
size_t l = 16;
|
||||
EVP_DigestSign (ctx, hash, &l, routerIdent, 32);
|
||||
EVP_MD_CTX_destroy (ctx);
|
||||
EVP_PKEY_free (sipKey);
|
||||
#else
|
||||
i2p::crypto::Siphash<16> (hash, routerIdent, 32, key);
|
||||
#endif
|
||||
return hash[0] & 0x03;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user