53 static constexpr std::size_t kMaxKeyFileBytes = 1024 * 1024;
67 kHashSubKeysOnlyIfCompositeKey
93 bool has_transformed_key_ =
false;
94 SecureBuffer<32> transformed_key_;
110 explicit Key(
const std::string& password);
117 Key(
const std::string& password,
const std::string& keyfile);
127 explicit Key(
const std::vector<uint8_t>& transformed_key);
166 static Key FromBytes(
const std::string& password,
const std::vector<uint8_t>& keyfile);
198 uint64_t memory_bytes, uint32_t parallelism,
Manages database encryption keys for KDB and KDBX formats.
Definition key.hh:45
Key(const std::vector< uint8_t > &transformed_key)
Constructs a key from a pre-derived transformed master key.
Key(const std::string &password)
Constructs a key with the given password.
static Key FromBytes(const std::string &password, const std::vector< uint8_t > &keyfile)
Creates a composite key from a password and an in-memory key file.
void SetKeyFile(const std::string &path)
Loads a key file and derives the key file component from it.
Key & operator=(const Key &other)
Copy-assigns, allocating wiped copies of all sub keys.
static Key FromStream(const std::string &password, std::istream &keyfile)
Creates a composite key from a password and a key-file stream.
SecureBuffer< 32 > TransformArgon2(Kdf kdf, const SecureBytes &salt, uint64_t iterations, uint64_t memory_bytes, uint32_t parallelism, uint32_t argon2_version, SubKeyResolution resolution) const
Derives the composite key using Argon2 for KDBX 4 databases.
Key(const std::string &password, const std::string &keyfile)
Constructs a composite key from a password and a key file.
void SetPassword(const std::string &password)
Sets the password used to derive the encryption key.
void SetKeyFile(std::istream &src)
Loads a key file from an in-memory stream.
Key(const Key &other)
Copy-constructs, allocating wiped copies of all sub keys.
SecureBuffer< 32 > Transform(const SecureBuffer< 32 > &seed, uint64_t rounds, SubKeyResolution resolution) const
Derives the composite key using AES-KDF for KDBX 3 databases.
Key()=default
Default constructor. Creates an empty key with no password or key file.
void SetKeyFileData(const uint8_t *data, std::size_t size)
Loads a key file from an in-memory byte range.
SubKeyResolution
Definition key.hh:59
Fixed-size byte buffer that is zeroized on destruction.
Definition secure.hh:79
Dynamic byte buffer that is zeroized in best-effort locked memory.
Definition secure.hh:164
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
Secure memory handling: zeroization, locked allocations and sensitive value containers.