diff --git a/Garlic.cpp b/Garlic.cpp index 5b5fd71b..b2f64000 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -187,8 +187,9 @@ namespace garlic RAND_bytes (elGamal.preIV, 32); // Pre-IV uint8_t iv[32]; // IV is first 16 bytes SHA256(elGamal.preIV, 32, iv); - i2p::crypto::ElGamalEncrypt (m_Destination->GetEncryptionPublicKey (), - (uint8_t *)&elGamal, buf, m_Owner->GetBNContext (), true); + BN_CTX * ctx = BN_CTX_new (); + i2p::crypto::ElGamalEncrypt (m_Destination->GetEncryptionPublicKey (), (uint8_t *)&elGamal, buf, ctx, true); + BN_CTX_free (ctx); m_Encryption.SetIV (iv); buf += 514; len += 514; diff --git a/Garlic.h b/Garlic.h index 6b05df42..6cc37a7d 100644 --- a/Garlic.h +++ b/Garlic.h @@ -158,7 +158,6 @@ namespace garlic void CleanUp (); void SetNumTags (int numTags) { m_NumTags = numTags; }; - BN_CTX * GetBNContext () const { return m_Ctx; }; std::shared_ptr GetRoutingSession (std::shared_ptr destination, bool attachLeaseSet); void CleanupExpiredTags (); void RemoveDeliveryStatusSession (uint32_t msgID); @@ -190,7 +189,7 @@ namespace garlic private: - BN_CTX * m_Ctx; + BN_CTX * m_Ctx; // incoming // outgoing sessions int m_NumTags; std::mutex m_SessionsMutex;