8#ifndef SRC_GPGIDSIGNER_H_
9#define SRC_GPGIDSIGNER_H_
48 std::function<int(
const QString &app,
const QStringList &args,
49 const QString &input, QString *out, QString *err)>;
63 GpgIdSigner(QString gpgExecutable, QStringList signingKeys,
84 static auto keysFromSetting(
const QString &passSigningKey) -> QStringList;
154 auto
sign(const QString &gpgIdFile, const QByteArray &contents,
155 QString *error =
nullptr) const ->
bool;
170 auto
verify(const QByteArray &contents, const QString &signatureFile) const
181 auto
verifyFile(const QString &gpgIdFile, QByteArray *contents) const ->
bool;
207 auto
heldByOneKey(const QString &signingFingerprint) const ->
bool;
225 [[nodiscard]] auto
readOwnFile(const QString &path, qint64 maxBytes) const
226 -> std::optional<QByteArray>;
240 auto
run(const QStringList &args, QString *out =
nullptr,
241 QString *err =
nullptr, const QString &input = QString()) const
static auto validSigFingerprints(const QString &statusOutput) -> QStringList
Pick the fingerprints out of gpg's --status-fd VALIDSIG line.
Exec m_exec
How gpg is run; replaced by a fake in the unit tests.
void setStoreRoot(const QString &root)
The store the lists and signatures this signer reads belong to.
auto enabled() const -> bool
Whether any signing key is configured at all.
auto run(const QStringList &args, QString *out=nullptr, QString *err=nullptr, const QString &input=QString()) const -> int
Run gpg with args through m_exec.
auto sign(const QString &gpgIdFile, const QByteArray &contents, QString *error=nullptr) const -> bool
Write <file>.sig, a detached signature by the first key over contents, the bytes the caller just wrot...
QString m_refusal
See refusal(); set by the last verify().
static auto settingOrExported(const QString &passSigningKey) -> QString
The signing key to use: the setting, or with none set, the PASSWORD_STORE_SIGNING_KEY exported for pa...
GpgIdSigner(QString gpgExecutable, QStringList signingKeys, Exec exec=Exec())
Create a signer.
std::function< int(const QString &app, const QStringList &args, const QString &input, QString *out, QString *err)> Exec
Blocking process runner: Executor::executeBlocking()'s shape.
QStringList m_keys
The configured signing keys. The first one signs; a signature by any of them verifies.
auto refusal() const -> QString
Why the last verify() refused a signature gpg called good, for the user: the signing key held by more...
auto keys() const -> const QStringList &
The keys this signer was given.
auto verifyFile(const QString &gpgIdFile, QByteArray *contents) const -> bool
Read gpgIdFile and verify it against <file>.sig.
static constexpr qint64 kMaxSignatureBytes
Most bytes of a .gpg-id.sig verify() hands to gpg.
auto heldByOneKey(const QString &signingFingerprint) const -> bool
Whether exactly one key block holds the key that made a signature.
QString m_gpg
The gpg executable, as configured.
QString m_storeRoot
See setStoreRoot(); empty when not set.
auto readOwnFile(const QString &path, qint64 maxBytes) const -> std::optional< QByteArray >
Read a list or signature of the store: under m_storeRoot when set (see setStoreRoot()).
static auto keysFromSetting(const QString &passSigningKey) -> QStringList
Split the settings value into keys, upper-cased the way gpg prints fingerprints.
auto verify(const QByteArray &contents, const QString &signatureFile) const -> bool
Check a detached signature against the given bytes: gpg must report a VALIDSIG whose key or primary-k...
auto haveSecretKey() const -> bool
Whether gpg has the secret key that sign() will use, i.e. the first configured key....