@@ -237,7 +237,32 @@ QByteArray deprecatedGeneratePassword(const QString& wordlist, const QByteArray&
237
237
(const unsigned char *)salt.constData (),// const unsigned char *salt,
238
238
salt.size (), // int saltlen,
239
239
iterationCount, // int iterations,
240
- EVP_sha1 (), // digest algorithm
240
+ EVP_sha1 (), // deprecated digest algorithm
241
+ keyLength, // int keylen,
242
+ unsignedData (secretKey)); // unsigned char *out
243
+
244
+ if (ret != 1 ) {
245
+ qCWarning (lcCse ()) << " Failed to generate encryption key" ;
246
+ // Error out?
247
+ }
248
+
249
+ return secretKey;
250
+ }
251
+
252
+ QByteArray deprecatedSha1GeneratePassword (const QString& wordlist, const QByteArray& salt)
253
+ {
254
+ const auto iterationCount = 600000 ;
255
+ const auto keyStrength = 256 ;
256
+ const auto keyLength = keyStrength / 8 ;
257
+
258
+ QByteArray secretKey (keyLength, ' \0 ' );
259
+
260
+ const auto ret = PKCS5_PBKDF2_HMAC (wordlist.toLocal8Bit ().constData (), // const char *password,
261
+ wordlist.size (), // int password length,
262
+ (const unsigned char *)salt.constData (),// const unsigned char *salt,
263
+ salt.size (), // int saltlen,
264
+ iterationCount, // int iterations,
265
+ EVP_sha1 (), // deprecated digest algorithm
241
266
keyLength, // int keylen,
242
267
unsignedData (secretKey)); // unsigned char *out
243
268
@@ -262,7 +287,7 @@ QByteArray generatePassword(const QString& wordlist, const QByteArray& salt)
262
287
(const unsigned char *)salt.constData (),// const unsigned char *salt,
263
288
salt.size (), // int saltlen,
264
289
iterationCount, // int iterations,
265
- EVP_sha1 (), // digest algorithm
290
+ EVP_sha256 (), // digest algorithm
266
291
keyLength, // int keylen,
267
292
unsignedData (secretKey)); // unsigned char *out
268
293
@@ -1419,7 +1444,7 @@ std::pair<QByteArray, PKey> ClientSideEncryption::generateCSR(const AccountPtr &
1419
1444
return {result, std::move (keyPair)};
1420
1445
}
1421
1446
1422
- ret = X509_REQ_sign (x509_req, privateKey, EVP_sha1 ()); // return x509_req->signature->length
1447
+ ret = X509_REQ_sign (x509_req, privateKey, EVP_sha256 ()); // return x509_req->signature->length
1423
1448
if (ret <= 0 ){
1424
1449
qCWarning (lcCse ()) << " Error signing the csr with the private key" ;
1425
1450
return {result, std::move (keyPair)};
@@ -1661,13 +1686,19 @@ void ClientSideEncryption::decryptPrivateKey(const AccountPtr &account, const QB
1661
1686
const auto salt = EncryptionHelper::extractPrivateKeySalt (key);
1662
1687
1663
1688
const auto deprecatedPassword = EncryptionHelper::deprecatedGeneratePassword (mnemonic, salt);
1689
+ const auto deprecatedSha1Password = EncryptionHelper::deprecatedSha1GeneratePassword (mnemonic, salt);
1664
1690
const auto password = EncryptionHelper::generatePassword (mnemonic, salt);
1665
1691
1666
1692
const auto privateKey = EncryptionHelper::decryptPrivateKey (password, key);
1667
1693
if (!privateKey.isEmpty ()) {
1668
1694
_privateKey = privateKey;
1669
1695
} else {
1670
- _privateKey = EncryptionHelper::decryptPrivateKey (deprecatedPassword, key);
1696
+ const auto deprecatedSha1PrivateKey = EncryptionHelper::decryptPrivateKey (deprecatedSha1Password, key);
1697
+ if (!privateKey.isEmpty ()) {
1698
+ _privateKey = deprecatedSha1PrivateKey;
1699
+ } else {
1700
+ _privateKey = EncryptionHelper::decryptPrivateKey (deprecatedPassword, key);
1701
+ }
1671
1702
}
1672
1703
1673
1704
if (!_privateKey.isNull () && checkPublicKeyValidity (account)) {
0 commit comments