From f5404ea11b4ba3c7fbcee0e2f4774c52b4a82900 Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Thu, 17 Dec 2015 08:22:18 -0800 Subject: [PATCH] Removed more references to publicKey --- core/backends/lan/lanpairinghandler.cpp | 2 - .../loopback/loopbackpairinghandler.cpp | 1 - tests/devicetest.cpp | 1 - tests/lanlinkprovidertest.cpp | 1 - tests/networkpackagetests.cpp | 53 ------------------- 5 files changed, 58 deletions(-) diff --git a/core/backends/lan/lanpairinghandler.cpp b/core/backends/lan/lanpairinghandler.cpp index 2a5882904..97bf0b981 100644 --- a/core/backends/lan/lanpairinghandler.cpp +++ b/core/backends/lan/lanpairinghandler.cpp @@ -40,8 +40,6 @@ void LanPairingHandler::createPairPackage(NetworkPackage& np) { np.set("link", deviceLink()->name()); np.set("pair", true); - np.set("publicKey", KdeConnectConfig::instance()->publicKey().toPEM()); - np.set("certificate", KdeConnectConfig::instance()->certificate().toPem()); } void LanPairingHandler::packageReceived(const NetworkPackage& np) diff --git a/core/backends/loopback/loopbackpairinghandler.cpp b/core/backends/loopback/loopbackpairinghandler.cpp index a1bdfe04f..f5c851396 100644 --- a/core/backends/loopback/loopbackpairinghandler.cpp +++ b/core/backends/loopback/loopbackpairinghandler.cpp @@ -64,7 +64,6 @@ bool LoopbackPairingHandler::acceptPairing() createPairPackage(np); setPairStatus(PairStatus::Paired); bool success = deviceLink()->sendPackage(np); - KdeConnectConfig::instance()->setDeviceProperty(m_deviceId, "publicKey", QString::fromLatin1(KdeConnectConfig::instance()->certificate().toPem())); KdeConnectConfig::instance()->setDeviceProperty(m_deviceId, "certificate", QString::fromLatin1(KdeConnectConfig::instance()->certificate().toPem())); return success; } diff --git a/tests/devicetest.cpp b/tests/devicetest.cpp index 716911bf8..87fd50ccd 100644 --- a/tests/devicetest.cpp +++ b/tests/devicetest.cpp @@ -60,7 +60,6 @@ void DeviceTest::testPairedDevice() { KdeConnectConfig* kcc = KdeConnectConfig::instance(); kcc->addTrustedDevice(deviceId, deviceName, deviceType); - kcc->setDeviceProperty(deviceId, QString("publicKey"), kcc->publicKey().toPEM()); // Using same public key from kcc, instead of creating new one kcc->setDeviceProperty(deviceId, QString("certificate"), QString::fromLatin1(kcc->certificate().toPem())); // Using same certificate from kcc, instead of generating one Device device(this, deviceId); diff --git a/tests/lanlinkprovidertest.cpp b/tests/lanlinkprovidertest.cpp index eb336d0d0..fc5667841 100644 --- a/tests/lanlinkprovidertest.cpp +++ b/tests/lanlinkprovidertest.cpp @@ -342,7 +342,6 @@ void LanLinkProviderTest::addTrustedDevice() KdeConnectConfig *kcc = KdeConnectConfig::instance(); kcc->addTrustedDevice(deviceId, name, QString("phone")); kcc->setDeviceProperty(deviceId, QString("certificate"), QString::fromLatin1(certificate.toPem())); - kcc->setDeviceProperty(deviceId, QString("publicKey"), privateKey.toPublicKey().toPEM()); } void LanLinkProviderTest::removeTrustedDevice() diff --git a/tests/networkpackagetests.cpp b/tests/networkpackagetests.cpp index 8d2b3d9db..34567874f 100644 --- a/tests/networkpackagetests.cpp +++ b/tests/networkpackagetests.cpp @@ -89,59 +89,6 @@ void NetworkPackageTests::networkPackageIdentityTest() QCOMPARE( np.type() , PACKAGE_TYPE_IDENTITY ); } -/* -void NetworkPackageTests::networkPackageEncryptionTest() -{ - QCA::Initializer init; - if(!QCA::isSupported("rsa")) { - QFAIL("RSA isn't supported by your QCA. "); - return; - } - - - NetworkPackage original("com.test"); - original.set("hello","hola"); - - NetworkPackage copy(""); - NetworkPackage::unserialize(original.serialize(), ©); - - NetworkPackage decrypted(""); - - QCA::PrivateKey privateKey = QCA::KeyGenerator().createRSA(2048); - QVERIFY(!privateKey.isNull()); - QCA::PublicKey publicKey = privateKey.toPublicKey(); - - - //Encrypt and decrypt np - QCOMPARE( original.type(), QString("com.test") ); - original.encrypt(publicKey); - QCOMPARE( original.type(), PACKAGE_TYPE_ENCRYPTED ); - original.decrypt(privateKey, &decrypted); - QCOMPARE( original.type(), PACKAGE_TYPE_ENCRYPTED ); - QCOMPARE( decrypted.type(), QString("com.test") ); - - //np should be equal top np2 - QCOMPARE( decrypted.id(), copy.id() ); - QCOMPARE( decrypted.type(), copy.type() ); - QCOMPARE( decrypted.body(), copy.body() ); - - - //Test for long package encryption that need multi-chunk encryption - - QByteArray json = "{\"body\":{\"nowPlaying\":\"A really long song name - A really long artist name\",\"player\":\"A really long player name\",\"the_meaning_of_life_the_universe_and_everything\":\"42\"},\"id\":\"A really long package id\",\"payloadSize\":0,\"payloadTransferInfo\":{},\"type\":\"kdeconnect.a_really_really_long_package_type\"}\n"; - qDebug() << "EME_PKCS1_OAEP maximumEncryptSize" << publicKey.maximumEncryptSize(QCA::EME_PKCS1_OAEP); - qDebug() << "EME_PKCS1v15 maximumEncryptSize" << publicKey.maximumEncryptSize(QCA::EME_PKCS1v15); - QCOMPARE( json.size() > publicKey.maximumEncryptSize(NetworkPackage::EncryptionAlgorithm), true ); - - NetworkPackage::unserialize(json, &original); - original.encrypt(publicKey); - original.decrypt(privateKey, &decrypted); - QByteArray decryptedJson = decrypted.serialize(); - - QCOMPARE(QString(decryptedJson), QString(json)); - -} -*/ void NetworkPackageTests::cleanupTestCase() {