correct reply key and IV for ECIES record

This commit is contained in:
orignal 2020-11-04 21:04:28 -05:00
parent 21501cbf81
commit 1740715c00

View file

@ -410,7 +410,9 @@ namespace i2p
for (int j = 0; j < num; j++)
{
uint8_t * reply = records + j*TUNNEL_BUILD_RECORD_SIZE;
if (isECIES && j == i)
if (isECIES)
{
if (j == i)
{
uint8_t nonce[12];
memset (nonce, 0, 12);
@ -423,6 +425,13 @@ namespace i2p
}
}
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.SetIV (clearText + BUILD_REQUEST_RECORD_REPLY_IV_OFFSET);
@ -466,7 +475,7 @@ namespace i2p
{
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 (clearText[ECIES_BUILD_REQUEST_RECORD_FLAG_OFFSET] & 0x40) // we are endpoint of outboud tunnel