Certify key.

In-place editing with a popup if user is allowed in app config file.
User must of course manage at least a private key. User identities of
target key may be selectively chosen. Optionally, certification may be
exportable and non-revocable.
This commit is contained in:
SET
2020-11-03 11:06:25 +01:00
parent e434315940
commit 7f8af95d3a
23 changed files with 922 additions and 24 deletions

View File

@@ -17,10 +17,12 @@
GpgMEWorker::GpgMEWorker()
{
m_ctx = Context::createForProtocol(Protocol::OpenPGP);
m_ppp = NULL;
}
GpgMEWorker::~GpgMEWorker()
{
delete m_ppp;
delete m_ctx;
}
@@ -89,3 +91,42 @@ const Error GpgMEWorker::EditOwnerTrust(const char* anyFullId, GpgME::Key::Owner
GpgME::Data d; // Internal processing data
return m_ctx->edit(k, std::unique_ptr<SetOwnerTrustEditInteractor> (interactor), d);
}
const Error GpgMEWorker::CertifyKey(const char* fprSigningKey,
const char * fprKeyToSign,
vector<uint>& userIDsToSign, int options,
const string& passphrase)
{
Error e;
Key signingKey = FindKey(fprSigningKey, e, true);
if (e.code() != 0)
return e;
e = m_ctx->addSigningKey(signingKey); // +++
if (e.code() != 0)
return e;
Key keyToSign = FindKey(fprKeyToSign, e, false);
if (e.code() != 0)
return e;
// GPG engine will fetch for passphrase in the custom provider.
m_ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback);
if (m_ppp == NULL)
m_ppp = new LoopbackPassphraseProvider();
m_ppp->SetPassphrase(passphrase);
m_ctx->setPassphraseProvider(m_ppp);
SetSignKeyEditInteractor * interactor = new SetSignKeyEditInteractor();
interactor->setKey(keyToSign);
interactor->setUserIDsToSign(userIDsToSign);
interactor->setSigningOptions(options);
// What's that check level ?
// interactor->setCheckLevel(2);
GpgME::Data d;
e = m_ctx->edit(keyToSign, std::unique_ptr<SetSignKeyEditInteractor> (interactor), d);
m_ctx->clearSigningKeys();
/*
* On error, always : code = 1024 | asString = User defined error code 1
* Can't distinguish between bad password or whatever cause.
*/
return e;
}