|
libkeepass 0.2.0
KeePass key database importer/exporter library
|
High-level entry point for opening and saving KeePass databases. More...
#include <keepass.hh>
Public Types | |
| enum class | Format { kAuto , kKdb , kKdbx3 , kKdbx4 } |
| Database formats supported for reading and writing. More... | |
Public Member Functions | |
| KeePass () | |
| Constructs an importer/exporter with an empty key. | |
| KeePass (const Key &key) | |
| Constructs an importer/exporter with the given key. | |
| KeePass (const std::string &password, const std::string &keyfile="") | |
| Constructs an importer/exporter from a password and optional key file. | |
| std::unique_ptr< Database > | Open (const std::string &path) |
| Opens a KeePass (KDB or KDBX) database file. | |
| std::unique_ptr< Database > | Open (std::istream &src) |
| Opens a KeePass database from a stream with format auto-detection. | |
| std::unique_ptr< Database > | Open (const uint8_t *data, std::size_t size) |
| Opens a KeePass database from an in-memory byte range. | |
| std::unique_ptr< Database > | Open (const std::vector< uint8_t > &data) |
| Opens a KeePass database from an in-memory byte vector. | |
| void | Save (const std::string &path, const Database &db) |
| Saves a database to a file. | |
| void | Save (std::ostream &dst, const Database &db) |
| Saves a database to a stream. | |
| void | Save (std::ostream &dst, const Database &db, const Key &key) |
| Saves a database to a stream using a new key. | |
| void | SaveAs (const std::string &path, const Database &db, const Key &new_key) |
| Saves a database to a file using a new key. | |
| void | SaveAs (std::ostream &dst, const Database &db, const Key &new_key) |
| Saves a database to a stream using a new key. | |
| void | SaveAs (const std::string &path, const Database &db, const std::string &password, const std::string &keyfile="") |
| Saves a database to a file using a new password and optional key file. | |
| void | SaveAs (std::ostream &dst, const Database &db, const std::string &password, const std::string &keyfile="") |
| Saves a database to a stream using a new password and optional key file. | |
| void | SetFormat (Format format) |
| Selects the output format. | |
| Format | GetFormat () const |
| Returns the configured output format. | |
Static Public Member Functions | |
| static std::unique_ptr< Database > | Create (const std::string &password="", Format format=Format::kKdbx4, Database::Cipher cipher=Database::Cipher::kAes, Database::Kdf kdf=Database::Kdf::kArgon2id) |
| Creates a new empty database with generated cryptographic material. | |
High-level entry point for opening and saving KeePass databases.
KeePass unifies the KDB and KDBX importers/exporters behind a single interface. The format is auto-detected on input; on output it can either be selected explicitly via SetFormat or derived from the database content and the target file extension.
|
strong |
Constructs an importer/exporter with the given key.
| key | The key used to decrypt and encrypt databases. |
Constructs an importer/exporter from a password and optional key file.
| password | The database password. |
| keyfile | Path to a key file, or an empty string for none. |
|
static |
Creates a new empty database with generated cryptographic material.
When password is non-empty and format is not KDB, the transformed key is derived immediately and cached on the returned Database. A later KDBX Save then works with an empty KeePass key (or use SaveAs with a new key to re-encrypt). KDB (1.x) export still requires an explicit key because the legacy format derives its key with different parameters.
| password | Password to derive and cache the transformed key for. |
| format | Preferred output format of the new database. |
| cipher | Payload cipher to use. |
| kdf | Key derivation function to use. |
Opens a KeePass database from an in-memory byte range.
The bytes are copied into a seekable stream; no reference is retained after the call. This is a convenience overload for callers that already hold the database in memory (for example after a network transfer).
| data | Pointer to the database bytes. |
| size | Number of bytes in data. |
| std::unique_ptr< Database > keepass::KeePass::Open | ( | std::istream & | src | ) |
Opens a KeePass database from a stream with format auto-detection.
Seekable streams are read directly (only the 8-byte format signature is inspected up front); non-seekable streams are buffered in memory.
| src | The input stream containing the database. |
Saves a database to a file.
The output format is taken from SetFormat if set, otherwise derived from the file extension and the database content.
| path | Path to the output file. |
| db | The database to save. |
Saves a database to a stream.
The output format is taken from SetFormat if set, otherwise a KDBX format is chosen based on the database KDF and cipher.
| dst | The output stream. |
| db | The database to save. |
Saves a database to a stream using a new key.
The key is used only for this save and key_ is restored afterwards. The output format is taken from SetFormat if set, otherwise a KDBX format is chosen based on the database KDF and cipher. KDB cannot be selected for stream output because there is no file extension.
| dst | The output stream. |
| db | The database to save. |
| key | The key to encrypt the database with. |
| void keepass::KeePass::SaveAs | ( | const std::string & | path, |
| const Database & | db, | ||
| const Key & | new_key | ||
| ) |
Saves a database to a file using a new key.
The output format is taken from SetFormat if set, otherwise a KDBX format is chosen based on the database KDF and cipher. KDB cannot be selected for stream output because there is no file extension.
| path | Path to the output file. |
| db | The database to save. |
| new_key | The key to encrypt the database with. |
| void keepass::KeePass::SaveAs | ( | const std::string & | path, |
| const Database & | db, | ||
| const std::string & | password, | ||
| const std::string & | keyfile = "" |
||
| ) |
Saves a database to a file using a new password and optional key file.
| path | Path to the output file. |
| db | The database to save. |
| password | The new database password. |
| keyfile | Path to a key file, or an empty string for none. |
Saves a database to a stream using a new key.
The output format is taken from SetFormat if set, otherwise a KDBX format is chosen based on the database KDF and cipher. KDB cannot be selected for stream output because there is no file extension.
| dst | The output stream. |
| db | The database to save. |
| new_key | The key to encrypt the database with. |
| void keepass::KeePass::SaveAs | ( | std::ostream & | dst, |
| const Database & | db, | ||
| const std::string & | password, | ||
| const std::string & | keyfile = "" |
||
| ) |
Saves a database to a stream using a new password and optional key file.
The output format is taken from SetFormat if set, otherwise a KDBX format is chosen based on the database KDF and cipher. KDB cannot be selected for stream output because there is no file extension.
| dst | The output stream. |
| db | The database to save. |
| password | The new database password. |
| keyfile | Path to a key file, or an empty string for none. |