1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

don't copy LS2 for signature verification

This commit is contained in:
orignal 2019-01-10 10:57:57 -05:00
parent 6311a80d0e
commit 84de7675c4

View File

@ -307,11 +307,12 @@ namespace data
bool LeaseSet2::VerifySignature (Verifier& verifier, const uint8_t * buf, size_t len, size_t signatureOffset) bool LeaseSet2::VerifySignature (Verifier& verifier, const uint8_t * buf, size_t len, size_t signatureOffset)
{ {
if (signatureOffset + verifier->GetSignatureLen () > len) return false; if (signatureOffset + verifier->GetSignatureLen () > len) return false;
uint8_t * buf1 = new uint8_t[signatureOffset + 1]; // we assume buf inside DatabaseStore message, so buf[-1] is valid memory
buf1[0] = m_StoreType; // change it for signature verification, and restore back
memcpy (buf1 + 1, buf, signatureOffset); // TODO: implement it better uint8_t c = buf[-1];
bool verified = verifier->Verify (buf1, signatureOffset + 1, buf + signatureOffset); const_cast<uint8_t *>(buf)[-1] = m_StoreType;
delete[] buf1; bool verified = verifier->Verify (buf - 1, signatureOffset + 1, buf + signatureOffset);
const_cast<uint8_t *>(buf)[-1] = c;
if (!verified) if (!verified)
LogPrint (eLogWarning, "LeaseSet2: verification failed"); LogPrint (eLogWarning, "LeaseSet2: verification failed");
return verified; return verified;