qt: Fix validity for (sub)keys generated using QGpgMEQuickJob

* lang/qt/src/qgpgmequickjob.cpp: Fix expiration calculation
--

The job calculates the validity as the seconds since epoch,
while GPG expects the seconds since the current time.
This leads to the validity being significantly longer than expected.

GnuPG-Bug-Id: 6889
This commit is contained in:
Tobias Fella 2023-12-13 15:55:55 +01:00
parent 6baccdc0c3
commit e18c09cbc4
No known key found for this signature in database
GPG Key ID: F315CBBEE5E1889B

View File

@ -64,7 +64,8 @@ static QGpgMEQuickJob::result_type createWorker(GpgME::Context *ctx,
auto err = ctx->createKey(uid.toUtf8().constData(), auto err = ctx->createKey(uid.toUtf8().constData(),
algo, algo,
0, 0,
expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000) : 0, expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000
- QDateTime::currentSecsSinceEpoch()) : 0,
key, key,
flags); flags);
return std::make_tuple(err, QString(), Error()); return std::make_tuple(err, QString(), Error());
@ -77,7 +78,8 @@ static QGpgMEQuickJob::result_type addSubkeyWorker(GpgME::Context *ctx,
unsigned int flags) unsigned int flags)
{ {
auto err = ctx->createSubkey(key, algo, 0, auto err = ctx->createSubkey(key, algo, 0,
expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000): 0, expires.isValid() ? (unsigned long) (expires.toMSecsSinceEpoch() / 1000
- QDateTime::currentSecsSinceEpoch()): 0,
flags); flags);
return std::make_tuple(err, QString(), Error()); return std::make_tuple(err, QString(), Error());
} }