diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ed43c04d04..7589b85fd3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5758,9 +5758,9 @@ int Application::processOctreeStats(ReceivedMessage& message, SharedNodePointer void Application::packetSent(quint64 length) { } -void Application::addingEntityWithCertificate(const QString& certificateID, const QString& domainID) { +void Application::addingEntityWithCertificate(const QString& certificateID, const QString& placeName) { auto ledger = DependencyManager::get(); - ledger->updateLocation(certificateID, domainID); + ledger->updateLocation(certificateID, placeName); } void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointer scriptEngine) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 84d9eb9feb..bd1de68d71 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -440,7 +440,7 @@ private slots: void nodeActivated(SharedNodePointer node); void nodeKilled(SharedNodePointer node); static void packetSent(quint64 length); - static void addingEntityWithCertificate(const QString& certificateID, const QString& domainID); + static void addingEntityWithCertificate(const QString& certificateID, const QString& placeName); void updateDisplayMode(); void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo); diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp index a1a709da98..7b48c98e54 100644 --- a/interface/src/commerce/Ledger.cpp +++ b/interface/src/commerce/Ledger.cpp @@ -234,8 +234,8 @@ void Ledger::updateLocation(const QString& asset_id, const QString location, con QStringList keys = wallet->listPublicKeys(); QString key = keys[0]; QJsonObject transaction; - transaction["asset_id"] = asset_id; - transaction["location"] = location; + transaction["certificate_id"] = asset_id; + transaction["place_name"] = location; QJsonDocument transactionDoc{ transaction }; auto transactionString = transactionDoc.toJson(QJsonDocument::Compact); signedSend("transaction", transactionString, key, "location", "updateLocationSuccess", "updateLocationFailure", controlledFailure); diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 16800c6ad3..6952f3b327 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -715,7 +715,7 @@ bool Wallet::changePassphrase(const QString& newPassphrase) { } void Wallet::handleChallengeOwnershipPacket(QSharedPointer packet, SharedNodePointer sendingNode) { - QString decryptedText; + unsigned char decryptedText[64]; int certIDByteArraySize; int encryptedTextByteArraySize; @@ -725,19 +725,24 @@ void Wallet::handleChallengeOwnershipPacket(QSharedPointer pack QByteArray certID = packet->read(certIDByteArraySize); QByteArray encryptedText = packet->read(encryptedTextByteArraySize); - const auto text = reinterpret_cast(encryptedText.constData()); - const unsigned int textLength = encryptedText.length(); + const auto encryptedTextBuf = reinterpret_cast(encryptedText.constData()); + const unsigned int textLength = (int)strlen((char*)encryptedTextBuf); RSA* rsa = readKeys(keyFilePath().toStdString().c_str()); if (rsa) { - const int decryptionStatus = RSA_private_decrypt(textLength, text, reinterpret_cast(encryptedText.data()), rsa, RSA_PKCS1_OAEP_PADDING); + const int decryptionStatus = RSA_private_decrypt(textLength, encryptedTextBuf, decryptedText, rsa, RSA_PKCS1_OAEP_PADDING); + + long error = ERR_get_error(); + const char* error_str = ERR_error_string(error, NULL); + qDebug() << "ZRF HERE\n\nEncrypted Text:" << encryptedTextBuf << "\nEncrypted Text Length:" << textLength << "\nDecrypted Text:" << decryptedText << "\nError:" << error_str; + RSA_free(rsa); if (decryptionStatus != -1) { auto nodeList = DependencyManager::get(); - QByteArray decryptedTextByteArray = decryptedText.toUtf8(); + QByteArray decryptedTextByteArray = QByteArray(reinterpret_cast(decryptedText), (int)strlen((char*)decryptedText)); int decryptedTextByteArraySize = decryptedTextByteArray.size(); int certIDSize = certID.size(); // setup the packet diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp index 2f8b796c93..aa045acbcc 100644 --- a/libraries/entities/src/EntityEditPacketSender.cpp +++ b/libraries/entities/src/EntityEditPacketSender.cpp @@ -111,7 +111,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, #endif queueOctreeEditMessage(type, bufferOut); if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) { - emit addingEntityWithCertificate(properties.getCertificateID(), nodeList->getDomainHandler().getUUID().toString()); + emit addingEntityWithCertificate(properties.getCertificateID(), DependencyManager::get()->currentAddress().authority()); } } } diff --git a/libraries/entities/src/EntityEditPacketSender.h b/libraries/entities/src/EntityEditPacketSender.h index 4e5b62e206..4e8a4be13d 100644 --- a/libraries/entities/src/EntityEditPacketSender.h +++ b/libraries/entities/src/EntityEditPacketSender.h @@ -19,6 +19,8 @@ #include "EntityItem.h" #include "AvatarData.h" +#include + /// Utility for processing, packing, queueing and sending of outbound edit voxel messages. class EntityEditPacketSender : public OctreeEditPacketSender { Q_OBJECT @@ -44,7 +46,7 @@ public: virtual void adjustEditPacketForClockSkew(PacketType type, QByteArray& buffer, qint64 clockSkew) override; signals: - void addingEntityWithCertificate(const QString& certificateID, const QString& domainID); + void addingEntityWithCertificate(const QString& certificateID, const QString& placeName); public slots: void processEntityEditNackPacket(QSharedPointer message, SharedNodePointer sendingNode); diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 7995a7894e..d96cdaaa3e 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -1164,14 +1165,14 @@ QString EntityTree::computeEncryptedNonce(const QString& certID, const QString o const auto text = reinterpret_cast(qPrintable(nonce.toString())); const unsigned int textLength = nonce.toString().length(); - BIO* bio = BIO_new_mem_buf((void*)ownerKey.toUtf8().constData(), -1); + 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) { + if (rsa) { QByteArray encryptedText(RSA_size(rsa), 0); const int encryptStatus = RSA_public_encrypt(textLength, text, reinterpret_cast(encryptedText.data()), rsa, RSA_PKCS1_OAEP_PADDING); - BIO_free(bio); RSA_free(rsa); if (encryptStatus == -1) { qCWarning(entities) << "Unable to compute encrypted nonce for" << certID; @@ -1181,10 +1182,10 @@ QString EntityTree::computeEncryptedNonce(const QString& certID, const QString o QWriteLocker locker(&_certNonceMapLock); _certNonceMap.insert(certID, nonce); - return encryptedText.toBase64(); - //} else { - // return ""; - //} + return encryptedText; + } else { + return ""; + } } bool EntityTree::verifyDecryptedNonce(const QString& certID, const QString& decryptedNonce) { @@ -1302,7 +1303,7 @@ void EntityTree::processChallengeOwnershipPacket(ReceivedMessage& message, const QString certID(message.read(certIDByteArraySize)); QString decryptedText(message.read(decryptedTextByteArraySize)); - qCDebug(entities) << "ZRF FIXME" << decryptedText << certID; + qCDebug(entities) << "ZRF FIXME FJAOPISEJFPAOISEJFOA" << decryptedText << certID; emit killChallengeOwnershipTimeoutTimer(certID);