diff --git a/Identity.cpp b/Identity.cpp index f2be3ba7..65bcf84f 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -265,6 +265,13 @@ namespace data } } + void IdentityEx::DropVerifier () + { + auto verifier = m_Verifier; + m_Verifier = nullptr; // TODO: make this atomic + delete verifier; + } + PrivateKeys& PrivateKeys::operator=(const Keys& keys) { m_Public = Identity (keys); diff --git a/Identity.h b/Identity.h index 223134e6..f9fe00e5 100644 --- a/Identity.h +++ b/Identity.h @@ -135,7 +135,8 @@ namespace data bool Verify (const uint8_t * buf, size_t len, const uint8_t * signature) const; SigningKeyType GetSigningKeyType () const; CryptoKeyType GetCryptoKeyType () const; - + void DropVerifier (); // to save memory + private: void CreateVerifier () const; diff --git a/RouterInfo.cpp b/RouterInfo.cpp index d50b3be0..14d338e9 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -101,8 +101,12 @@ namespace data { // verify signature int l = m_BufferLen - m_RouterIdentity.GetSignatureLen (); - if (!m_RouterIdentity.Verify ((uint8_t *)m_Buffer, l, (uint8_t *)m_Buffer + l)) - LogPrint (eLogError, "signature verification failed"); + if (!m_RouterIdentity.Verify ((uint8_t *)m_Buffer, l, (uint8_t *)m_Buffer + l)) + { + LogPrint (eLogError, "signature verification failed"); + m_IsUnreachable = true; + } + m_RouterIdentity.DropVerifier (); } }