mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Move constants in KeePass2.h to KeePass2.cpp and add a list of KDFs and ciphers
This commit is contained in:
parent
a5ec7fc704
commit
33974d710a
@ -82,7 +82,7 @@ set(keepassx_SOURCES
|
|||||||
format/CsvExporter.cpp
|
format/CsvExporter.cpp
|
||||||
format/KeePass1.h
|
format/KeePass1.h
|
||||||
format/KeePass1Reader.cpp
|
format/KeePass1Reader.cpp
|
||||||
format/KeePass2.h
|
format/KeePass2.cpp
|
||||||
format/KeePass2RandomStream.cpp
|
format/KeePass2RandomStream.cpp
|
||||||
format/KeePass2Reader.cpp
|
format/KeePass2Reader.cpp
|
||||||
format/KeePass2Repair.cpp
|
format/KeePass2Repair.cpp
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "crypto/SymmetricCipherBackend.h"
|
#include "crypto/SymmetricCipherBackend.h"
|
||||||
#include "format/KeePass2.h"
|
#include "format/KeePass2.h"
|
||||||
|
#include "core/Uuid.h"
|
||||||
|
|
||||||
class SymmetricCipher
|
class SymmetricCipher
|
||||||
{
|
{
|
||||||
|
70
src/format/KeePass2.cpp
Normal file
70
src/format/KeePass2.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "KeePass2.h"
|
||||||
|
#include "crypto/CryptoHash.h"
|
||||||
|
#include "crypto/kdf/AesKdf.h"
|
||||||
|
#include "core/Uuid.h"
|
||||||
|
|
||||||
|
const Uuid KeePass2::CIPHER_AES = Uuid(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff"));
|
||||||
|
const Uuid KeePass2::CIPHER_TWOFISH = Uuid(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c"));
|
||||||
|
|
||||||
|
const Uuid KeePass2::KDF_AES = Uuid(QByteArray::fromHex("C9D9F39A628A4460BF740D08C18A4FEA"));
|
||||||
|
|
||||||
|
const QByteArray KeePass2::INNER_STREAM_SALSA20_IV("\xE8\x30\x09\x4B\x97\x20\x5D\x2A");
|
||||||
|
|
||||||
|
const QList<KeePass2::UuidNamePair> KeePass2::CIPHERS {
|
||||||
|
KeePass2::UuidNamePair(KeePass2::CIPHER_AES, "AES: 256-bit"),
|
||||||
|
KeePass2::UuidNamePair(KeePass2::CIPHER_TWOFISH, "Twofish: 256-bit"),
|
||||||
|
};
|
||||||
|
const QList<KeePass2::UuidNamePair> KeePass2::KDFS {
|
||||||
|
KeePass2::UuidNamePair(KeePass2::KDF_AES, "AES-KDF"),
|
||||||
|
};
|
||||||
|
|
||||||
|
Kdf* KeePass2::uuidToKdf(const Uuid& uuid) {
|
||||||
|
if (uuid == KDF_AES) {
|
||||||
|
return static_cast<Kdf*>(new AesKdf());
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Uuid KeePass2::kdfToUuid(const Kdf& kdf)
|
||||||
|
{
|
||||||
|
switch (kdf.type()) {
|
||||||
|
case Kdf::Type::AES:
|
||||||
|
return KDF_AES;
|
||||||
|
default:
|
||||||
|
return Uuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KeePass2::UuidNamePair::UuidNamePair(const Uuid& uuid, const QString& name)
|
||||||
|
: m_uuid(uuid)
|
||||||
|
, m_name(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Uuid KeePass2::UuidNamePair::uuid() const
|
||||||
|
{
|
||||||
|
return m_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KeePass2::UuidNamePair::name() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
@ -19,7 +19,10 @@
|
|||||||
#define KEEPASSX_KEEPASS2_H
|
#define KEEPASSX_KEEPASS2_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QList>
|
||||||
|
|
||||||
|
#include "crypto/SymmetricCipher.h"
|
||||||
|
#include "crypto/kdf/Kdf.h"
|
||||||
#include "core/Uuid.h"
|
#include "core/Uuid.h"
|
||||||
|
|
||||||
namespace KeePass2
|
namespace KeePass2
|
||||||
@ -32,10 +35,27 @@ namespace KeePass2
|
|||||||
|
|
||||||
const QSysInfo::Endian BYTEORDER = QSysInfo::LittleEndian;
|
const QSysInfo::Endian BYTEORDER = QSysInfo::LittleEndian;
|
||||||
|
|
||||||
const Uuid CIPHER_AES = Uuid(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff"));
|
extern const Uuid CIPHER_AES;
|
||||||
const Uuid CIPHER_TWOFISH = Uuid(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c"));
|
extern const Uuid CIPHER_TWOFISH;
|
||||||
|
|
||||||
const QByteArray INNER_STREAM_SALSA20_IV("\xE8\x30\x09\x4B\x97\x20\x5D\x2A");
|
extern const Uuid KDF_AES;
|
||||||
|
|
||||||
|
extern const QByteArray INNER_STREAM_SALSA20_IV;
|
||||||
|
|
||||||
|
class UuidNamePair
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UuidNamePair(const Uuid& uuid, const QString& name);
|
||||||
|
Uuid uuid() const;
|
||||||
|
QString name() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Uuid m_uuid;
|
||||||
|
QString m_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const QList<UuidNamePair> CIPHERS;
|
||||||
|
extern const QList<UuidNamePair> KDFS;
|
||||||
|
|
||||||
enum HeaderFieldID
|
enum HeaderFieldID
|
||||||
{
|
{
|
||||||
@ -57,6 +77,9 @@ namespace KeePass2
|
|||||||
ArcFourVariant = 1,
|
ArcFourVariant = 1,
|
||||||
Salsa20 = 2
|
Salsa20 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Kdf* uuidToKdf(const Uuid& uuid);
|
||||||
|
Uuid kdfToUuid(const Kdf& kdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // KEEPASSX_KEEPASS2_H
|
#endif // KEEPASSX_KEEPASS2_H
|
||||||
|
Loading…
Reference in New Issue
Block a user