8#ifndef SRC_RNPCRYPTO_H_
9#define SRC_RNPCRYPTO_H_
125 [[nodiscard]]
auto isValid() const ->
bool;
133 auto
importKeys(const QByteArray &keyData, QString *error =
nullptr)
168 auto
encrypt(const QByteArray &plaintext, const QStringList &recipients,
169 QString *error =
nullptr) -> QByteArray;
184 auto
decrypt(const QByteArray &ciphertext, QString *error =
nullptr,
185 bool *ok =
nullptr) -> QByteArray;
192 [[nodiscard]] auto
listKeys(
bool secretOnly = false) const -> QList<
KeyInfo>;
205 auto
sign(const QByteArray &data, const QString &signer,
206 QString *error =
nullptr) -> QByteArray;
223 auto
verify(const QByteArray &data, const QByteArray &signature,
224 QString *error =
nullptr) -> QStringList;
241 auto
protectKey(const QString &fingerprint, const QString &passphrase,
242 QString *error =
nullptr) ->
bool;
268 auto
saveKeyring(const QString &dir,
bool allowUnprotected = false,
269 QString *error =
nullptr) const ->
bool;
283 auto
loadKeyring(const QString &dir, QString *error =
nullptr) ->
bool;
static constexpr qint64 kMaxKeyringBytes
Most bytes of a keyring file: saveKeyring() writes no larger one, loadKeyring() reads no larger one.
auto sign(const QByteArray &data, const QString &signer, QString *error=nullptr) -> QByteArray
Makes a detached signature over data, as gpg –detach-sign –local-user signer does (for ....
void setPassphraseProvider(PassphraseProvider provider)
Sets how secret-key passphrases are obtained.
std::function< QString(const QString &keyId)> PassphraseProvider
Asks for the passphrase of a secret key.
RnpCrypto()
Creates an empty keyring.
auto importKeys(const QByteArray &keyData, QString *error=nullptr) -> QStringList
Imports public and secret keys from armored or binary key data.
qint64 m_maxPlaintext
Largest plaintext decrypt() returns, in bytes.
auto verify(const QByteArray &data, const QByteArray &signature, QString *error=nullptr) -> QStringList
Checks a detached signature over data, as QtPass reads gpg's VALIDSIG.
void setMaxPlaintextBytes(qint64 bytes)
Sets the most bytes of plaintext decrypt() may produce.
rnp_ffi_st * m_ffi
RNP's handle holding this object's keyring; null when RNP could not be initialised,...
auto protectKey(const QString &fingerprint, const QString &passphrase, QString *error=nullptr) -> bool
Protects the secret parts of a key with passphrase.
auto decrypt(const QByteArray &ciphertext, QString *error=nullptr, bool *ok=nullptr) -> QByteArray
Decrypts an OpenPGP message with any secret key in the keyring.
auto listKeys(bool secretOnly=false) const -> QList< KeyInfo >
The primary keys in the keyring.
auto isValid() const -> bool
Whether the RNP context could be created at all.
auto loadKeyring(const QString &dir, QString *error=nullptr) -> bool
Adds the keyring in dir (as saveKeyring() wrote it) to this one. Secret keys stay protected until an ...
auto encrypt(const QByteArray &plaintext, const QStringList &recipients, QString *error=nullptr) -> QByteArray
Encrypts plaintext to every recipient, as one message.
PassphraseProvider m_passphrase
Asked for the passphrase of a locked secret key during decryption; set with setPassphraseProvider(),...
static constexpr qint64 kMaxPlaintextBytes
Most bytes of plaintext decrypt() produces by default.
auto saveKeyring(const QString &dir, bool allowUnprotected=false, QString *error=nullptr) const -> bool
Writes the keyring to dir: keyring.gpg, public and secret keys in one file (OpenPGP keys,...
One primary key in the keyring, as the Users dialog lists keys.
QStringList userIds
Its user IDs that are still its own (valid, not revoked), in the keyring's order.
QDateTime expires
When it expires; invalid when it does not.
bool canSign
Whether it can sign now, with a secret key that is here.
bool canEncrypt
Whether a message can be encrypted to it now.
bool secretProtected
Whether every secret part of it that is here is protected by a passphrase; true when none is here.
bool expired
Whether it has expired.
QString fingerprint
The primary key's fingerprint, upper-case hex.
QString keyId
The primary key's 16-hex-digit key ID.
QDateTime created
When it was created.
bool hasSecret
Whether a secret part of it (primary or subkey) is here to use: a GnuPG stub (a key left at home,...
bool revoked
Whether it has been revoked.