mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
store and check remote Identity
This commit is contained in:
15
Identity.cpp
15
Identity.cpp
@@ -16,20 +16,27 @@ namespace data
|
||||
{
|
||||
// copy public and signing keys together
|
||||
memcpy (publicKey, keys.publicKey, sizeof (publicKey) + sizeof (signingKey));
|
||||
memset (certificate, 0, sizeof (certificate));
|
||||
memset (&certificate, 0, sizeof (certificate));
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Identity::FromBase64 (const std::string& s)
|
||||
{
|
||||
size_t count = Base64ToByteStream (s.c_str(), s.length(), publicKey, sizeof (Identity));
|
||||
return count == sizeof(Identity);
|
||||
size_t count = Base64ToByteStream (s.c_str(), s.length(), publicKey, DEFAULT_IDENTITY_SIZE);
|
||||
return count == DEFAULT_IDENTITY_SIZE;
|
||||
}
|
||||
|
||||
size_t Identity::FromBuffer (const uint8_t * buf, size_t len)
|
||||
{
|
||||
memcpy (publicKey, buf, DEFAULT_IDENTITY_SIZE);
|
||||
// TODO: process certificate
|
||||
return DEFAULT_IDENTITY_SIZE;
|
||||
}
|
||||
|
||||
IdentHash Identity::Hash() const
|
||||
{
|
||||
IdentHash hash;
|
||||
CryptoPP::SHA256().CalculateDigest(hash, publicKey, sizeof (Identity));
|
||||
CryptoPP::SHA256().CalculateDigest(hash, publicKey, DEFAULT_IDENTITY_SIZE);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user