Browse Source

correct reply key and IV for ECIES record

pull/1553/merge
orignal 4 years ago
parent
commit
1740715c00
  1. 13
      libi2pd/I2NPProtocol.cpp

13
libi2pd/I2NPProtocol.cpp

@ -410,7 +410,9 @@ namespace i2p
for (int j = 0; j < num; j++) for (int j = 0; j < num; j++)
{ {
uint8_t * reply = records + j*TUNNEL_BUILD_RECORD_SIZE; uint8_t * reply = records + j*TUNNEL_BUILD_RECORD_SIZE;
if (isECIES && j == i) if (isECIES)
{
if (j == i)
{ {
uint8_t nonce[12]; uint8_t nonce[12];
memset (nonce, 0, 12); memset (nonce, 0, 12);
@ -423,6 +425,13 @@ namespace i2p
} }
} }
else else
{
encryption.SetKey (clearText + ECIES_BUILD_REQUEST_RECORD_REPLY_KEY_OFFSET);
encryption.SetIV (clearText + ECIES_BUILD_REQUEST_RECORD_REPLY_IV_OFFSET);
encryption.Encrypt(reply, TUNNEL_BUILD_RECORD_SIZE, reply);
}
}
else
{ {
encryption.SetKey (clearText + BUILD_REQUEST_RECORD_REPLY_KEY_OFFSET); encryption.SetKey (clearText + BUILD_REQUEST_RECORD_REPLY_KEY_OFFSET);
encryption.SetIV (clearText + BUILD_REQUEST_RECORD_REPLY_IV_OFFSET); encryption.SetIV (clearText + BUILD_REQUEST_RECORD_REPLY_IV_OFFSET);
@ -466,7 +475,7 @@ namespace i2p
{ {
if (i2p::context.IsECIES ()) if (i2p::context.IsECIES ())
{ {
uint8_t clearText[TUNNEL_BUILD_RECORD_SIZE]; uint8_t clearText[ECIES_BUILD_REQUEST_RECORD_CLEAR_TEXT_SIZE];
if (HandleBuildRequestRecords (num, buf + 1, clearText)) if (HandleBuildRequestRecords (num, buf + 1, clearText))
{ {
if (clearText[ECIES_BUILD_REQUEST_RECORD_FLAG_OFFSET] & 0x40) // we are endpoint of outboud tunnel if (clearText[ECIES_BUILD_REQUEST_RECORD_FLAG_OFFSET] & 0x40) // we are endpoint of outboud tunnel

Loading…
Cancel
Save