|
|
@ -655,11 +655,10 @@ namespace transport |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO: we are using a dirty solution here but should work for now
|
|
|
|
|
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
memcpy (header->iv, iv, 16); |
|
|
|
memcpy (header->iv, iv, 16); |
|
|
|
header->flag = payloadType << 4; // MSB is 0
|
|
|
|
header->flag = payloadType << 4; // MSB is 0
|
|
|
|
htobe32buf (&(header->time), i2p::util::GetSecondsSinceEpoch ()); |
|
|
|
htobe32buf (header->time, i2p::util::GetSecondsSinceEpoch ()); |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
i2p::crypto::CBCEncryption encryption; |
|
|
|
i2p::crypto::CBCEncryption encryption; |
|
|
@ -679,12 +678,11 @@ namespace transport |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO: we are using a dirty solution here but should work for now
|
|
|
|
|
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
RAND_bytes (header->iv, 16); // random iv
|
|
|
|
RAND_bytes (header->iv, 16); // random iv
|
|
|
|
m_SessionKeyEncryption.SetIV (header->iv); |
|
|
|
m_SessionKeyEncryption.SetIV (header->iv); |
|
|
|
header->flag = payloadType << 4; // MSB is 0
|
|
|
|
header->flag = payloadType << 4; // MSB is 0
|
|
|
|
htobe32buf (&(header->time), i2p::util::GetSecondsSinceEpoch ()); |
|
|
|
htobe32buf (header->time, i2p::util::GetSecondsSinceEpoch ()); |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
m_SessionKeyEncryption.Encrypt (encrypted, encryptedLen, encrypted); |
|
|
|
m_SessionKeyEncryption.Encrypt (encrypted, encryptedLen, encrypted); |
|
|
@ -701,7 +699,6 @@ namespace transport |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO: since we are accessing a uint8_t this is unlikely to crash due to alignment but should be improved
|
|
|
|
|
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
@ -718,7 +715,6 @@ namespace transport |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO: since we are accessing a uint8_t this is unlikely to crash due to alignment but should be improved
|
|
|
|
|
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
@ -736,7 +732,6 @@ namespace transport |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
LogPrint (eLogError, "SSU: Unexpected packet length ", len); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
//TODO: since we are accessing a uint8_t this is unlikely to crash due to alignment but should be improved
|
|
|
|
|
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint8_t * encrypted = &header->flag; |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|
uint16_t encryptedLen = len - (encrypted - buf); |
|
|
|