8#ifndef SRC_GPGIDSIGNER_H_
9#define SRC_GPGIDSIGNER_H_
42 std::function<int(
const QString &app,
const QStringList &args,
43 const QString &input, QString *out, QString *err)>;
57 GpgIdSigner(QString gpgExecutable, QStringList signingKeys,
66 static auto keysFromSetting(
const QString &passSigningKey) -> QStringList;
78 auto keys() const -> const QStringList & {
return m_keys; }
112 auto
sign(const QString &gpgIdFile, const QByteArray &contents,
113 QString *error =
nullptr) const ->
bool;
128 auto
verify(const QByteArray &contents, const QString &signatureFile) const
139 auto
verifyFile(const QString &gpgIdFile, QByteArray *contents) const ->
bool;
169 auto
run(const QStringList &args, QString *out =
nullptr,
170 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.
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...
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 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.
QString m_gpg
The gpg executable, as configured.
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.