File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1207,6 +1207,13 @@ void ClientSideEncryption::initializeHardwareTokenEncryption(const AccountPtr &a
1207
1207
<< " label:" << _tokenPublicKey->label
1208
1208
<< " need login:" << (_tokenPublicKey->needLogin ? " true" : " false" );
1209
1209
1210
+ if (!checkEncryptionIsWorking (account)) {
1211
+ qCWarning (lcCse ()) << " encryption is not properly setup" ;
1212
+
1213
+ failedToInitialize (account);
1214
+ return ;
1215
+ }
1216
+
1210
1217
emit initializationFinished ();
1211
1218
}
1212
1219
@@ -1277,6 +1284,31 @@ bool ClientSideEncryption::checkPublicKeyValidity(const AccountPtr &account) con
1277
1284
return true ;
1278
1285
}
1279
1286
1287
+ bool ClientSideEncryption::checkEncryptionIsWorking (const AccountPtr &account) const
1288
+ {
1289
+ QByteArray data = EncryptionHelper::generateRandom (64 );
1290
+
1291
+ auto encryptedData = EncryptionHelper::encryptStringAsymmetric (*account->e2e (), data);
1292
+ if (!encryptedData) {
1293
+ qCWarning (lcCse ()) << " encryption error" ;
1294
+ return false ;
1295
+ }
1296
+
1297
+ const auto decryptionResult = EncryptionHelper::decryptStringAsymmetric (*account->e2e (), *encryptedData);
1298
+ if (!decryptionResult) {
1299
+ qCWarning (lcCse ()) << " encryption error" ;
1300
+ return false ;
1301
+ }
1302
+ QByteArray decryptResult = QByteArray::fromBase64 (*decryptionResult);
1303
+
1304
+ if (data != decryptResult) {
1305
+ qCInfo (lcCse ()) << " invalid private key" ;
1306
+ return false ;
1307
+ }
1308
+
1309
+ return true ;
1310
+ }
1311
+
1280
1312
bool ClientSideEncryption::checkServerPublicKeyValidity (const QByteArray &serverPublicKeyString) const
1281
1313
{
1282
1314
Bio serverPublicKeyBio;
Original file line number Diff line number Diff line change @@ -238,6 +238,8 @@ private slots:
238
238
[[nodiscard]] bool checkServerPublicKeyValidity (const QByteArray &serverPublicKeyString) const ;
239
239
[[nodiscard]] bool sensitiveDataRemaining () const ;
240
240
241
+ [[nodiscard]] bool checkEncryptionIsWorking (const AccountPtr &account) const ;
242
+
241
243
void failedToInitialize (const AccountPtr &account);
242
244
243
245
QByteArray _privateKey;
You can’t perform that action at this time.
0 commit comments