libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
kdf_registry.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
22#pragma once
23
24#include <functional>
25#include <map>
26#include <mutex>
27
28#include "database.hh"
29#include "libkeepass/export.hh"
30#include "libkeepass/key.hh"
31#include "libkeepass/secure.hh"
32
33namespace keepass {
34
43public:
45 using Factory =
46 std::function<SecureBuffer<32>(const Key&, const Database&, Key::SubKeyResolution)>;
47
50
52 void Register(Database::Kdf kdf, Factory factory);
53
56 Key::SubKeyResolution resolution) const;
57
59 bool Contains(Database::Kdf kdf) const;
60
61private:
63
64 mutable std::mutex mutex_;
65 std::map<Database::Kdf, Factory> factories_;
66};
67
68} // namespace keepass
Represents a KeePass (KDB/KDBX) database.
Definition database.hh:74
Kdf
Key derivation functions supported by the importer/exporter.
Definition database.hh:80
Process-wide registry for key-derivation functions.
Definition kdf_registry.hh:42
void Register(Database::Kdf kdf, Factory factory)
Registers/overwrites the factory for a KDF id.
static KdfRegistry & Instance()
Returns the process-wide registry.
bool Contains(Database::Kdf kdf) const
Returns whether a factory is registered for kdf.
std::function< SecureBuffer< 32 >(const Key &, const Database &, Key::SubKeyResolution)> Factory
Derives the transformed 32-byte key.
Definition kdf_registry.hh:46
SecureBuffer< 32 > Transform(Database::Kdf kdf, const Key &key, const Database &db, Key::SubKeyResolution resolution) const
Derives the transformed key, or throws UnsupportedFeatureError.
Manages database encryption keys for KDB and KDBX formats.
Definition key.hh:45
SubKeyResolution
Definition key.hh:59
Fixed-size byte buffer that is zeroized on destruction.
Definition secure.hh:79
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
Database encryption key management for KDB and KDBX formats.
Secure memory handling: zeroization, locked allocations and sensitive value containers.