mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
store and check remote Identity
This commit is contained in:
parent
c9c311c41e
commit
f811b19cf1
4 changed files with 49 additions and 14 deletions
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue