From dd1a233859068abf8f295dc2c989c3f89a0ae1cf Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Mon, 27 May 2024 07:32:28 -0400 Subject: [PATCH] Fix force conversion of KDBX3 if using Quick Unlock * Use SHA256 hash of the file path of the database to generate a UUID when using the KDBX3 format. This restores the original behavior of using the file path as the quick unlock lookup key. --- src/core/Database.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/Database.cpp b/src/core/Database.cpp index c5156bbce..031955c1e 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -1041,6 +1041,13 @@ void Database::stopModifiedTimer() QUuid Database::publicUuid() { + // This feature requires KDBX4 + if (m_data.formatVersion < KeePass2::FILE_VERSION_4) { + // Return the file path hash as a UUID for KDBX3 + QCryptographicHash hasher(QCryptographicHash::Sha256); + hasher.addData(filePath().toUtf8()); + return QUuid::fromRfc4122(hasher.result().left(16)); + } if (!publicCustomData().contains("KPXC_PUBLIC_UUID")) { publicCustomData().insert("KPXC_PUBLIC_UUID", QUuid::createUuid().toRfc4122());