|
libkeepass 0.2.0
KeePass key database importer/exporter library
|
Parses and serializes the outer header of a KDBX database. More...
#include <kdbx_header.hh>
Static Public Member Functions | |
| 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. | |
| static std::array< uint8_t, 32 > | Parse3 (std::istream &src, Database &db) |
| Parses the KDBX 3 outer header fields into db. | |
| static void | Parse4 (std::istream &src, Database &db) |
| Parses the KDBX 4 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 Public Attributes | |
| static constexpr uint32_t | kSignature0 = detail::kKdbxSignature0 |
| First magic value identifying a KDBX database. | |
| static constexpr uint32_t | kSignature1 = detail::kKdbxSignature1 |
| Second magic value identifying a KDBX database. | |
| static constexpr uint32_t | kVersionCriticalMask = detail::kKdbxVersionCriticalMask |
| Mask selecting the critical (major) part of the version field. | |
| static constexpr uint32_t | kVersion3 = detail::kKdbxVersion3 |
| KDBX 3 critical version. | |
| static constexpr uint32_t | kVersion4 = detail::kKdbxVersion4 |
| KDBX 4 critical version. | |
Parses and serializes the outer header of a KDBX database.
The outer header of a KDBX 3 and a KDBX 4 database differs in the field layout (16-bit vs. 32-bit field sizes, different field IDs) and in the stored parameters (KDBX 4 carries a KDF variant dictionary). This class hides those differences behind a version-dispatched interface; all state is kept in the Database that the header describes.
All operations are static: the class carries no per-instance state.
|
static |
Parses the KDBX 3 outer header fields into db.
Reads and validates every header field of a KDBX 3 database and populates the corresponding settings (cipher, compression, seeds, init vector, inner random stream) on db.
| src | The input stream positioned after the signature/version prefix. |
| db | The database to populate with the parsed header settings. |
| FormatError | If a header field is malformed or unknown. |
Parses the KDBX 4 outer header fields into db.
Reads and validates every header field of a KDBX 4 database, including the KDF variant dictionary, and populates the corresponding settings on db.
| src | The input stream positioned after the signature/version prefix. |
| db | The database to populate with the parsed header settings. |
| FormatError | If a header field is malformed or unknown. |
Reads the file signatures and version prefix of a KDBX database.
Verifies the two magic values and returns the raw version field of the database. The caller dispatches on the critical version bits.
| src | The input stream positioned at the start of the database. |
| FormatError | If the stream does not start with a KDBX signature. |
|
static |
Serializes a KDBX 3 outer header.
| db | The database whose settings to serialize. |
| content_start_bytes | The 32 randomly chosen content stream start bytes that KdbxFile embeds in the header. |
Serializes a KDBX 4 (or 4.1) outer header.
| db | The database whose settings to serialize. |
| kdbx41 | True to write the KDBX 4.1 critical version (0x00040001). |