summaryrefslogtreecommitdiff
path: root/src/core/crypto
diff options
context:
space:
mode:
authorDavid <25727384+ogniK5377@users.noreply.github.com>2020-07-01 14:16:26 +1000
committerGitHub <noreply@github.com>2020-07-01 14:16:26 +1000
commit3bb63bc0b364ed10d478102d3174f55486438716 (patch)
treec8ecf8b20b877bd08701e0213e446e4bb9a8660c /src/core/crypto
parentc6b0353c4dac96a592b67f6360909d2ac0836ea6 (diff)
parent9f82a9a2444a232e746992fa89084b928255cb63 (diff)
Merge pull request #3967 from FearlessTobi/keys-singleton
crypto: Make KeyManager a singleton class
Diffstat (limited to 'src/core/crypto')
-rw-r--r--src/core/crypto/key_manager.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h
index 7265c4171..bf3434e1c 100644
--- a/src/core/crypto/key_manager.h
+++ b/src/core/crypto/key_manager.h
@@ -223,7 +223,13 @@ bool operator<(const KeyIndex<KeyType>& lhs, const KeyIndex<KeyType>& rhs) {
class KeyManager {
public:
- KeyManager();
+ static KeyManager& instance() {
+ static KeyManager instance;
+ return instance;
+ }
+
+ KeyManager(KeyManager const&) = delete;
+ void operator=(KeyManager const&) = delete;
bool HasKey(S128KeyType id, u64 field1 = 0, u64 field2 = 0) const;
bool HasKey(S256KeyType id, u64 field1 = 0, u64 field2 = 0) const;
@@ -257,6 +263,8 @@ public:
bool AddTicketPersonalized(Ticket raw);
private:
+ KeyManager();
+
std::map<KeyIndex<S128KeyType>, Key128> s128_keys;
std::map<KeyIndex<S256KeyType>, Key256> s256_keys;