summaryrefslogtreecommitdiff
path: root/include/m_db_int.h
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-01-08 17:55:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-01-08 17:55:06 +0300
commit8f3e583fffeba6606cf4442008c65e6902308080 (patch)
tree3dc085bc50bb64993faaaa5e4aeeaa273396887e /include/m_db_int.h
parent64579d553e4089d55c136140bd0058696d2cf526 (diff)
encryption code unification, part 2: initialization & data storage
Diffstat (limited to 'include/m_db_int.h')
-rw-r--r--include/m_db_int.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
index 45440ff981..b4fef07719 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -175,7 +175,7 @@ class MIR_APP_EXPORT MDatabaseCommon : public MIDatabase, public MNonCopyable
HANDLE m_hLock = nullptr;
protected:
- bool m_bEncrypted = false;
+ bool m_bEncrypted = false, m_bUsesPassword = false;
int m_codePage;
mir_cs m_csDbAccess;
@@ -184,13 +184,24 @@ protected:
MICryptoEngine *m_crypto;
protected:
+ int CheckProto(DBCachedContact *cc, const char *proto);
void FillContactSettings();
bool LockName(const wchar_t *pwszProfileName);
- int CheckProto(DBCachedContact *cc, const char *proto);
void UnlockName();
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // encryption support
+
+ int InitCrypt();
+
CRYPTO_PROVIDER* SelectProvider();
- STDMETHOD_(BOOL, StoreProvider)(CRYPTO_PROVIDER*);
+ STDMETHOD_(CRYPTO_PROVIDER*, ReadProvider)() PURE;
+ STDMETHOD_(BOOL, StoreProvider)(CRYPTO_PROVIDER*) PURE;
+
+ STDMETHOD_(BOOL, ReadCryptoKey)(MBinBuffer&) PURE;
+ STDMETHOD_(BOOL, StoreCryptoKey)() PURE;
+
+ STDMETHOD_(BOOL, ReadEncryption)() PURE;
STDMETHOD_(BOOL, GetContactSettingWorker)(MCONTACT contactID, LPCSTR szModule, LPCSTR szSetting, DBVARIANT *dbv, int isStatic);
STDMETHOD_(BOOL, WriteContactSettingWorker)(MCONTACT contactID, DBCONTACTWRITESETTING &dbcws) PURE;
@@ -202,6 +213,7 @@ public:
__forceinline bool isEncrypted() const { return m_bEncrypted; }
__forceinline MICryptoEngine* getCrypt() const { return m_crypto; }
__forceinline MIDatabaseCache* getCache() const { return m_cache; }
+ __forceinline bool usesPassword() const { return m_bUsesPassword; }
STDMETHODIMP_(BOOL) DeleteModule(MCONTACT contactID, LPCSTR szModule) override;
@@ -247,6 +259,12 @@ public:
STDMETHODIMP_(BOOL) EnumModuleNames(DBMODULEENUMPROC, void*) override;
+ STDMETHODIMP_(CRYPTO_PROVIDER*) ReadProvider() override;
+ STDMETHODIMP_(BOOL) StoreProvider(CRYPTO_PROVIDER*) override;
+ STDMETHODIMP_(BOOL) ReadCryptoKey(MBinBuffer&) override;
+ STDMETHODIMP_(BOOL) StoreCryptoKey() override;
+ STDMETHODIMP_(BOOL) ReadEncryption() override;
+
////////////////////////////////////////////////////////////////////////////////////////
STDMETHODIMP_(MCONTACT) AddContact(void) override;
STDMETHODIMP_(LONG) DeleteContact(MCONTACT) override;