libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
kdbx.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
25#pragma once
26#include <cstdint>
27#include <istream>
28#include <memory>
29#include <ostream>
30#include <string>
31
32#include "database.hh"
34#include "libkeepass/export.hh"
36#include "security.hh"
37
38namespace keepass {
39
40class Key;
41
46private:
48 bool write_kdbx4_ = false;
49
51 bool use_cached_key_ = true;
52
54 KdbxXml xml_;
55
57 void Reset();
58
60
65 std::unique_ptr<Database> Import3(std::istream& src, const Key& key);
66
68
73 std::unique_ptr<Database> Import4(std::istream& src, const Key& key);
74
76
81 void Export3(std::ostream& dst, const Database& db, const Key& key);
82
84
89 void Export4(std::ostream& dst, const Database& db, const Key& key);
90
91public:
93
98 std::unique_ptr<Database> Import(const std::string& path, const Key& key);
99
101
106 std::unique_ptr<Database> Import(std::istream& src, const Key& key);
107
109
114 void Export(const std::string& path, const Database& db, const Key& key);
115
117
122 void Export(std::ostream& dst, const Database& db, const Key& key);
123
125 void set_write_kdbx4(bool write_kdbx4) { write_kdbx4_ = write_kdbx4; }
126
134 void set_use_cached_key(bool use_cached_key) { use_cached_key_ = use_cached_key; }
135
137 bool use_cached_key() const { return use_cached_key_; }
138
141};
142
143} // namespace keepass
Represents a KeePass (KDB/KDBX) database.
Definition database.hh:74
Keepass2 database file representation.
Definition kdbx.hh:45
void set_use_cached_key(bool use_cached_key)
Definition kdbx.hh:134
std::unique_ptr< Database > Import(const std::string &path, const Key &key)
Imports a KDBX database from a file path.
void set_resource_limits(const detail::ResourceLimits &limits)
std::unique_ptr< Database > Import(std::istream &src, const Key &key)
Imports a KDBX database from an input stream.
void set_write_kdbx4(bool write_kdbx4)
Definition kdbx.hh:125
void Export(std::ostream &dst, const Database &db, const Key &key)
Exports a database to an output stream in KDBX format.
bool use_cached_key() const
Definition kdbx.hh:137
void Export(const std::string &path, const Database &db, const Key &key)
Exports a database to a KDBX file.
Parses and serializes the KDBX XML body.
Definition kdbx_xml.hh:66
Manages database encryption keys for KDB and KDBX formats.
Definition key.hh:45
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
KDBX XML body parser and serializer.
Resource budgets enforced while importing (and parsing) databases.
Wrapper type for protecting sensitive KeePass field values.
Configurable resource budgets for database import and XML parsing.
Definition limits.hh:45