libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
kdbx_header.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
32#pragma once
33#include <array>
34#include <cstdint>
35#include <istream>
36#include <string>
37
40#include "libkeepass/export.hh"
41
42namespace keepass {
43
56public:
58 static constexpr uint32_t kSignature0 = detail::kKdbxSignature0;
60 static constexpr uint32_t kSignature1 = detail::kKdbxSignature1;
61
63 static constexpr uint32_t kVersionCriticalMask = detail::kKdbxVersionCriticalMask;
65 static constexpr uint32_t kVersion3 = detail::kKdbxVersion3;
67 static constexpr uint32_t kVersion4 = detail::kKdbxVersion4;
68
70
78 static uint32_t ReadVersion(std::istream& src);
79
81 static bool IsKdbx4(uint32_t version) { return (version & kVersionCriticalMask) == kVersion4; }
82
84
94 static std::array<uint8_t, 32> Parse3(std::istream& src, Database& db);
95
97
105 static void Parse4(std::istream& src, Database& db);
106
108
114 static std::string Write3(const Database& db, const std::array<uint8_t, 32>& content_start_bytes);
115
117
122 static std::string Write4(const Database& db, bool kdbx41);
123};
124
125} // namespace keepass
Represents a KeePass (KDB/KDBX) database.
Definition database.hh:74
Parses and serializes the outer header of a KDBX database.
Definition kdbx_header.hh:55
static std::array< uint8_t, 32 > Parse3(std::istream &src, Database &db)
Parses the KDBX 3 outer header fields into db.
static std::string Write3(const Database &db, const std::array< uint8_t, 32 > &content_start_bytes)
Serializes a KDBX 3 outer header.
static std::string Write4(const Database &db, bool kdbx41)
Serializes a KDBX 4 (or 4.1) outer header.
static uint32_t ReadVersion(std::istream &src)
Reads the file signatures and version prefix of a KDBX database.
static bool IsKdbx4(uint32_t version)
Returns whether version denotes a KDBX 4 database.
Definition kdbx_header.hh:81
static void Parse4(std::istream &src, Database &db)
Parses the KDBX 4 outer header fields into db.
On-disk signatures, version numbers, cipher/KDF UUIDs and framing limits shared by the KDB and KDBX c...
In-memory representation of a KeePass database.
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43