mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
use pointer to whole struct instead publicKey for buffer
This commit is contained in:
parent
4edde333ad
commit
5e301937f2
|
@ -27,18 +27,15 @@ namespace data
|
||||||
|
|
||||||
size_t Identity::FromBuffer (const uint8_t * buf, size_t len)
|
size_t Identity::FromBuffer (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
if ( len < DEFAULT_IDENTITY_SIZE ) {
|
if (len < DEFAULT_IDENTITY_SIZE) return 0; // buffer too small, don't overflow
|
||||||
// buffer too small, don't overflow
|
memcpy (this, buf, DEFAULT_IDENTITY_SIZE);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
memcpy (publicKey, buf, DEFAULT_IDENTITY_SIZE);
|
|
||||||
return DEFAULT_IDENTITY_SIZE;
|
return DEFAULT_IDENTITY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentHash Identity::Hash () const
|
IdentHash Identity::Hash () const
|
||||||
{
|
{
|
||||||
IdentHash hash;
|
IdentHash hash;
|
||||||
SHA256(publicKey, DEFAULT_IDENTITY_SIZE, hash);
|
SHA256((const uint8_t *)this, DEFAULT_IDENTITY_SIZE, hash);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue