Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32739042
D14268.1767673786.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D14268.1767673786.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -210,6 +210,9 @@
#else
virtual void createMainCompaction(std::string backupID) const = 0;
virtual void captureBackupLogs() const = 0;
+ virtual void setUserDataKeys(
+ const std::string &backupDataKey,
+ const std::string &backupLogDataKey) const = 0;
#endif
};
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -225,6 +225,9 @@
static void initialize(std::string &databasePath);
void createMainCompaction(std::string backupID) const override;
void captureBackupLogs() const override;
+ void setUserDataKeys(
+ const std::string &backupDataKey,
+ const std::string &backupLogDataKey) const override;
#endif
};
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -3160,6 +3160,38 @@
}
this->setMetadata("logID", std::to_string(std::stoi(logID) + 1));
}
+
+void SQLiteQueryExecutor::setUserDataKeys(
+ const std::string &backupDataKey,
+ const std::string &backupLogDataKey) const {
+ if (SQLiteQueryExecutor::backupDataKey.empty()) {
+ throw std::runtime_error("backupDataKey is not set");
+ }
+
+ if (SQLiteQueryExecutor::backupLogDataKey.empty()) {
+ throw std::runtime_error("invalid backupLogDataKey size");
+ }
+
+ if (backupDataKey.size() != SQLiteQueryExecutor::backupDataKeySize) {
+ throw std::runtime_error("invalid backupDataKey size");
+ }
+
+ if (backupLogDataKey.size() != SQLiteQueryExecutor::backupLogDataKeySize) {
+ throw std::runtime_error("invalid backupLogDataKey size");
+ }
+
+ std::string rekey_encryption_key_query =
+ "PRAGMA rekey = \"x'" + backupDataKey + "'\";";
+
+ executeQuery(
+ SQLiteQueryExecutor::getConnection(), rekey_encryption_key_query);
+
+ CommSecureStore::set(CommSecureStore::backupDataKey, backupDataKey);
+ SQLiteQueryExecutor::backupDataKey = backupDataKey;
+
+ CommSecureStore::set(CommSecureStore::backupLogDataKey, backupLogDataKey);
+ SQLiteQueryExecutor::backupLogDataKey = backupLogDataKey;
+}
#endif
void SQLiteQueryExecutor::restoreFromMainCompaction(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 6, 4:29 AM (23 m, 16 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5899327
Default Alt Text
D14268.1767673786.diff (2 KB)
Attached To
Mode
D14268: [SQLite] implement setting User Data keys
Attached
Detach File
Event Timeline
Log In to Comment