diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 94b75477c5aa6..bd7e8cb54759f 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -723,33 +723,33 @@ QByteArray encryptStringAsymmetric(EVP_PKEY *publicKey, const QByteArray& data) auto ctx = PKeyCtx::forKey(publicKey, ENGINE_get_default_RSA()); if (!ctx) { qCInfo(lcCse()) << "Could not initialize the pkey context."; - exit(1); + return {}; } if (EVP_PKEY_encrypt_init(ctx) != 1) { qCInfo(lcCse()) << "Error initilaizing the encryption."; - exit(1); + return {}; } if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_OAEP_PADDING) <= 0) { qCInfo(lcCse()) << "Error setting the encryption padding."; - exit(1); + return {}; } if (EVP_PKEY_CTX_set_rsa_oaep_md(ctx, EVP_sha256()) <= 0) { qCInfo(lcCse()) << "Error setting OAEP SHA 256"; - exit(1); + return {}; } if (EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, EVP_sha256()) <= 0) { qCInfo(lcCse()) << "Error setting MGF1 padding"; - exit(1); + return {}; } size_t outLen = 0; if (EVP_PKEY_encrypt(ctx, nullptr, &outLen, (unsigned char *)data.constData(), data.size()) != 1) { qCInfo(lcCse()) << "Error retrieving the size of the encrypted data"; - exit(1); + return {}; } else { qCInfo(lcCse()) << "Encryption Length:" << outLen; } @@ -757,7 +757,7 @@ QByteArray encryptStringAsymmetric(EVP_PKEY *publicKey, const QByteArray& data) QByteArray out(outLen, '\0'); if (EVP_PKEY_encrypt(ctx, unsignedData(out), &outLen, (unsigned char *)data.constData(), data.size()) != 1) { qCInfo(lcCse()) << "Could not encrypt key." << err; - exit(1); + return {}; } // Transform the encrypted data into base64. @@ -1399,7 +1399,8 @@ QByteArray FolderMetadata::encryptedMetadata() { * Now we should be compatible with Android and IOS. Maybe we can fix it later. */ const QByteArray encryptedKey = encryptMetadataKey(it.value().toBase64()); - metadataKeys.insert(QString::number(it.key()), QString(encryptedKey)); + if (!encryptedKey.isEmpty()) + metadataKeys.insert(QString::number(it.key()), QString(encryptedKey)); } /* NO SHARING IN V1