8#ifndef SRC_GPGIDGENERATION_H_
9#define SRC_GPGIDGENERATION_H_
93 static auto parse(
const QByteArray &contents, QString *error =
nullptr)
94 -> std::optional<Header>;
103 static auto header(qint64 generation,
const QString &folder,
104 const QString &store = {}) -> QByteArray;
114 static auto withHeader(qint64 generation,
const QString &folder,
115 const QByteArray &recipients,
116 const QString &store = {}) -> QByteArray;
129 static auto storeIdFor(
const QString &storeRoot,
130 const std::optional<QString> &onDisk,
131 QString *error =
nullptr) -> std::optional<QString>;
143 static auto folderOf(
const QString &gpgIdFile,
const QString &storeRoot)
144 -> std::optional<QString>;
155 static auto remembered(
const QString &gpgIdFile, QString *error =
nullptr)
156 -> std::optional<qint64>;
212 static auto accept(
const QString &gpgIdFile,
const QByteArray &contents,
213 const QString &storeRoot, QString *error =
nullptr)
238 std::optional<qint64> verifiedOnDisk,
239 QString *error =
nullptr) -> std::optional<qint64>;
254 const QByteArray &contents,
255 QString *error =
nullptr) -> bool;
264 static auto digest(
const QByteArray &contents) -> QString;
273 static auto key(
const QString &gpgIdFile) -> QString;
303 const QString &storeRoot, QString *error)
320 const QString &pinned,
bool alreadyAccepted,
321 const QString &recordPath, QString *error) -> bool;
333 static auto wayThrough(qint64 last,
const QString &recordPath,
334 const QString &saving) -> QString;
348 qint64 last,
const QString &recordPath, QString *error)
Rollback detection for signed .gpg-id files.
static auto accept(const QString &gpgIdFile, const QByteArray &contents, const QString &storeRoot, QString *error=nullptr) -> Verdict
Decide about a verified list: its folder against where it sits, its generation against the remembered...
static auto ofThisStore(const QString &gpgIdFile, const Header &header, const QString &pinned, bool alreadyAccepted, const QString &recordPath, QString *error) -> bool
Whether header fits the store this device knows by pinned: its store line names that id,...
static auto digest(const QByteArray &contents) -> QString
The digest of a list as the record keeps it: SHA-256 of the exact bytes, hexadecimal,...
static auto header(qint64 generation, const QString &folder, const QString &store={}) -> QByteArray
The header lines for a list.
static auto storeRecordFile() -> QString
The file the store IDs are kept in, next to recordFile() and under its lock, so a QtPass from before ...
static auto folderOf(const QString &gpgIdFile, const QString &storeRoot) -> std::optional< QString >
The store-relative folder of gpgIdFile, as written in and compared against the folder line: ....
static auto reserveNext(const QString &gpgIdFile, std::optional< qint64 > verifiedOnDisk, QString *error=nullptr) -> std::optional< qint64 >
Reserve the generation to write next for gpgIdFile: one above both what this device remembers and ver...
static auto boundToItsFolder(const QString &gpgIdFile, const Header &header, const QString &storeRoot, QString *error) -> bool
Whether header's folder line, if it has one, names the folder the list sits in: a pair copied elsewhe...
static auto recordWritten(const QString &gpgIdFile, const QByteArray &contents, QString *error=nullptr) -> bool
Record the bytes just written for gpgIdFile, so that this device recognises its own list afterwards a...
static auto key(const QString &gpgIdFile) -> QString
The settings key for a .gpg-id: a hash of its canonical path, so path spelling (case,...
Verdict
The outcome of accept(). Only Accepted means the list may be used; the others say why not,...
static auto remembered(const QString &gpgIdFile, QString *error=nullptr) -> std::optional< qint64 >
The highest generation this device has accepted or written for the .gpg-id at gpgIdFile....
static auto staleList(const QString &gpgIdFile, const Header &header, qint64 last, const QString &recordPath, QString *error) -> Verdict
The refusal for a list older than the one accepted here: a rollback, or an unbound list that could be...
static const QByteArray kStorePrefix
static const QByteArray kFolderPrefix
static const qint64 kMaxGeneration
static auto withHeader(qint64 generation, const QString &folder, const QByteArray &recipients, const QString &store={}) -> QByteArray
A complete list: the header in front of the recipients.
static auto recordFile() -> QString
The file the accepted generations are recorded in, so a refusal can name it: removing it forgets what...
static const QByteArray kGenerationPrefix
static auto parse(const QByteArray &contents, QString *error=nullptr) -> std::optional< Header >
The header a .gpg-id's bytes declare.
static auto storeIdFor(const QString &storeRoot, const std::optional< QString > &onDisk, QString *error=nullptr) -> std::optional< QString >
The store id to write into a list of storeRoot: the one this device knows the store by; else onDisk,...
static auto wayThrough(qint64 last, const QString &recordPath, const QString &saving) -> QString
How a holder of the signing key gets through a refusal, in words: saving the recipients writes the ne...