From: Johannes Huber Date: Thu, 17 Mar 2011 13:19:18 +0000 (+0100) Subject: check for qca provider plugin, fixes #1045 X-Git-Tag: 0.7.4~10 X-Git-Url: https://git.quassel-irc.org/?a=commitdiff_plain;h=90fba615fc90c23d92faa6d874dd0b3fcf80a425;p=quassel.git check for qca provider plugin, fixes #1045 Prevents core from crashing when qca provider plugin is missing. The plugin is needed at runtime. Can occurres when packagers did not install it. --- diff --git a/src/core/cipher.cpp b/src/core/cipher.cpp index 195936cb..92b8fad1 100644 --- a/src/core/cipher.cpp +++ b/src/core/cipher.cpp @@ -13,6 +13,7 @@ */ #include "cipher.h" +#include "logger.h" Cipher::Cipher() @@ -449,3 +450,14 @@ QByteArray Cipher::b64ToByte(QByteArray text) } return decoded; } + +bool Cipher::neededFeaturesAvailable() +{ + QCA::Initializer init; + + if (QCA::isSupported("blowfish-ecb") && QCA::isSupported("blowfish-cbc") && QCA::isSupported("dh")) + return true; + + qWarning() << "QCA provider plugin not found. It is usually provided by the qca-ossl plugin."; + return false; +} diff --git a/src/core/cipher.h b/src/core/cipher.h index b5cf0e0f..33a2bf8c 100644 --- a/src/core/cipher.h +++ b/src/core/cipher.h @@ -33,6 +33,7 @@ class Cipher QByteArray key() { return m_key; } bool setType(const QString &type); QString type() { return m_type; } + static bool neededFeaturesAvailable(); private: //direction is true for encrypt, false for decrypt diff --git a/src/core/coreircchannel.cpp b/src/core/coreircchannel.cpp index 85eb333f..02b81b76 100644 --- a/src/core/coreircchannel.cpp +++ b/src/core/coreircchannel.cpp @@ -46,6 +46,9 @@ Cipher *CoreIrcChannel::cipher() const { } void CoreIrcChannel::setEncrypted(bool e) { + if(!Cipher::neededFeaturesAvailable()) + return; + if(e) { if(topic().isEmpty()) return; diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index b7ec55d2..5b539fae 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -281,6 +281,9 @@ Cipher *CoreNetwork::cipher(const QString &target) const { if(target.isEmpty()) return 0; + if(!Cipher::neededFeaturesAvailable()) + return 0; + QByteArray key = cipherKey(target); if(key.isEmpty()) return 0; diff --git a/src/core/coreuserinputhandler.cpp b/src/core/coreuserinputhandler.cpp index c0c40364..633cd8bc 100644 --- a/src/core/coreuserinputhandler.cpp +++ b/src/core/coreuserinputhandler.cpp @@ -163,6 +163,9 @@ void CoreUserInputHandler::handleDelkey(const BufferInfo &bufferInfo, const QStr if(!bufferInfo.isValid()) return; + if(!Cipher::neededFeaturesAvailable()) + return; + QStringList parms = msg.split(' ', QString::SkipEmptyParts); if(parms.isEmpty() && !bufferInfo.bufferName().isEmpty()) @@ -452,6 +455,9 @@ void CoreUserInputHandler::handleSetkey(const BufferInfo &bufferInfo, const QStr if(!bufferInfo.isValid()) return; + if(!Cipher::neededFeaturesAvailable()) + return; + QStringList parms = msg.split(' ', QString::SkipEmptyParts); if(parms.count() == 1 && !bufferInfo.bufferName().isEmpty()) @@ -636,6 +642,9 @@ QByteArray CoreUserInputHandler::encrypt(const QString &target, const QByteArray if(message_.isEmpty()) return message_; + if(!Cipher::neededFeaturesAvailable()) + return message_; + Cipher *cipher = network()->cipher(target); if(!cipher) return message_; diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index 7004e864..59f24884 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -1307,6 +1307,9 @@ QByteArray IrcServerHandler::decrypt(const QString &bufferName, const QByteArray if(message_.isEmpty()) return message_; + if(!Cipher::neededFeaturesAvailable()) + return message_; + Cipher *cipher = network()->cipher(bufferName); if(!cipher) return message_;