Fix key generation functions.

Created key must always be looked for as it is not assigned to the
passed in null key.
Delete local context and loopback passphrase provider.
Parameter expires was ignored in CreateKeyWithEngineDefaultAlgo.
This commit is contained in:
SET
2020-11-12 22:25:14 +01:00
parent 39afc3ebdc
commit b9b4396b12

View File

@@ -195,7 +195,12 @@ const Error GpgMEWorker::CreateKeyWithEngineDefaultAlgo(GpgME::Key& k,
? 0 : _CREATE_NOEXPIRE;
KeyGenerationResult kgr = ctx->createKeyEx(uid.c_str(), "default",
0, 0, k, flags);
0, expires, k, flags);
delete ppp;
delete ctx;
if (kgr.error().code() == 0)
// Why is k not assigned the newly created key ?!
k = FindKey(kgr.fingerprint(), e, true);
return kgr.error();
}
@@ -222,10 +227,11 @@ const Error GpgMEWorker::CreateKey(GpgME::Key& k,
KeyGenerationResult kgr = ctx->createKeyEx(uid.c_str(), algo,
0, expires, k, flags);
// Why is k not assigned the newly created key ?!
k = FindKey(kgr.fingerprint(), e, true);
delete ppp;
delete ctx;
if (kgr.error().code() == 0)
// Why is k not assigned the newly created key ?!
k = FindKey(kgr.fingerprint(), e, true);
return kgr.error();
}