libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
constants.hh
Go to the documentation of this file.
1/*
2 * libkeepass - KeePass key database importer/exporter
3 * Copyright (C) 2014 Christian Kindahl
4 * Copyright (C) 2024 Dominik Krümpelmann
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
26#pragma once
27#include <array>
28#include <cstdint>
29
30namespace keepass {
31namespace detail {
32
33// ---------------------------------------------------------------------------
34// Signatures and versions
35// ---------------------------------------------------------------------------
36
38constexpr uint32_t kKdbSignature0 = 0x9aa2d903;
40constexpr uint32_t kKdbSignature1 = 0xb54bfb65;
42constexpr uint32_t kKdbxSignature0 = 0x9aa2d903;
44constexpr uint32_t kKdbxSignature1 = 0xb54bfb67;
45
47constexpr uint32_t kKdbxVersion3 = 0x00030000;
49constexpr uint32_t kKdbxVersionCriticalMin = 0x00030001;
51constexpr uint32_t kKdbxVersion4 = 0x00040000;
53constexpr uint32_t kKdbxVersion4_1 = 0x00040001;
55constexpr uint32_t kKdbxVersionCriticalMask = 0xffff0000;
56
57// ---------------------------------------------------------------------------
58// Cipher UUIDs (KDBX header)
59// ---------------------------------------------------------------------------
60
61constexpr std::array<uint8_t, 16> kKdbxCipherAes = {{0x31, 0xc1, 0xf2, 0xe6, 0xbf, 0x71, 0x43, 0x50,
62 0xbe, 0x58, 0x05, 0x21, 0x6a, 0xfc, 0x5a,
63 0xff}};
64constexpr std::array<uint8_t, 16> kKdbxCipherChaCha20 = {{0xd6, 0x03, 0x8a, 0x2b, 0x8b, 0x6f, 0x4c,
65 0xb5, 0xa5, 0x24, 0x33, 0x9a, 0x31, 0xdb,
66 0xb5, 0x9a}};
67constexpr std::array<uint8_t, 16> kKdbxCipherTwofish = {{0xad, 0x68, 0xf2, 0x9f, 0x57, 0x6f, 0x4b,
68 0xb9, 0xa3, 0x6a, 0xd4, 0x7a, 0xf9, 0x65,
69 0x34, 0x6c}};
70
71// ---------------------------------------------------------------------------
72// KDF UUIDs (KDBX 4 variant dictionary)
73// ---------------------------------------------------------------------------
74
75constexpr std::array<uint8_t, 16> kKdbxKdfAesKdbx4 = {{0x7c, 0x02, 0xbb, 0x82, 0x79, 0xa7, 0x4a,
76 0xc0, 0x92, 0x7d, 0x11, 0x4a, 0x00, 0x64,
77 0x82, 0x38}};
78constexpr std::array<uint8_t, 16> kKdbxKdfAesKdbx3 = {{0xc9, 0xd9, 0xf3, 0x9a, 0x62, 0x8a, 0x44,
79 0x60, 0xbf, 0x74, 0x0d, 0x08, 0xc1, 0x8a,
80 0x4f, 0xea}};
81constexpr std::array<uint8_t, 16> kKdbxKdfArgon2d = {{0xef, 0x63, 0x6d, 0xdf, 0x8c, 0x29, 0x44,
82 0x4b, 0x91, 0xf7, 0xa9, 0xa4, 0x03, 0xe3,
83 0x0a, 0x0c}};
84constexpr std::array<uint8_t, 16> kKdbxKdfArgon2id = {{0x9e, 0x29, 0x8b, 0x19, 0x56, 0xdb, 0x47,
85 0x73, 0xb2, 0x3d, 0xfc, 0x3e, 0xc6, 0xf0,
86 0xa1, 0xe6}};
87
88// ---------------------------------------------------------------------------
89// Framing constants
90// ---------------------------------------------------------------------------
91
93constexpr std::array<uint8_t, 8> kKdbxInnerRandomStreamInitVec = {
94 {0xe8, 0x30, 0x09, 0x4b, 0x97, 0x20, 0x5d, 0x2a}};
95
97constexpr uint32_t kMaxOuterHeaderFieldSize = 1U << 20;
98
99} // namespace detail
100} // namespace keepass
constexpr uint32_t kKdbxVersion4_1
KDBX 4.1 critical version.
Definition constants.hh:53
constexpr std::array< uint8_t, 8 > kKdbxInnerRandomStreamInitVec
Fixed Salsa20 IV used by the KDBX inner random stream.
Definition constants.hh:93
constexpr uint32_t kKdbxVersion4
KDBX 4.0 critical version.
Definition constants.hh:51
constexpr uint32_t kKdbxSignature1
Second signature word identifying a KDBX database.
Definition constants.hh:44
constexpr uint32_t kKdbSignature1
Second signature word identifying a legacy KDB database.
Definition constants.hh:40
constexpr uint32_t kKdbxSignature0
First signature word of a KDBX database (same as KDB).
Definition constants.hh:42
constexpr uint32_t kKdbSignature0
First signature word shared by KDB and KDBX.
Definition constants.hh:38
constexpr uint32_t kMaxOuterHeaderFieldSize
Upper bound for a single outer KDBX header field (1 MiB).
Definition constants.hh:97
constexpr uint32_t kKdbxVersion3
Lowest KDBX 3 version accepted/written.
Definition constants.hh:47
constexpr uint32_t kKdbxVersionCriticalMask
Mask selecting the critical (major) part of a KDBX version field.
Definition constants.hh:55
constexpr uint32_t kKdbxVersionCriticalMin
Lowest KDBX 3 critical version (3.1).
Definition constants.hh:49