@@ -1316,38 +1316,6 @@ void ClientSideEncryption::fetchPublicKeyFromKeyChain(const AccountPtr &account)
1316
1316
job->start ();
1317
1317
}
1318
1318
1319
- bool ClientSideEncryption::checkPublicKeyValidity (const AccountPtr &account) const
1320
- {
1321
- QByteArray data = EncryptionHelper::generateRandom (64 );
1322
-
1323
- Bio publicKeyBio;
1324
- QByteArray publicKeyPem = account->e2e ()->getPublicKey ().toPem ();
1325
- BIO_write (publicKeyBio, publicKeyPem.constData (), publicKeyPem.size ());
1326
- auto publicKey = PKey::readPublicKey (publicKeyBio);
1327
-
1328
- auto encryptedData = EncryptionHelper::encryptStringAsymmetric (account->e2e ()->getCertificateInformation (), account->e2e ()->paddingMode (), *account->e2e (), data);
1329
- if (!encryptedData) {
1330
- qCWarning (lcCse ()) << " encryption error" ;
1331
- return false ;
1332
- }
1333
-
1334
- auto key = _encryptionCertificate.getEvpPrivateKey ();
1335
-
1336
- const auto decryptionResult = EncryptionHelper::decryptStringAsymmetric (account->e2e ()->getCertificateInformation (), account->e2e ()->paddingMode (), *account->e2e (), *encryptedData);
1337
- if (!decryptionResult) {
1338
- qCWarning (lcCse ()) << " encryption error" ;
1339
- return false ;
1340
- }
1341
- const auto decryptResult = QByteArray::fromBase64 (*decryptionResult);
1342
-
1343
- if (data != decryptResult) {
1344
- qCInfo (lcCse ()) << " invalid private key" ;
1345
- return false ;
1346
- }
1347
-
1348
- return true ;
1349
- }
1350
-
1351
1319
bool ClientSideEncryption::checkEncryptionIsWorking () const
1352
1320
{
1353
1321
qCInfo (lcCse) << " check encryption is working before enabling end-to-end encryption feature" ;
@@ -2296,7 +2264,7 @@ void ClientSideEncryption::decryptPrivateKey(const AccountPtr &account, const QB
2296
2264
}
2297
2265
}
2298
2266
2299
- if (!getPrivateKey ().isNull () && checkPublicKeyValidity (account )) {
2267
+ if (!getPrivateKey ().isNull () && checkEncryptionIsWorking ( )) {
2300
2268
writePrivateKey (account);
2301
2269
writeCertificate (account);
2302
2270
writeMnemonic (account, [] () {});
0 commit comments