mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
generate random padding length in bulk
This commit is contained in:
parent
49a19a52c8
commit
69194118df
@ -96,6 +96,7 @@ namespace garlic
|
|||||||
ECIESX25519AEADRatchetSession::ECIESX25519AEADRatchetSession (GarlicDestination * owner, bool attachLeaseSet):
|
ECIESX25519AEADRatchetSession::ECIESX25519AEADRatchetSession (GarlicDestination * owner, bool attachLeaseSet):
|
||||||
GarlicRoutingSession (owner, attachLeaseSet)
|
GarlicRoutingSession (owner, attachLeaseSet)
|
||||||
{
|
{
|
||||||
|
RAND_bytes (m_PaddingSizes, 32); m_NextPaddingSize = 0;
|
||||||
ResetKeys ();
|
ResetKeys ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -745,8 +746,12 @@ namespace garlic
|
|||||||
int delta = (int)ECIESX25519_OPTIMAL_PAYLOAD_SIZE - (int)payloadLen;
|
int delta = (int)ECIESX25519_OPTIMAL_PAYLOAD_SIZE - (int)payloadLen;
|
||||||
if (delta < 0 || delta > 3) // don't create padding if we are close to optimal size
|
if (delta < 0 || delta > 3) // don't create padding if we are close to optimal size
|
||||||
{
|
{
|
||||||
RAND_bytes (&paddingSize, 1);
|
paddingSize = m_PaddingSizes[m_NextPaddingSize++] & 0x0F; // 0 - 15
|
||||||
paddingSize &= 0x0F; // 0 - 15
|
if (m_NextPaddingSize >= 32)
|
||||||
|
{
|
||||||
|
RAND_bytes (m_PaddingSizes, 32);
|
||||||
|
m_NextPaddingSize = 0;
|
||||||
|
}
|
||||||
if (delta > 3)
|
if (delta > 3)
|
||||||
{
|
{
|
||||||
delta -= 3;
|
delta -= 3;
|
||||||
|
@ -188,7 +188,8 @@ namespace garlic
|
|||||||
std::list<std::pair<uint16_t, int> > m_AckRequests; // (tagsetid, index)
|
std::list<std::pair<uint16_t, int> > m_AckRequests; // (tagsetid, index)
|
||||||
bool m_SendReverseKey = false, m_SendForwardKey = false;
|
bool m_SendReverseKey = false, m_SendForwardKey = false;
|
||||||
std::unique_ptr<DHRatchet> m_NextReceiveRatchet, m_NextSendRatchet;
|
std::unique_ptr<DHRatchet> m_NextReceiveRatchet, m_NextSendRatchet;
|
||||||
|
uint8_t m_PaddingSizes[32], m_NextPaddingSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// for HTTP only
|
// for HTTP only
|
||||||
|
Loading…
x
Reference in New Issue
Block a user