mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 09:21:08 +00:00
check if session key is available
This commit is contained in:
parent
2140f49665
commit
747383a5e6
8
SSU.cpp
8
SSU.cpp
@ -843,11 +843,11 @@ namespace ssu
|
|||||||
|
|
||||||
void SSUSession::SendSesionDestroyed ()
|
void SSUSession::SendSesionDestroyed ()
|
||||||
{
|
{
|
||||||
uint8_t buf[48 + 18], iv[16];
|
if (HasSessionKey ())
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
|
||||||
rnd.GenerateBlock (iv, 16); // random iv
|
|
||||||
if (m_State == eSessionStateEstablished)
|
|
||||||
{
|
{
|
||||||
|
uint8_t buf[48 + 18], iv[16];
|
||||||
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
|
rnd.GenerateBlock (iv, 16); // random iv
|
||||||
// encrypt message with session key
|
// encrypt message with session key
|
||||||
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48, m_SessionKey, iv, m_MacKey);
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48, m_SessionKey, iv, m_MacKey);
|
||||||
m_Server.Send (buf, 48, m_RemoteEndpoint);
|
m_Server.Send (buf, 48, m_RemoteEndpoint);
|
||||||
|
1
SSU.h
1
SSU.h
@ -118,6 +118,7 @@ namespace ssu
|
|||||||
void Decrypt (uint8_t * buf, size_t len, const uint8_t * aesKey);
|
void Decrypt (uint8_t * buf, size_t len, const uint8_t * aesKey);
|
||||||
bool Validate (uint8_t * buf, size_t len, const uint8_t * macKey);
|
bool Validate (uint8_t * buf, size_t len, const uint8_t * macKey);
|
||||||
const uint8_t * GetIntroKey () const;
|
const uint8_t * GetIntroKey () const;
|
||||||
|
bool HasSessionKey () const { return m_State == eSessionStateCreatedReceived || m_State == eSessionStateRequestReceived; };
|
||||||
|
|
||||||
void ScheduleTermination ();
|
void ScheduleTermination ();
|
||||||
void HandleTerminationTimer (const boost::system::error_code& ecode);
|
void HandleTerminationTimer (const boost::system::error_code& ecode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user