Browse Source

correct ad calculation for SessionCreated

pull/1194/head
orignal 7 years ago
parent
commit
6b37a41e00
  1. 9
      libi2pd/NTCP2.cpp

9
libi2pd/NTCP2.cpp

@ -84,15 +84,18 @@ namespace transport
uint8_t h[64]; uint8_t h[64];
memcpy (h, m_H, 32); memcpy (h, m_H, 32);
memcpy (h + 32, sessionRequest + 32, 32); // encrypted payload memcpy (h + 32, sessionRequest + 32, 32); // encrypted payload
SHA256 (h, 64, m_H); SHA256 (h, 64, h);
int paddingLength = sessionRequestLen - 64; int paddingLength = sessionRequestLen - 64;
if (paddingLength > 0) if (paddingLength > 0)
{ {
std::vector<uint8_t> h1(paddingLength + 32); std::vector<uint8_t> h1(paddingLength + 32);
memcpy (h1.data (), m_H, 32); memcpy (h1.data (), h, 32);
memcpy (h1.data () + 32, sessionRequest + 64, paddingLength); memcpy (h1.data () + 32, sessionRequest + 64, paddingLength);
SHA256 (h1.data (), paddingLength + 32, m_H); SHA256 (h1.data (), paddingLength + 32, h);
} }
memcpy (h + 32, pub, 32);
SHA256 (h, 64, m_H);
// x25519 between remote pub and priv // x25519 between remote pub and priv
uint8_t inputKeyMaterial[32]; uint8_t inputKeyMaterial[32];
BN_CTX * ctx = BN_CTX_new (); BN_CTX * ctx = BN_CTX_new ();

Loading…
Cancel
Save