don't send datetime for one time key message
This commit is contained in:
@@ -1099,13 +1099,17 @@ namespace garlic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t CreateGarlicPayload (std::shared_ptr<const I2NPMessage> msg, uint8_t * payload)
|
static size_t CreateGarlicPayload (std::shared_ptr<const I2NPMessage> msg, uint8_t * payload, bool datetime)
|
||||||
|
{
|
||||||
|
size_t len = 0;
|
||||||
|
if (datetime)
|
||||||
{
|
{
|
||||||
size_t len = 7;
|
|
||||||
// DateTime
|
// DateTime
|
||||||
payload[0] = eECIESx25519BlkDateTime;
|
payload[0] = eECIESx25519BlkDateTime;
|
||||||
htobe16buf (payload + 1, 4);
|
htobe16buf (payload + 1, 4);
|
||||||
htobe32buf (payload + 3, i2p::util::GetSecondsSinceEpoch ());
|
htobe32buf (payload + 3, i2p::util::GetSecondsSinceEpoch ());
|
||||||
|
len = 7;
|
||||||
|
}
|
||||||
// I2NP
|
// I2NP
|
||||||
payload += len;
|
payload += len;
|
||||||
uint16_t cloveSize = msg->GetPayloadLength () + 10;
|
uint16_t cloveSize = msg->GetPayloadLength () + 10;
|
||||||
@@ -1120,10 +1124,10 @@ namespace garlic
|
|||||||
len += cloveSize + 3;
|
len += cloveSize + 3;
|
||||||
payload += cloveSize;
|
payload += cloveSize;
|
||||||
// padding
|
// padding
|
||||||
uint8_t paddingSize = (rand () & 0x0F) + 1; // 1 - 16
|
uint8_t paddingSize = rand () & 0x0F; // 0 - 15
|
||||||
payload[0] = eECIESx25519BlkPadding;
|
payload[0] = eECIESx25519BlkPadding;
|
||||||
htobe16buf (payload + 1, paddingSize);
|
htobe16buf (payload + 1, paddingSize);
|
||||||
memset (payload + 3, 0, paddingSize);
|
if (paddingSize) memset (payload + 3, 0, paddingSize);
|
||||||
len += paddingSize + 3;
|
len += paddingSize + 3;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@@ -1136,7 +1140,7 @@ namespace garlic
|
|||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
memcpy (buf + offset, &tag, 8); offset += 8;
|
memcpy (buf + offset, &tag, 8); offset += 8;
|
||||||
auto payload = buf + offset;
|
auto payload = buf + offset;
|
||||||
size_t len = CreateGarlicPayload (msg, payload);
|
size_t len = CreateGarlicPayload (msg, payload, false);
|
||||||
uint8_t nonce[12];
|
uint8_t nonce[12];
|
||||||
memset (nonce, 0, 12); // n = 0
|
memset (nonce, 0, 12); // n = 0
|
||||||
if (!i2p::crypto::AEADChaCha20Poly1305 (payload, len, buf, 8, key, nonce, payload, len + 16, true)) // encrypt
|
if (!i2p::crypto::AEADChaCha20Poly1305 (payload, len, buf, 8, key, nonce, payload, len + 16, true)) // encrypt
|
||||||
@@ -1172,7 +1176,7 @@ namespace garlic
|
|||||||
}
|
}
|
||||||
noiseState.MixKey (sharedSecret);
|
noiseState.MixKey (sharedSecret);
|
||||||
auto payload = buf + offset;
|
auto payload = buf + offset;
|
||||||
size_t len = CreateGarlicPayload (msg, payload);
|
size_t len = CreateGarlicPayload (msg, payload, true);
|
||||||
uint8_t nonce[12];
|
uint8_t nonce[12];
|
||||||
memset (nonce, 0, 12);
|
memset (nonce, 0, 12);
|
||||||
// encrypt payload
|
// encrypt payload
|
||||||
|
Reference in New Issue
Block a user