Implements KDBX4 format with Argon2 KDF

* Adds KDBX4 reader/writer interfaces
* Adds KDBX4 XML reader/write interfaces
* Implements test cases for KDBX4
* Fully compatible with KeePass2
* Corrects minor issues with Argon2 KDF
This commit is contained in:
Jonathan White
2018-01-05 10:41:29 -05:00
parent 7dba788d09
commit bef7ba2cfe
36 changed files with 3305 additions and 51 deletions

View File

@@ -22,6 +22,7 @@
#include "format/KeePass2Writer.h"
#include "core/Database.h"
#include "format/Kdbx3Writer.h"
#include "format/Kdbx4Writer.h"
BaseKeePass2Writer::BaseKeePass2Writer() : m_error(false)
{
@@ -67,6 +68,22 @@ QString KeePass2Writer::errorString()
}
bool KeePass2Writer::writeDatabase(QIODevice* device, Database* db) {
m_writer.reset(static_cast<BaseKeePass2Writer*>(new Kdbx3Writer()));
bool useKdbx4 = false;
if (db->kdf()->uuid() != KeePass2::KDF_AES) {
useKdbx4 = true;
}
if (db->publicCustomData().size() > 0) {
useKdbx4 = true;
}
// Determine KDBX3 vs KDBX4
if (useKdbx4) {
m_writer.reset(new Kdbx4Writer());
} else {
m_writer.reset(new Kdbx3Writer());
}
return m_writer->writeDatabase(device, db);
}