- Removed GCM, CTR and OFB encryption modes.

- Every time server sends CALV message, IV will be changed as well.
This commit is contained in:
jerry 2013-08-16 18:06:30 +00:00
parent beab22e5b2
commit a25587c4c5
19 changed files with 63 additions and 411 deletions

View File

@ -66,7 +66,6 @@ HEADERS += src/MainWindow.h \
src/IpcClient.h \ src/IpcClient.h \
src/IpcReader.h \ src/IpcReader.h \
src/Ipc.h \ src/Ipc.h \
src/CryptoMode.h \
src/SynergyLocale.h \ src/SynergyLocale.h \
src/QUtility.h src/QUtility.h
RESOURCES += res/Synergy.qrc RESOURCES += res/Synergy.qrc

View File

@ -189,51 +189,6 @@
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property> </property>
<item row="0" column="0">
<widget class="QLabel" name="m_pLabel_26">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&amp;Mode:</string>
</property>
<property name="buddy">
<cstring>m_pComboCryptoMode</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_pComboCryptoMode">
<item>
<property name="text">
<string notr="true">OFB (Output Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CFB (Cipher Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CTR (Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">GCM (Galois/Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Disable encryption</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="m_pLabel_23"> <widget class="QLabel" name="m_pLabel_23">
<property name="minimumSize"> <property name="minimumSize">
@ -260,6 +215,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QCheckBox" name="m_pCheckBoxEnableCrypto">
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -397,7 +359,6 @@
<tabstop>m_pCheckBoxAutoStart</tabstop> <tabstop>m_pCheckBoxAutoStart</tabstop>
<tabstop>m_pCheckBoxAutoConnect</tabstop> <tabstop>m_pCheckBoxAutoConnect</tabstop>
<tabstop>m_pCheckBoxAutoHide</tabstop> <tabstop>m_pCheckBoxAutoHide</tabstop>
<tabstop>m_pComboCryptoMode</tabstop>
<tabstop>m_pLineEditCryptoPass</tabstop> <tabstop>m_pLineEditCryptoPass</tabstop>
<tabstop>m_pComboLogLevel</tabstop> <tabstop>m_pComboLogLevel</tabstop>
<tabstop>m_pCheckBoxLogToFile</tabstop> <tabstop>m_pCheckBoxLogToFile</tabstop>

View File

@ -535,108 +535,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Choose a random encryption mode. The mode must be the same on both the client and server.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum> <enum>QFormLayout::ExpandingFieldsGrow</enum>
</property> </property>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="m_pLabel_26"> <widget class="QCheckBox" name="m_pCheckBoxEnableCrypto">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>&amp;Mode:</string> <string>Enable encryption</string>
</property> </property>
<property name="indent">
<number>10</number>
</property>
<property name="buddy">
<cstring>m_pComboCryptoMode</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="m_pComboCryptoMode">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string notr="true"/>
</property>
</item>
<item>
<property name="text">
<string notr="true">OFB (Output Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CFB (Cipher Feedback)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">CTR (Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">GCM (Galois/Counter)</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Disable encryption</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -808,7 +716,6 @@
<tabstop>m_pRadioButtonPremiumLater</tabstop> <tabstop>m_pRadioButtonPremiumLater</tabstop>
<tabstop>m_pServerRadioButton</tabstop> <tabstop>m_pServerRadioButton</tabstop>
<tabstop>m_pClientRadioButton</tabstop> <tabstop>m_pClientRadioButton</tabstop>
<tabstop>m_pComboCryptoMode</tabstop>
<tabstop>m_pLineEditCryptoPassword1</tabstop> <tabstop>m_pLineEditCryptoPassword1</tabstop>
<tabstop>m_pLineEditCryptoPassword2</tabstop> <tabstop>m_pLineEditCryptoPassword2</tabstop>
</tabstops> </tabstops>

View File

@ -57,7 +57,6 @@ AppConfig::AppConfig(QSettings* settings) :
m_AutoStartPrompt(false), m_AutoStartPrompt(false),
m_WizardLastRun(0), m_WizardLastRun(0),
m_CryptoPass(), m_CryptoPass(),
m_CryptoMode(),
m_ProcessMode(DEFAULT_PROCESS_MODE) m_ProcessMode(DEFAULT_PROCESS_MODE)
{ {
Q_ASSERT(m_pSettings); Q_ASSERT(m_pSettings);
@ -160,7 +159,7 @@ void AppConfig::loadSettings()
m_WizardLastRun = settings().value("wizardLastRun", 0).toInt(); m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
m_ProcessMode = (ProcessMode)settings().value("processMode2", DEFAULT_PROCESS_MODE).toInt(); m_ProcessMode = (ProcessMode)settings().value("processMode2", DEFAULT_PROCESS_MODE).toInt();
m_CryptoPass = settings().value("cryptoPass", "").toString(); m_CryptoPass = settings().value("cryptoPass", "").toString();
m_CryptoMode = (CryptoMode)settings().value("cryptoMode", Disabled).toInt(); m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool();
m_Language = settings().value("language", QLocale::system().name()).toString(); m_Language = settings().value("language", QLocale::system().name()).toString();
m_PremiumEmail= settings().value("premiumEmail", "").toString(); m_PremiumEmail= settings().value("premiumEmail", "").toString();
m_PremiumToken = settings().value("premiumToken", "").toString(); m_PremiumToken = settings().value("premiumToken", "").toString();
@ -181,7 +180,7 @@ void AppConfig::saveSettings()
settings().setValue("wizardLastRun", kWizardVersion); settings().setValue("wizardLastRun", kWizardVersion);
settings().setValue("processMode2", m_ProcessMode); settings().setValue("processMode2", m_ProcessMode);
settings().setValue("cryptoPass", m_CryptoPass); settings().setValue("cryptoPass", m_CryptoPass);
settings().setValue("cryptoMode", m_CryptoMode); settings().setValue("cryptoEnabled", m_CryptoEnabled);
settings().setValue("language", m_Language); settings().setValue("language", m_Language);
settings().setValue("premiumEmail", m_PremiumEmail); settings().setValue("premiumEmail", m_PremiumEmail);
settings().setValue("premiumToken", m_PremiumToken); settings().setValue("premiumToken", m_PremiumToken);
@ -203,28 +202,6 @@ void AppConfig::setCryptoPass(const QString &s)
} }
} }
QString AppConfig::cryptoModeString() const
{
switch (cryptoMode())
{
case OFB:
return "ofb";
case CFB:
return "cfb";
case CTR:
return "ctr";
case GCM:
return "gcm";
default:
qCritical() << "invalid crypto mode";
return "";
}
}
bool AppConfig::isPremium() bool AppConfig::isPremium()
{ {
QString hashSrc = m_PremiumEmail + getFirstMacAddress(); QString hashSrc = m_PremiumEmail + getFirstMacAddress();

View File

@ -21,7 +21,6 @@
#define APPCONFIG_H #define APPCONFIG_H
#include <QString> #include <QString>
#include "CryptoMode.h"
// this should be incremented each time a new page is added. this is // this should be incremented each time a new page is added. this is
// saved to settings when the user finishes running the wizard. if // saved to settings when the user finishes running the wizard. if
@ -66,7 +65,7 @@ class AppConfig
bool autoHide() const { return m_AutoHide; } bool autoHide() const { return m_AutoHide; }
bool autoStartPrompt() const { return m_AutoStartPrompt; } bool autoStartPrompt() const { return m_AutoStartPrompt; }
const QString& cryptoPass() const { return m_CryptoPass; } const QString& cryptoPass() const { return m_CryptoPass; }
CryptoMode cryptoMode() const { return m_CryptoMode; } bool cryptoEnabled() const { return m_CryptoEnabled; }
QString cryptoModeString() const; QString cryptoModeString() const;
ProcessMode processMode() const { return m_ProcessMode; } ProcessMode processMode() const { return m_ProcessMode; }
bool wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; } bool wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; }
@ -95,7 +94,7 @@ class AppConfig
void setAutoStart(bool b); void setAutoStart(bool b);
void setAutoHide(bool b) { m_AutoHide = b; } void setAutoHide(bool b) { m_AutoHide = b; }
void setAutoStartPrompt(bool b) { m_AutoStartPrompt = b; } void setAutoStartPrompt(bool b) { m_AutoStartPrompt = b; }
void setCryptoMode(CryptoMode c) { m_CryptoMode = c; } void setCryptoEnabled(bool b) { m_CryptoEnabled = b; }
void setProcessMode(ProcessMode p) { m_ProcessMode = p; } void setProcessMode(ProcessMode p) { m_ProcessMode = p; }
void setWizardHasRun() { m_WizardLastRun = kWizardVersion; } void setWizardHasRun() { m_WizardLastRun = kWizardVersion; }
void setLanguage(const QString language) { m_Language = language; } void setLanguage(const QString language) { m_Language = language; }
@ -120,8 +119,8 @@ class AppConfig
bool m_AutoHide; bool m_AutoHide;
bool m_AutoStartPrompt; bool m_AutoStartPrompt;
int m_WizardLastRun; int m_WizardLastRun;
bool m_CryptoEnabled;
QString m_CryptoPass; QString m_CryptoPass;
CryptoMode m_CryptoMode;
ProcessMode m_ProcessMode; ProcessMode m_ProcessMode;
QString m_Language; QString m_Language;
QString m_PremiumEmail; QString m_PremiumEmail;

View File

@ -1,26 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2013 Bolton Software Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
enum CryptoMode {
Disabled,
OFB,
CFB,
CTR,
GCM
};

View File

@ -392,9 +392,8 @@ void MainWindow::startSynergy()
if (!appConfig().screenName().isEmpty()) if (!appConfig().screenName().isEmpty())
args << "--name" << appConfig().screenName(); args << "--name" << appConfig().screenName();
if (appConfig().cryptoMode() != Disabled) if (appConfig().cryptoEnabled())
{ {
args << "--crypto-mode" << appConfig().cryptoModeString();
args << "--crypto-pass" << appConfig().cryptoPass(); args << "--crypto-pass" << appConfig().cryptoPass();
} }

View File

@ -44,17 +44,21 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
m_pLineEditLogFilename->setText(appConfig().logFilename()); m_pLineEditLogFilename->setText(appConfig().logFilename());
m_pCheckBoxAutoStart->setChecked(appConfig().autoStart()); m_pCheckBoxAutoStart->setChecked(appConfig().autoStart());
m_pCheckBoxAutoHide->setChecked(appConfig().autoHide()); m_pCheckBoxAutoHide->setChecked(appConfig().autoHide());
m_pCheckBoxEnableCrypto->setChecked(appConfig().cryptoEnabled());
setIndexFromItemData(m_pComboLanguage, appConfig().language()); setIndexFromItemData(m_pComboLanguage, appConfig().language());
if (appConfig().isPremium()) if (appConfig().isPremium())
{ {
m_pComboCryptoMode->setCurrentIndex(getCryptoModeIndex(appConfig().cryptoMode())); if (appConfig().cryptoEnabled())
{
m_pLineEditCryptoPass->setText(appConfig().cryptoPass()); m_pLineEditCryptoPass->setText(appConfig().cryptoPass());
} }
}
else else
{ {
int size = m_pComboCryptoMode->count(); m_pCheckBoxEnableCrypto->setChecked(false);
m_pComboCryptoMode->setCurrentIndex(size - 1); m_pCheckBoxEnableCrypto->setEnabled(false);
m_pComboCryptoMode->setEnabled(false); m_pLineEditCryptoPass->clear();
m_pLineEditCryptoPass->setEnabled(false);
} }
} }
@ -62,8 +66,8 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
void SettingsDialog::accept() void SettingsDialog::accept()
{ {
const QString& cryptoPass = m_pLineEditCryptoPass->text(); const QString& cryptoPass = m_pLineEditCryptoPass->text();
CryptoMode cryptoMode = parseCryptoMode(m_pComboCryptoMode->currentText()); bool cryptoEnabled = m_pCheckBoxEnableCrypto->isChecked();
if ((cryptoMode != Disabled) && cryptoPass.isEmpty()) if (cryptoEnabled && cryptoPass.isEmpty())
{ {
QMessageBox message; QMessageBox message;
message.setWindowTitle("Settings"); message.setWindowTitle("Settings");
@ -83,7 +87,7 @@ void SettingsDialog::accept()
appConfig().setLogFilename(m_pLineEditLogFilename->text()); appConfig().setLogFilename(m_pLineEditLogFilename->text());
appConfig().setAutoStart(m_pCheckBoxAutoStart->isChecked()); appConfig().setAutoStart(m_pCheckBoxAutoStart->isChecked());
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked()); appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
appConfig().setCryptoMode(cryptoMode); appConfig().setCryptoEnabled(cryptoEnabled);
appConfig().setCryptoPass(cryptoPass); appConfig().setCryptoPass(cryptoPass);
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()); appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
appConfig().saveSettings(); appConfig().saveSettings();
@ -143,59 +147,17 @@ void SettingsDialog::on_m_pButtonBrowseLog_clicked()
} }
} }
void SettingsDialog::on_m_pComboCryptoMode_currentIndexChanged(int index) void SettingsDialog::on_m_pCheckBoxEnableCrypto_stateChanged(int )
{ {
bool enabled = parseCryptoMode(m_pComboCryptoMode->currentText()) != Disabled; bool cryptoEnabled = m_pCheckBoxEnableCrypto->isChecked();
m_pLineEditCryptoPass->setEnabled(enabled); m_pLineEditCryptoPass->setEnabled(cryptoEnabled);
if (!enabled)
if (!cryptoEnabled)
{ {
m_pLineEditCryptoPass->clear(); m_pLineEditCryptoPass->clear();
} }
} }
int SettingsDialog::getCryptoModeIndex(const CryptoMode& mode) const
{
switch (mode)
{
case OFB:
return m_pComboCryptoMode->findText("OFB", Qt::MatchStartsWith);
case CFB:
return m_pComboCryptoMode->findText("CFB", Qt::MatchStartsWith);
case CTR:
return m_pComboCryptoMode->findText("CTR", Qt::MatchStartsWith);
case GCM:
return m_pComboCryptoMode->findText("GCM", Qt::MatchStartsWith);
default:
return m_pComboCryptoMode->findText("Disable", Qt::MatchStartsWith);
}
}
CryptoMode SettingsDialog::parseCryptoMode(const QString& s)
{
if (s.startsWith("OFB"))
{
return OFB;
}
else if (s.startsWith("CFB"))
{
return CFB;
}
else if (s.startsWith("CTR"))
{
return CTR;
}
else if (s.startsWith("GCM"))
{
return GCM;
}
return Disabled;
}
void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index) void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
{ {
QString ietfCode = m_pComboLanguage->itemData(index).toString(); QString ietfCode = m_pComboLanguage->itemData(index).toString();

View File

@ -22,7 +22,6 @@
#include <QDialog> #include <QDialog>
#include "ui_SettingsDialogBase.h" #include "ui_SettingsDialogBase.h"
#include "CryptoMode.h"
#include "SynergyLocale.h" #include "SynergyLocale.h"
class AppConfig; class AppConfig;
@ -43,13 +42,11 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
AppConfig& appConfig() { return m_AppConfig; } AppConfig& appConfig() { return m_AppConfig; }
private: private:
int getCryptoModeIndex(const CryptoMode& mode) const;
CryptoMode parseCryptoMode(const QString& s);
AppConfig& m_AppConfig; AppConfig& m_AppConfig;
SynergyLocale m_Locale; SynergyLocale m_Locale;
private slots: private slots:
void on_m_pComboCryptoMode_currentIndexChanged(int index); void on_m_pCheckBoxEnableCrypto_stateChanged(int );
void on_m_pComboLanguage_currentIndexChanged(int index); void on_m_pComboLanguage_currentIndexChanged(int index);
void on_m_pCheckBoxLogToFile_stateChanged(int ); void on_m_pCheckBoxLogToFile_stateChanged(int );
void on_m_pButtonBrowseLog_clicked(); void on_m_pButtonBrowseLog_clicked();

View File

@ -107,8 +107,8 @@ bool SetupWizard::validateCurrentPage()
} }
else else
{ {
m_pComboCryptoMode->setCurrentIndex(0); m_pCheckBoxEnableCrypto->setEnabled(true);
m_pComboCryptoMode->setEnabled(true); m_pCheckBoxEnableCrypto->setChecked(true);
} }
} }
else if (m_pRadioButtonPremiumRegister->isChecked()) else if (m_pRadioButtonPremiumRegister->isChecked())
@ -120,9 +120,9 @@ bool SetupWizard::validateCurrentPage()
} }
else if (m_pRadioButtonPremiumLater->isChecked()) else if (m_pRadioButtonPremiumLater->isChecked())
{ {
int size = m_pComboCryptoMode->count(); m_pCheckBoxEnableCrypto->setEnabled(false);
m_pComboCryptoMode->setCurrentIndex(size - 1); m_pLineEditCryptoPassword1->setEnabled(false);
m_pComboCryptoMode->setEnabled(false); m_pLineEditCryptoPassword2->setEnabled(false);
} }
else { else {
message.setText(tr("Please select an option.")); message.setText(tr("Please select an option."));
@ -132,15 +132,7 @@ bool SetupWizard::validateCurrentPage()
} }
else if (currentPage() == m_pCryptoPage) else if (currentPage() == m_pCryptoPage)
{ {
QString modeText = m_pComboCryptoMode->currentText(); if (m_pCheckBoxEnableCrypto->isChecked())
if (modeText.isEmpty())
{
message.setText(tr("Encryption mode required."));
message.exec();
return false;
}
if (parseCryptoMode(modeText) != Disabled)
{ {
if (m_pLineEditCryptoPassword1->text().isEmpty()) if (m_pLineEditCryptoPassword1->text().isEmpty())
{ {
@ -185,7 +177,7 @@ void SetupWizard::accept()
{ {
AppConfig& appConfig = m_MainWindow.appConfig(); AppConfig& appConfig = m_MainWindow.appConfig();
appConfig.setCryptoMode(parseCryptoMode(m_pComboCryptoMode->currentText())); appConfig.setCryptoEnabled(m_pCheckBoxEnableCrypto->isChecked());
appConfig.setCryptoPass(m_pLineEditCryptoPassword1->text()); appConfig.setCryptoPass(m_pLineEditCryptoPassword1->text());
appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()); appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
appConfig.setPremiumEmail(m_pLineEditPremiumEmail->text()); appConfig.setPremiumEmail(m_pLineEditPremiumEmail->text());
@ -239,33 +231,16 @@ void SetupWizard::reject()
QWizard::reject(); QWizard::reject();
} }
void SetupWizard::on_m_pComboCryptoMode_currentIndexChanged(int index) void SetupWizard::on_m_pCheckBoxEnableCrypto_stateChanged(int )
{ {
bool enabled = parseCryptoMode(m_pComboCryptoMode->currentText()) != Disabled; bool enabled = m_pCheckBoxEnableCrypto->isChecked();
m_pLineEditCryptoPassword1->setEnabled(enabled); m_pLineEditCryptoPassword1->setEnabled(enabled);
m_pLineEditCryptoPassword2->setEnabled(enabled); m_pLineEditCryptoPassword2->setEnabled(enabled);
} if (!enabled)
CryptoMode SetupWizard::parseCryptoMode(const QString& s)
{
if (s.startsWith("OFB"))
{ {
return OFB; m_pLineEditCryptoPassword1->clear();
m_pLineEditCryptoPassword2->clear();
} }
else if (s.startsWith("CFB"))
{
return CFB;
}
else if (s.startsWith("CTR"))
{
return CTR;
}
else if (s.startsWith("GCM"))
{
return GCM;
}
return Disabled;
} }
void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index) void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index)

View File

@ -18,7 +18,6 @@
#pragma once #pragma once
#include "ui_SetupWizardBase.h" #include "ui_SetupWizardBase.h"
#include "CryptoMode.h"
#include "SynergyLocale.h" #include "SynergyLocale.h"
#include <QWizard> #include <QWizard>
@ -41,7 +40,6 @@ protected:
void reject(); void reject();
private: private:
CryptoMode parseCryptoMode(const QString& s);
bool isPremiumLoginValid(QMessageBox& message); bool isPremiumLoginValid(QMessageBox& message);
private: private:
@ -51,7 +49,7 @@ private:
QNetworkAccessManager m_Network; QNetworkAccessManager m_Network;
private slots: private slots:
void on_m_pComboCryptoMode_currentIndexChanged(int index); void on_m_pCheckBoxEnableCrypto_stateChanged(int );
void on_m_pComboLanguage_currentIndexChanged(int index); void on_m_pComboLanguage_currentIndexChanged(int index);
void on_m_pRadioButtonPremiumLogin_toggled(bool checked); void on_m_pRadioButtonPremiumLogin_toggled(bool checked);
}; };

View File

@ -27,22 +27,10 @@ CCryptoMode::CCryptoMode(ECryptoMode mode, bool encryption) :
{ {
if (m_encryption) { if (m_encryption) {
switch (m_mode) { switch (m_mode) {
case kOfb:
m_crypto = new COfbModeEnc;
break;
case kCfb: case kCfb:
m_crypto = new CCfbModeEnc; m_crypto = new CCfbModeEnc;
break; break;
case kCtr:
m_crypto = new CCtrModeEnc;
break;
case kGcm:
m_crypto = new CGcmModeEnc;
break;
case kDisabled: case kDisabled:
break; break;
@ -52,22 +40,10 @@ CCryptoMode::CCryptoMode(ECryptoMode mode, bool encryption) :
} }
else { else {
switch (m_mode) { switch (m_mode) {
case kOfb:
m_crypto = new COfbModeDec;
break;
case kCfb: case kCfb:
m_crypto = new CCfbModeDec; m_crypto = new CCfbModeDec;
break; break;
case kCtr:
m_crypto = new CCtrModeDec;
break;
case kGcm:
m_crypto = new CGcmModeDec;
break;
case kDisabled: case kDisabled:
break; break;
@ -85,40 +61,16 @@ CCryptoMode::~CCryptoMode()
if (m_encryption) { if (m_encryption) {
switch (m_mode) { switch (m_mode) {
case kOfb:
delete reinterpret_cast<COfbModeEnc*>(m_crypto);
break;
case kCfb: case kCfb:
delete reinterpret_cast<CCfbModeEnc*>(m_crypto); delete reinterpret_cast<CCfbModeEnc*>(m_crypto);
break; break;
case kCtr:
delete reinterpret_cast<CCtrModeEnc*>(m_crypto);
break;
case kGcm:
delete reinterpret_cast<CGcmModeEnc*>(m_crypto);
break;
} }
} }
else { else {
switch (m_mode) { switch (m_mode) {
case kOfb:
delete reinterpret_cast<COfbModeDec*>(m_crypto);
break;
case kCfb: case kCfb:
delete reinterpret_cast<CCfbModeDec*>(m_crypto); delete reinterpret_cast<CCfbModeDec*>(m_crypto);
break; break;
case kCtr:
delete reinterpret_cast<CCtrModeDec*>(m_crypto);
break;
case kGcm:
delete reinterpret_cast<CGcmModeDec*>(m_crypto);
break;
} }
} }
} }
@ -132,40 +84,16 @@ CCryptoMode::processData(byte* out, const byte* in, size_t length)
if (m_encryption) { if (m_encryption) {
switch (m_mode) { switch (m_mode) {
case kOfb:
reinterpret_cast<COfbModeEnc*>(m_crypto)->ProcessData(out, in, length);
break;
case kCfb: case kCfb:
reinterpret_cast<CCfbModeEnc*>(m_crypto)->ProcessData(out, in, length); reinterpret_cast<CCfbModeEnc*>(m_crypto)->ProcessData(out, in, length);
break; break;
case kCtr:
reinterpret_cast<CCtrModeEnc*>(m_crypto)->ProcessData(out, in, length);
break;
case kGcm:
reinterpret_cast<CGcmModeEnc*>(m_crypto)->ProcessData(out, in, length);
break;
} }
} }
else { else {
switch (m_mode) { switch (m_mode) {
case kOfb:
reinterpret_cast<COfbModeDec*>(m_crypto)->ProcessData(out, in, length);
break;
case kCfb: case kCfb:
reinterpret_cast<CCfbModeDec*>(m_crypto)->ProcessData(out, in, length); reinterpret_cast<CCfbModeDec*>(m_crypto)->ProcessData(out, in, length);
break; break;
case kCtr:
reinterpret_cast<CCtrModeDec*>(m_crypto)->ProcessData(out, in, length);
break;
case kGcm:
reinterpret_cast<CGcmModeDec*>(m_crypto)->ProcessData(out, in, length);
break;
} }
} }
} }
@ -180,40 +108,16 @@ CCryptoMode::setKeyWithIv(const byte* key, size_t length, const byte* iv)
if (m_encryption) { if (m_encryption) {
switch (m_mode) { switch (m_mode) {
case kOfb:
reinterpret_cast<COfbModeEnc*>(m_crypto)->SetKeyWithIV(key, length, iv);
break;
case kCfb: case kCfb:
reinterpret_cast<CCfbModeEnc*>(m_crypto)->SetKeyWithIV(key, length, iv); reinterpret_cast<CCfbModeEnc*>(m_crypto)->SetKeyWithIV(key, length, iv);
break; break;
case kCtr:
reinterpret_cast<CCtrModeEnc*>(m_crypto)->SetKeyWithIV(key, length, iv);
break;
case kGcm:
reinterpret_cast<CGcmModeEnc*>(m_crypto)->SetKeyWithIV(key, length, iv);
break;
} }
} }
else { else {
switch (m_mode) { switch (m_mode) {
case kOfb:
reinterpret_cast<COfbModeDec*>(m_crypto)->SetKeyWithIV(key, length, iv);
break;
case kCfb: case kCfb:
reinterpret_cast<CCfbModeDec*>(m_crypto)->SetKeyWithIV(key, length, iv); reinterpret_cast<CCfbModeDec*>(m_crypto)->SetKeyWithIV(key, length, iv);
break; break;
case kCtr:
reinterpret_cast<CCtrModeDec*>(m_crypto)->SetKeyWithIV(key, length, iv);
break;
case kGcm:
reinterpret_cast<CGcmModeDec*>(m_crypto)->SetKeyWithIV(key, length, iv);
break;
} }
} }
} }

View File

@ -36,18 +36,9 @@ CCryptoOptions::setMode(CString modeString)
ECryptoMode ECryptoMode
CCryptoOptions::parseMode(CString modeString) CCryptoOptions::parseMode(CString modeString)
{ {
if (modeString == "ofb") { if (modeString == "cfb") {
return kOfb;
}
else if (modeString == "cfb") {
return kCfb; return kCfb;
} }
else if (modeString == "ctr") {
return kCtr;
}
else if (modeString == "gcm") {
return kGcm;
}
else { else {
throw XIOBadCryptoMode(); throw XIOBadCryptoMode();
} }

View File

@ -19,9 +19,6 @@
enum ECryptoMode { enum ECryptoMode {
kDisabled, kDisabled,
kOfb,
kCfb, kCfb,
kCtr,
kGcm,
kNumOfModes kNumOfModes
}; };

View File

@ -116,6 +116,12 @@ CClientProxy1_3::removeHeartbeatTimer()
void void
CClientProxy1_3::handleKeepAlive(const CEvent&, void*) CClientProxy1_3::handleKeepAlive(const CEvent&, void*)
{
keepAlive();
}
void
CClientProxy1_3::keepAlive()
{ {
CProtocolUtil::writef(getStream(), kMsgCKeepAlive); CProtocolUtil::writef(getStream(), kMsgCKeepAlive);
} }

View File

@ -38,6 +38,7 @@ protected:
virtual void resetHeartbeatTimer(); virtual void resetHeartbeatTimer();
virtual void addHeartbeatTimer(); virtual void addHeartbeatTimer();
virtual void removeHeartbeatTimer(); virtual void removeHeartbeatTimer();
virtual void keepAlive();
private: private:
void handleKeepAlive(const CEvent&, void*); void handleKeepAlive(const CEvent&, void*);

View File

@ -61,6 +61,13 @@ CClientProxy1_4::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
CClientProxy1_3::keyUp(key, mask, button); CClientProxy1_3::keyUp(key, mask, button);
} }
void
CClientProxy1_4::keepAlive()
{
cryptoIv();
CClientProxy1_3::keepAlive();
}
void void
CClientProxy1_4::cryptoIv() CClientProxy1_4::cryptoIv()
{ {

View File

@ -40,6 +40,7 @@ public:
virtual void keyDown(KeyID key, KeyModifierMask mask, KeyButton button); virtual void keyDown(KeyID key, KeyModifierMask mask, KeyButton button);
virtual void keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button); virtual void keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button);
virtual void keyUp(KeyID key, KeyModifierMask mask, KeyButton button); virtual void keyUp(KeyID key, KeyModifierMask mask, KeyButton button);
virtual void keepAlive();
//! Send IV to make //! Send IV to make
void cryptoIv(); void cryptoIv();

View File

@ -165,10 +165,7 @@ CApp::parseArg(const int& argc, const char* const* argv, int& i)
else if (isArg(i, argc, argv, NULL, "--crypto-pass")) { else if (isArg(i, argc, argv, NULL, "--crypto-pass")) {
argsBase().m_crypto.m_pass = argv[++i]; argsBase().m_crypto.m_pass = argv[++i];
} argsBase().m_crypto.setMode("cfb");
else if (isArg(i, argc, argv, NULL, "--crypto-mode")) {
argsBase().m_crypto.setMode(argv[++i]);
} }
else if (isArg(i, argc, argv, NULL, "--filetransfer-src")) { else if (isArg(i, argc, argv, NULL, "--filetransfer-src")) {