Browse Source

don't add padding for optimal packet size

pull/1514/head
orignal 5 years ago
parent
commit
1c8d662e30
  1. 4
      libi2pd/ECIESX25519AEADRatchetSession.cpp
  2. 3
      libi2pd/ECIESX25519AEADRatchetSession.h

4
libi2pd/ECIESX25519AEADRatchetSession.cpp

@ -712,11 +712,15 @@ namespace garlic
} }
uint8_t paddingSize = 0; uint8_t paddingSize = 0;
if (payloadLen) if (payloadLen)
{
// don't create padding if we are close to optimal size
if (first || payloadLen + 19 <= ECIESX25519_OPTIMAL_PAYLOAD_SIZE || payloadLen > ECIESX25519_OPTIMAL_PAYLOAD_SIZE)
{ {
RAND_bytes (&paddingSize, 1); RAND_bytes (&paddingSize, 1);
paddingSize &= 0x0F; paddingSize++; // 1 - 16 paddingSize &= 0x0F; paddingSize++; // 1 - 16
payloadLen += paddingSize + 3; payloadLen += paddingSize + 3;
} }
}
std::vector<uint8_t> v(payloadLen); std::vector<uint8_t> v(payloadLen);
size_t offset = 0; size_t offset = 0;
// DateTime // DateTime

3
libi2pd/ECIESX25519AEADRatchetSession.h

@ -26,6 +26,9 @@ namespace garlic
const int ECIESX25519_MAX_NUM_GENERATED_TAGS = 160; const int ECIESX25519_MAX_NUM_GENERATED_TAGS = 160;
const int ECIESX25519_NSR_NUM_GENERATED_TAGS = 12; const int ECIESX25519_NSR_NUM_GENERATED_TAGS = 12;
const size_t ECIESX25519_OPTIMAL_PAYLOAD_SIZE = 1912; // 1912 = 1956 /* to fit 2 tunnel messages */
// - 16 /* I2NP header */ - 16 /* poly hash */ - 8 /* tag */ - 4 /* garlic length */
class ECIESX25519AEADRatchetSession; class ECIESX25519AEADRatchetSession;
class RatchetTagSet class RatchetTagSet
{ {

Loading…
Cancel
Save