mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
transient key signature verification
This commit is contained in:
parent
bce4224d6e
commit
2e56c4895d
@ -249,6 +249,9 @@ namespace data
|
|||||||
if (flags & 0x0001)
|
if (flags & 0x0001)
|
||||||
{
|
{
|
||||||
// offline key
|
// offline key
|
||||||
|
if (offset + 6 >= len) return;
|
||||||
|
const uint8_t * signedData = buf + offset;
|
||||||
|
offset += 4; // expires timestamp
|
||||||
uint16_t keyType = bufbe16toh (buf + offset); offset += 2;
|
uint16_t keyType = bufbe16toh (buf + offset); offset += 2;
|
||||||
offlineVerifier.reset (i2p::data::IdentityEx::CreateVerifier (keyType));
|
offlineVerifier.reset (i2p::data::IdentityEx::CreateVerifier (keyType));
|
||||||
if (!offlineVerifier) return;
|
if (!offlineVerifier) return;
|
||||||
@ -256,16 +259,9 @@ namespace data
|
|||||||
if (offset + keyLen >= len) return;
|
if (offset + keyLen >= len) return;
|
||||||
offlineVerifier->SetPublicKey (buf + offset); offset += keyLen;
|
offlineVerifier->SetPublicKey (buf + offset); offset += keyLen;
|
||||||
if (offset + offlineVerifier->GetSignatureLen () >= len) return;
|
if (offset + offlineVerifier->GetSignatureLen () >= len) return;
|
||||||
uint8_t * signedData = new uint8_t[keyLen + 6];
|
if (!identity->Verify (signedData, keyLen + 6, buf + offset)) return;
|
||||||
htobe32buf (signedData, timestamp + expires);
|
|
||||||
htobe16buf (signedData + 4, keyType);
|
|
||||||
memcpy (signedData + 6, buf + offset - keyLen, keyLen);
|
|
||||||
bool verified = identity->Verify (signedData, keyLen + 6, buf + offset);
|
|
||||||
delete[] signedData;
|
|
||||||
if (!verified) return;
|
|
||||||
offset += offlineVerifier->GetSignatureLen ();
|
offset += offlineVerifier->GetSignatureLen ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
|
uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2;
|
||||||
offset += propertiesLen; // skip for now. TODO: implement properties
|
offset += propertiesLen; // skip for now. TODO: implement properties
|
||||||
|
Loading…
x
Reference in New Issue
Block a user