From: Matthieu Gallien Date: Fri, 30 Jun 2023 08:36:57 +0000 (+0200) Subject: fix review comments X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~92^2^2~115^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=10cac0f46f9e9b7b4a150357341e5202c94ed3aa;p=nextcloud-desktop.git fix review comments Signed-off-by: Matthieu Gallien --- diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 8c6f7ba74..c1732e13f 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -1314,8 +1314,7 @@ void ClientSideEncryption::generateKeyPair(const AccountPtr &account) return; } - const auto key = BIO2ByteArray(privKey); - _privateKey = key; + _privateKey = BIO2ByteArray(privKey); } Bio privKey; @@ -1325,13 +1324,11 @@ void ClientSideEncryption::generateKeyPair(const AccountPtr &account) return; } - auto privateKey = PKey::readPrivateKey(privKey); - qCDebug(lcCse()) << "Key correctly generated"; - auto csrOutput = generateCSR(account, std::move(localKeyPair), std::move(privateKey)); - writeMnemonic(account, [account, keyPair = std::move(csrOutput.second), output = std::move(csrOutput.first), this]() mutable -> void { - writeKeyPair(account, std::move(keyPair), output); + auto csrContent = generateCSR(account, std::move(localKeyPair), PKey::readPrivateKey(privKey)); + writeMnemonic(account, [account, keyPair = std::move(csrContent.second), csrContent = std::move(csrContent.first), this]() mutable -> void { + writeKeyPair(account, std::move(keyPair), csrContent); }); } @@ -1356,7 +1353,7 @@ std::pair ClientSideEncryption::generate int nVersion = 1; // 2. set version of x509 req - X509_REQ *x509_req = X509_REQ_new(); + auto x509_req = X509_REQ_new(); auto release_on_exit_x509_req = qScopeGuard([&] { X509_REQ_free(x509_req); }); @@ -1406,7 +1403,7 @@ std::pair ClientSideEncryption::generate void ClientSideEncryption::sendSignRequestCSR(const AccountPtr &account, PKey keyPair, - QByteArray csrContent) + const QByteArray &csrContent) { auto job = new SignPublicKeyApiJob(account, e2eeBaseUrl() + "public-key", this); job->setCsr(csrContent); @@ -1441,7 +1438,7 @@ void ClientSideEncryption::sendSignRequestCSR(const AccountPtr &account, void ClientSideEncryption::writeKeyPair(const AccountPtr &account, PKey keyPair, - QByteArray output) + const QByteArray &csrContent) { const auto privateKeyKeychainId = AbstractCredentials::keychainKey( account->url().toString(), @@ -1467,7 +1464,7 @@ void ClientSideEncryption::writeKeyPair(const AccountPtr &account, privateKeyJob->setInsecureFallback(false); privateKeyJob->setKey(privateKeyKeychainId); privateKeyJob->setBinaryData(bytearrayPrivateKey); - connect(privateKeyJob, &WritePasswordJob::finished, [keyPair = std::move(keyPair), publicKeyKeychainId, account, output, this] (Job *incoming) mutable { + connect(privateKeyJob, &WritePasswordJob::finished, [keyPair = std::move(keyPair), publicKeyKeychainId, account, csrContent, this] (Job *incoming) mutable { if (incoming->error() != Error::NoError) { failedToInitialize(account); return; @@ -1486,13 +1483,13 @@ void ClientSideEncryption::writeKeyPair(const AccountPtr &account, publicKeyJob->setInsecureFallback(false); publicKeyJob->setKey(publicKeyKeychainId); publicKeyJob->setBinaryData(bytearrayPublicKey); - connect(publicKeyJob, &WritePasswordJob::finished, [account, keyPair = std::move(keyPair), output, this](Job *incoming) mutable { + connect(publicKeyJob, &WritePasswordJob::finished, [account, keyPair = std::move(keyPair), csrContent, this](Job *incoming) mutable { if (incoming->error() != Error::NoError) { failedToInitialize(account); return; } - sendSignRequestCSR(account, std::move(keyPair), output); + sendSignRequestCSR(account, std::move(keyPair), csrContent); }); publicKeyJob->start(); }); diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h index e95fc21bb..a4a4c8be4 100644 --- a/src/libsync/clientsideencryption.h +++ b/src/libsync/clientsideencryption.h @@ -175,11 +175,11 @@ private: void sendSignRequestCSR(const AccountPtr &account, PKey keyPair, - QByteArray csrContent); + const QByteArray &csrContent); void writeKeyPair(const AccountPtr &account, PKey keyPair, - QByteArray output); + const QByteArray &csrContent); template void writeMnemonic(OCC::AccountPtr account,