Welcome to mirror list, hosted at ThFree Co, Russian Federation.

KeePass2.h « format « src - github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cdc594f5a5d299440a1d17b473424231d1543264 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 /*
 *  Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
 *
 *  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/>.
 */

#ifndef KEEPASSX_KEEPASS2_H
#define KEEPASSX_KEEPASS2_H

#include <QtGlobal>
#include <QMap>
#include <QVariantMap>
#include <QList>

#include "crypto/SymmetricCipher.h"
#include "crypto/kdf/Kdf.h"
#include "core/Uuid.h"

namespace KeePass2
{
    const quint32 SIGNATURE_1 = 0x9AA2D903;
    const quint32 SIGNATURE_2 = 0xB54BFB67;

    const quint32 FILE_VERSION_MIN = 0x00020000;
    const quint32 FILE_VERSION_CRITICAL_MASK = 0xFFFF0000;
    const quint32 FILE_VERSION_4 = 0x00040000;
    const quint32 FILE_VERSION_3 = 0x00030001;

    const quint16 VARIANTMAP_VERSION = 0x0100;
    const quint16 VARIANTMAP_CRITICAL_MASK = 0xFF00;

    const QSysInfo::Endian BYTEORDER = QSysInfo::LittleEndian;

    extern const Uuid CIPHER_AES;
    extern const Uuid CIPHER_TWOFISH;
    extern const Uuid CIPHER_CHACHA20;

    extern const Uuid KDF_AES;
    extern const Uuid KDF_ARGON2;

    extern const QByteArray INNER_STREAM_SALSA20_IV;

    extern const QString KDFPARAM_UUID;
    extern const QString KDFPARAM_AES_ROUNDS;
    extern const QString KDFPARAM_AES_SEED;
    extern const QString KDFPARAM_ARGON2_SALT;
    extern const QString KDFPARAM_ARGON2_PARALLELISM;
    extern const QString KDFPARAM_ARGON2_MEMORY;
    extern const QString KDFPARAM_ARGON2_ITERATIONS;
    extern const QString KDFPARAM_ARGON2_VERSION;
    extern const QString KDFPARAM_ARGON2_SECRET;
    extern const QString KDFPARAM_ARGON2_ASSOCDATA;

    extern const QList<QPair<Uuid, QString>> CIPHERS;
    extern const QList<QPair<Uuid, QString>> KDFS;

    enum HeaderFieldID
    {
        EndOfHeader = 0,
        Comment = 1,
        CipherID = 2,
        CompressionFlags = 3,
        MasterSeed = 4,
        TransformSeed = 5,
        TransformRounds = 6,
        EncryptionIV = 7,
        ProtectedStreamKey = 8,
        StreamStartBytes = 9,
        InnerRandomStreamID = 10,
        KdfParameters = 11,
        PublicCustomData = 12
    };

    enum class InnerHeaderFieldID : quint8
    {
        End = 0,
        InnerRandomStreamID = 1,
        InnerRandomStreamKey = 2,
        Binary = 3
    };

    enum ProtectedStreamAlgo
    {
        ArcFourVariant = 1,
        Salsa20 = 2,
        ChaCha20 = 3,
        InvalidProtectedStreamAlgo = -1
    };

    enum class VariantMapFieldType : quint8
    {
        End = 0,
        // Byte = 0x02,
        // UInt16 = 0x03,
        UInt32 = 0x04,
        UInt64 = 0x05,
        // Signed mask: 0x08
        Bool = 0x08,
        // SByte = 0x0A,
        // Int16 = 0x0B,
        Int32 = 0x0C,
        Int64 = 0x0D,
        // Float = 0x10,
        // Double = 0x11,
        // Decimal = 0x12,
        // Char = 0x17, // 16-bit Unicode character
        String = 0x18,
        // Array mask: 0x40
        ByteArray = 0x42
    };

    QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey);
    QSharedPointer<Kdf> kdfFromParameters(const QVariantMap &p);
    QVariantMap kdfToParameters(QSharedPointer<Kdf> kdf);
    QSharedPointer<Kdf> uuidToKdf(const Uuid& uuid);
    Uuid kdfToUuid(QSharedPointer<Kdf> kdf);
    ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id);
}

#endif // KEEPASSX_KEEPASS2_H