MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / DecryptECIESTunnelBuildRecord

Method DecryptECIESTunnelBuildRecord

libi2pd/RouterContext.cpp:1369–1392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1367 }
1368
1369 bool RouterContext::DecryptECIESTunnelBuildRecord (const uint8_t * encrypted, uint8_t * data, size_t clearTextSize)
1370 {
1371 // m_InitialNoiseState is h = SHA256(h || hepk)
1372 m_CurrentNoiseState = m_InitialNoiseState;
1373 m_CurrentNoiseState.MixHash (encrypted, 32); // h = SHA256(h || sepk)
1374 uint8_t sharedSecret[32];
1375 if (!m_TunnelDecryptor->Decrypt (encrypted, sharedSecret))
1376 {
1377 LogPrint (eLogWarning, "Router: Incorrect ephemeral public key");
1378 return false;
1379 }
1380 m_CurrentNoiseState.MixKey (sharedSecret);
1381 encrypted += 32;
1382 uint8_t nonce[12];
1383 memset (nonce, 0, 12);
1384 if (!i2p::crypto::AEADChaCha20Poly1305 (encrypted, clearTextSize, m_CurrentNoiseState.m_H, 32,
1385 m_CurrentNoiseState.m_CK + 32, nonce, data, clearTextSize, false)) // decrypt
1386 {
1387 LogPrint (eLogWarning, "Router: Tunnel record AEAD decryption failed");
1388 return false;
1389 }
1390 m_CurrentNoiseState.MixHash (encrypted, clearTextSize + 16); // h = SHA256(h || ciphertext)
1391 return true;
1392 }
1393
1394 bool RouterContext::DecryptTunnelShortRequestRecord (const uint8_t * encrypted, uint8_t * data)
1395 {

Callers

nothing calls this directly

Calls 5

LogPrintFunction · 0.85
AEADChaCha20Poly1305Function · 0.85
MixHashMethod · 0.80
MixKeyMethod · 0.80
DecryptMethod · 0.45

Tested by

no test coverage detected