From a4b8bf0be60b52ce8ae85d3d4fa2cf5e67e1a8f8 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 16 Oct 2017 15:33:10 -0700 Subject: [PATCH] Bugfixes and CR --- .../src/entities/EntityServer.cpp | 1 + assignment-client/src/entities/EntityServer.h | 4 ++-- .../resources/describe-settings.json | 4 ++-- interface/src/commerce/Wallet.cpp | 2 +- libraries/entities/src/EntityTree.cpp | 21 +++++++++++++------ libraries/entities/src/EntityTree.h | 1 - 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/assignment-client/src/entities/EntityServer.cpp b/assignment-client/src/entities/EntityServer.cpp index d2585aae49..d99187adee 100644 --- a/assignment-client/src/entities/EntityServer.cpp +++ b/assignment-client/src/entities/EntityServer.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "AssignmentParentFinder.h" #include "EntityNodeData.h" diff --git a/assignment-client/src/entities/EntityServer.h b/assignment-client/src/entities/EntityServer.h index 408fad4494..bcfeb3485d 100644 --- a/assignment-client/src/entities/EntityServer.h +++ b/assignment-client/src/entities/EntityServer.h @@ -84,9 +84,9 @@ private: QMap> _viewerSendingStats; static const int DEFAULT_MINIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS = 45 * 60 * 1000; // 45m - static const int DEFAULT_MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS = 75 * 60 * 1000; // 1h15m + static const int DEFAULT_MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS = 60 * 60 * 1000; // 1h int _MINIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS = DEFAULT_MINIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS; // 45m - int _MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS = DEFAULT_MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS; // 1h15m + int _MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS = DEFAULT_MAXIMUM_DYNAMIC_DOMAIN_VERIFICATION_TIMER_MS; // 1h QTimer _dynamicDomainVerificationTimer; void startDynamicDomainVerification(); }; diff --git a/domain-server/resources/describe-settings.json b/domain-server/resources/describe-settings.json index 2b0d032e3c..d8c91f4ce3 100644 --- a/domain-server/resources/describe-settings.json +++ b/domain-server/resources/describe-settings.json @@ -1266,8 +1266,8 @@ "name": "dynamicDomainVerificationTimeMax", "label": "Dynamic Domain Verification Time (seconds) - Maximum", "help": "The upper limit on the amount of time that passes before Dynamic Domain Verification on entities occurs. Units are seconds.", - "placeholder": "4500", - "default": "4500", + "placeholder": "3600", + "default": "3600", "advanced": true }, { diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index f7cd0e5919..c7c09d8b03 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -741,7 +741,7 @@ void Wallet::handleChallengeOwnershipPacket(QSharedPointer pack if (decryptionStatus != -1) { auto nodeList = DependencyManager::get(); - QByteArray decryptedTextByteArray = QByteArray(reinterpret_cast(decryptedText), decryptionStatus); + QByteArray decryptedTextByteArray = QByteArray(reinterpret_cast(decryptedText), decryptionStatus); int decryptedTextByteArraySize = decryptedTextByteArray.size(); int certIDSize = certID.size(); // setup the packet diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 6ccff83fb4..57b4c9acc1 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -1159,18 +1160,23 @@ void EntityTree::startPendingTransferStatusTimer(const QString& certID, const En } QByteArray EntityTree::computeEncryptedNonce(const QString& certID, const QString ownerKey) { - QUuid nonce = QUuid::createUuid(); - const auto text = reinterpret_cast(qPrintable(nonce.toString())); - const unsigned int textLength = nonce.toString().length(); - QString ownerKeyWithHeaders = ("-----BEGIN RSA PUBLIC KEY-----\n" + ownerKey + "\n-----END RSA PUBLIC KEY-----"); BIO* bio = BIO_new_mem_buf((void*)ownerKeyWithHeaders.toUtf8().constData(), -1); BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); // NO NEWLINE RSA* rsa = PEM_read_bio_RSAPublicKey(bio, NULL, NULL, NULL); if (rsa) { + QUuid nonce = QUuid::createUuid(); + const unsigned int textLength = nonce.toString().length(); QByteArray encryptedText(RSA_size(rsa), 0); - const int encryptStatus = RSA_public_encrypt(textLength, text, reinterpret_cast(encryptedText.data()), rsa, RSA_PKCS1_OAEP_PADDING); + const int encryptStatus = RSA_public_encrypt(textLength, + reinterpret_cast(qPrintable(nonce.toString())), + reinterpret_cast(encryptedText.data()), + rsa, + RSA_PKCS1_OAEP_PADDING); + if (bio) { + BIO_free(bio); + } RSA_free(rsa); if (encryptStatus == -1) { long error = ERR_get_error(); @@ -1181,10 +1187,13 @@ QByteArray EntityTree::computeEncryptedNonce(const QString& certID, const QStrin QWriteLocker locker(&_certNonceMapLock); _certNonceMap.insert(certID, nonce); - qCDebug(entities) << "Challenging ownership of Cert ID" << certID << "by encrypting and sending nonce" << nonce << "to owner."; + return encryptedText; } else { + if (bio) { + BIO_free(bio); + } return ""; } } diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 8d939159ce..d6539babe7 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include