mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-05 14:04:17 +00:00
use unique_ptr for ElGamalEncryption
This commit is contained in:
parent
1e74ff8a85
commit
3983838694
11
Identity.h
11
Identity.h
@ -4,6 +4,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "ElGamal.h"
|
#include "ElGamal.h"
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
@ -219,23 +220,23 @@ namespace data
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RoutingDestination (): m_ElGamalEncryption (nullptr) {};
|
RoutingDestination () {};
|
||||||
virtual ~RoutingDestination () { delete m_ElGamalEncryption; };
|
virtual ~RoutingDestination () {};
|
||||||
|
|
||||||
virtual const IdentHash& GetIdentHash () const = 0;
|
virtual const IdentHash& GetIdentHash () const = 0;
|
||||||
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
virtual const uint8_t * GetEncryptionPublicKey () const = 0;
|
||||||
virtual bool IsDestination () const = 0; // for garlic
|
virtual bool IsDestination () const = 0; // for garlic
|
||||||
|
|
||||||
const i2p::crypto::ElGamalEncryption * GetElGamalEncryption () const
|
std::unique_ptr<const i2p::crypto::ElGamalEncryption>& GetElGamalEncryption () const
|
||||||
{
|
{
|
||||||
if (!m_ElGamalEncryption)
|
if (!m_ElGamalEncryption)
|
||||||
m_ElGamalEncryption = new i2p::crypto::ElGamalEncryption (GetEncryptionPublicKey ());
|
m_ElGamalEncryption.reset (new i2p::crypto::ElGamalEncryption (GetEncryptionPublicKey ()));
|
||||||
return m_ElGamalEncryption;
|
return m_ElGamalEncryption;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
mutable i2p::crypto::ElGamalEncryption * m_ElGamalEncryption; // use lazy initialization
|
mutable std::unique_ptr<const i2p::crypto::ElGamalEncryption> m_ElGamalEncryption; // use lazy initialization
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocalDestination
|
class LocalDestination
|
||||||
|
Loading…
x
Reference in New Issue
Block a user