mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
don't create enryptor for ECIES record encryption
This commit is contained in:
parent
cd8e8970de
commit
99c7d5c23a
|
@ -131,17 +131,14 @@ namespace tunnel
|
||||||
|
|
||||||
void ECIESTunnelHopConfig::EncryptECIES (const uint8_t * plainText, size_t len, uint8_t * encrypted)
|
void ECIESTunnelHopConfig::EncryptECIES (const uint8_t * plainText, size_t len, uint8_t * encrypted)
|
||||||
{
|
{
|
||||||
auto encryptor = ident->CreateEncryptor (nullptr);
|
if (!ident) return;
|
||||||
if (!encryptor) return;
|
i2p::crypto::InitNoiseNState (*this, ident->GetEncryptionPublicKey ());
|
||||||
uint8_t hepk[32];
|
|
||||||
encryptor->Encrypt (nullptr, hepk, nullptr, false);
|
|
||||||
i2p::crypto::InitNoiseNState (*this, hepk);
|
|
||||||
auto ephemeralKeys = i2p::transport::transports.GetNextX25519KeysPair ();
|
auto ephemeralKeys = i2p::transport::transports.GetNextX25519KeysPair ();
|
||||||
memcpy (encrypted, ephemeralKeys->GetPublicKey (), 32);
|
memcpy (encrypted, ephemeralKeys->GetPublicKey (), 32);
|
||||||
MixHash (encrypted, 32); // h = SHA256(h || sepk)
|
MixHash (encrypted, 32); // h = SHA256(h || sepk)
|
||||||
encrypted += 32;
|
encrypted += 32;
|
||||||
uint8_t sharedSecret[32];
|
uint8_t sharedSecret[32];
|
||||||
ephemeralKeys->Agree (hepk, sharedSecret); // x25519(sesk, hepk)
|
ephemeralKeys->Agree (ident->GetEncryptionPublicKey (), sharedSecret); // x25519(sesk, hepk)
|
||||||
MixKey (sharedSecret);
|
MixKey (sharedSecret);
|
||||||
uint8_t nonce[12];
|
uint8_t nonce[12];
|
||||||
memset (nonce, 0, 12);
|
memset (nonce, 0, 12);
|
||||||
|
|
Loading…
Reference in a new issue