mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
handle TunnelBuildMessage for ECIES router
This commit is contained in:
parent
b12fa97a38
commit
3907c17cf5
6 changed files with 93 additions and 17 deletions
|
@ -127,9 +127,7 @@ namespace tunnel
|
|||
void TunnelHopConfig::EncryptECIES (std::shared_ptr<i2p::crypto::CryptoKeyEncryptor>& encryptor,
|
||||
const uint8_t * plainText, uint8_t * encrypted, BN_CTX * ctx)
|
||||
{
|
||||
static const char protocolName[] = "Noise_N_25519_ChaChaPoly_SHA256"; // 31 chars
|
||||
memcpy (m_CK, protocolName, 32); // ck = h = protocol_name || 0
|
||||
SHA256 (m_CK, 32, m_H); // h = SHA256(h);
|
||||
InitBuildRequestRecordNoiseState (*this);
|
||||
uint8_t hepk[32];
|
||||
encryptor->Encrypt (nullptr, hepk, nullptr, false);
|
||||
MixHash (hepk, 32); // h = SHA256(h || hepk)
|
||||
|
@ -150,5 +148,12 @@ namespace tunnel
|
|||
}
|
||||
MixHash (encrypted, ECIES_BUILD_REQUEST_RECORD_CLEAR_TEXT_SIZE + 16); // h = SHA256(h || ciphertext)
|
||||
}
|
||||
|
||||
void InitBuildRequestRecordNoiseState (i2p::crypto::NoiseSymmetricState& state)
|
||||
{
|
||||
static const char protocolName[] = "Noise_N_25519_ChaChaPoly_SHA256"; // 31 chars
|
||||
memcpy (state.m_CK, protocolName, 32); // ck = h = protocol_name || 0
|
||||
SHA256 (state.m_CK, 32, state.m_H); // h = SHA256(h);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue