mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 01:59:59 +02:00
Getting closer
This commit is contained in:
parent
c3e66c9581
commit
5efa920712
7 changed files with 28 additions and 20 deletions
|
@ -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>();
|
||||
ledger->updateLocation(certificateID, domainID);
|
||||
ledger->updateLocation(certificateID, placeName);
|
||||
}
|
||||
|
||||
void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointer scriptEngine) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -715,7 +715,7 @@ bool Wallet::changePassphrase(const QString& newPassphrase) {
|
|||
}
|
||||
|
||||
void Wallet::handleChallengeOwnershipPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode) {
|
||||
QString decryptedText;
|
||||
unsigned char decryptedText[64];
|
||||
int certIDByteArraySize;
|
||||
int encryptedTextByteArraySize;
|
||||
|
||||
|
@ -725,19 +725,24 @@ void Wallet::handleChallengeOwnershipPacket(QSharedPointer<ReceivedMessage> pack
|
|||
QByteArray certID = packet->read(certIDByteArraySize);
|
||||
QByteArray encryptedText = packet->read(encryptedTextByteArraySize);
|
||||
|
||||
const auto text = reinterpret_cast<const unsigned char*>(encryptedText.constData());
|
||||
const unsigned int textLength = encryptedText.length();
|
||||
const auto encryptedTextBuf = reinterpret_cast<const unsigned char*>(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<unsigned char*>(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<NodeList>();
|
||||
|
||||
QByteArray decryptedTextByteArray = decryptedText.toUtf8();
|
||||
QByteArray decryptedTextByteArray = QByteArray(reinterpret_cast<char*>(decryptedText), (int)strlen((char*)decryptedText));
|
||||
int decryptedTextByteArraySize = decryptedTextByteArray.size();
|
||||
int certIDSize = certID.size();
|
||||
// setup the packet
|
||||
|
|
|
@ -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<AddressManager>()->currentAddress().authority());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "EntityItem.h"
|
||||
#include "AvatarData.h"
|
||||
|
||||
#include <AddressManager.h>
|
||||
|
||||
/// 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<ReceivedMessage> message, SharedNodePointer sendingNode);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QQueue>
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/x509.h>
|
||||
|
@ -1164,14 +1165,14 @@ QString EntityTree::computeEncryptedNonce(const QString& certID, const QString o
|
|||
const auto text = reinterpret_cast<const unsigned char*>(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<unsigned char*>(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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue