mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-23 00:56:21 +03:00
deleted old home brew crypto #4313
This commit is contained in:
parent
4fcec1d217
commit
80343c41eb
@ -319,7 +319,6 @@ else() # not-unix
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(ext)
|
||||
|
||||
if (WIN32)
|
||||
# TODO: consider using /analyze to uncover potential bugs in the source code.
|
||||
|
@ -1,96 +0,0 @@
|
||||
# synergy -- mouse and keyboard sharing utility
|
||||
# Copyright (C) 2013 Synergy Si 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/>.
|
||||
|
||||
set(cryptopp_dir cryptopp562)
|
||||
|
||||
# only compile the crypto++ files we need.
|
||||
set(cryptopp_src
|
||||
${cryptopp_dir}/3way.cpp
|
||||
${cryptopp_dir}/algparam.cpp
|
||||
${cryptopp_dir}/asn.cpp
|
||||
${cryptopp_dir}/authenc.cpp
|
||||
${cryptopp_dir}/basecode.cpp
|
||||
${cryptopp_dir}/cpu.cpp
|
||||
${cryptopp_dir}/cryptlib.cpp
|
||||
${cryptopp_dir}/des.cpp
|
||||
${cryptopp_dir}/dessp.cpp
|
||||
${cryptopp_dir}/dll.cpp
|
||||
${cryptopp_dir}/ec2n.cpp
|
||||
${cryptopp_dir}/ecp.cpp
|
||||
${cryptopp_dir}/filters.cpp
|
||||
${cryptopp_dir}/fips140.cpp
|
||||
${cryptopp_dir}/gcm.cpp
|
||||
${cryptopp_dir}/gf2n.cpp
|
||||
${cryptopp_dir}/gfpcrypt.cpp
|
||||
${cryptopp_dir}/hex.cpp
|
||||
${cryptopp_dir}/hmac.cpp
|
||||
${cryptopp_dir}/hrtimer.cpp
|
||||
${cryptopp_dir}/integer.cpp
|
||||
${cryptopp_dir}/iterhash.cpp
|
||||
${cryptopp_dir}/misc.cpp
|
||||
${cryptopp_dir}/modes.cpp
|
||||
${cryptopp_dir}/mqueue.cpp
|
||||
${cryptopp_dir}/nbtheory.cpp
|
||||
${cryptopp_dir}/oaep.cpp
|
||||
${cryptopp_dir}/osrng.cpp
|
||||
${cryptopp_dir}/pubkey.cpp
|
||||
${cryptopp_dir}/queue.cpp
|
||||
${cryptopp_dir}/randpool.cpp
|
||||
${cryptopp_dir}/rdtables.cpp
|
||||
${cryptopp_dir}/rijndael.cpp
|
||||
${cryptopp_dir}/rng.cpp
|
||||
${cryptopp_dir}/sha.cpp
|
||||
)
|
||||
|
||||
# if 64-bit windows, compile asm file.
|
||||
if (CMAKE_CL_64)
|
||||
list(APPEND cryptopp_src ${cryptopp_dir}/x64dll.asm ${cryptopp_dir}/x64masm.asm)
|
||||
|
||||
add_custom_command(OUTPUT $(IntDir)x64dll.obj
|
||||
COMMAND ml64.exe /c /nologo /Fo$(IntDir)x64dll.obj /Zi
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${cryptopp_dir}/x64dll.asm"
|
||||
MAIN_DEPENDENCY ${cryptopp_dir}/x64dll.asm
|
||||
VERBATIM)
|
||||
|
||||
add_custom_command(OUTPUT $(IntDir)x64masm.obj
|
||||
COMMAND ml64.exe /c /nologo /Fo$(IntDir)x64masm.obj /Zi
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${cryptopp_dir}/x64masm.asm"
|
||||
MAIN_DEPENDENCY ${cryptopp_dir}/x64masm.asm
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
add_definitions(-DCRYPTOPP_DISABLE_ASM)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -pipe")
|
||||
|
||||
if (APPLE)
|
||||
if (DARWIN_VERSION GREATER 10)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-compare")
|
||||
endif()
|
||||
else()
|
||||
set(CRYPTOPP_ARCH "native")
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^arm.*")
|
||||
set(CRYPTOPP_ARCH "armv6zk")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${CRYPTOPP_ARCH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(cryptopp STATIC ${cryptopp_src})
|
||||
|
||||
if (UNIX)
|
||||
# ignore warnings in crypto++
|
||||
set_target_properties(cryptopp PROPERTIES COMPILE_FLAGS "-w")
|
||||
endif()
|
Binary file not shown.
@ -247,9 +247,6 @@ class InternalCommands:
|
||||
# by default, unknown
|
||||
macIdentity = None
|
||||
|
||||
# cryptoPP dir with version number
|
||||
cryptoPPDir = 'cryptopp562'
|
||||
|
||||
# gtest dir with version number
|
||||
gtestDir = 'gtest-1.6.0'
|
||||
|
||||
@ -320,22 +317,6 @@ class InternalCommands:
|
||||
for target in targets:
|
||||
self.configure(target)
|
||||
|
||||
def checkCryptoPP(self):
|
||||
|
||||
dir = self.extDir + '/' + self.cryptoPPDir
|
||||
if (os.path.isdir(dir)):
|
||||
return
|
||||
|
||||
zipFilename = dir + '.zip'
|
||||
if (not os.path.exists(zipFilename)):
|
||||
raise Exception('Crypto++ zip not found at: ' + zipFilename)
|
||||
|
||||
if not os.path.exists(dir):
|
||||
os.mkdir(dir)
|
||||
|
||||
zip = zipfile.ZipFile(zipFilename)
|
||||
self.zipExtractAll(zip, dir)
|
||||
|
||||
def checkGTest(self):
|
||||
|
||||
dir = self.extDir + '/' + self.gtestDir
|
||||
@ -464,8 +445,6 @@ class InternalCommands:
|
||||
# if not visual studio, use parent dir
|
||||
sourceDir = generator.getSourceDir()
|
||||
|
||||
# ensure that the cryptopp source exists
|
||||
self.checkCryptoPP()
|
||||
self.checkGTest()
|
||||
self.checkGMock()
|
||||
|
||||
|
@ -58,7 +58,7 @@ endif()
|
||||
|
||||
add_executable(synergyc ${sources})
|
||||
target_link_libraries(synergyc
|
||||
arch base client common io mt net ipc platform server synergy cryptopp ${libs})
|
||||
arch base client common io mt net ipc platform server synergy ${libs})
|
||||
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
|
@ -35,7 +35,7 @@ else()
|
||||
endif()
|
||||
|
||||
target_link_libraries(synergyd
|
||||
arch base common io ipc mt net platform synergy cryptopp ${libs})
|
||||
arch base common io ipc mt net platform synergy ${libs})
|
||||
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
|
@ -63,7 +63,7 @@ else()
|
||||
endif()
|
||||
|
||||
target_link_libraries(synergyp
|
||||
arch base client common io mt net ipc platform server synergy client cryptopp ${libs})
|
||||
arch base client common io mt net ipc platform server synergy client ${libs})
|
||||
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
|
@ -58,7 +58,7 @@ endif()
|
||||
|
||||
add_executable(synergys ${sources})
|
||||
target_link_libraries(synergys
|
||||
arch base client common io mt net ipc platform server synergy cryptopp ${libs})
|
||||
arch base client common io mt net ipc platform server synergy ${libs})
|
||||
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
|
@ -29,7 +29,7 @@ endif()
|
||||
|
||||
add_executable(syntool ${sources})
|
||||
target_link_libraries(syntool
|
||||
synergy arch base client common io ipc mt net platform server cryptopp ${libs})
|
||||
synergy arch base client common io ipc mt net platform server ${libs})
|
||||
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
|
@ -1,353 +1,326 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SettingsDialogBase</class>
|
||||
<widget class="QDialog" name="SettingsDialogBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>354</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupAdvanced">
|
||||
<property name="title">
|
||||
<string>&Miscellaneous</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_19">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sc&reen name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditScreenName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditScreenName">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_20">
|
||||
<property name="text">
|
||||
<string>P&ort:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pSpinBoxPort</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_pSpinBoxPort">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24800</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_21">
|
||||
<property name="text">
|
||||
<string>&Interface:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditInterface</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditInterface">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_27">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Language:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pComboLanguage</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_pComboLanguage"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxElevateMode">
|
||||
<property name="text">
|
||||
<string>Elevate mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupCrypto">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>&Encryption</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_23">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pass&word:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditCryptoPass</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditCryptoPass">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxEnableCrypto">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupLog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Logging</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Logging level:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pComboLogLevel</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="m_pComboLogLevel">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Warning</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Note</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxLogToFile">
|
||||
<property name="text">
|
||||
<string>Log to file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditLogFilename">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="m_pButtonBrowseLog">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_pComboLanguage</tabstop>
|
||||
<tabstop>m_pLineEditScreenName</tabstop>
|
||||
<tabstop>m_pSpinBoxPort</tabstop>
|
||||
<tabstop>m_pLineEditInterface</tabstop>
|
||||
<tabstop>m_pLineEditCryptoPass</tabstop>
|
||||
<tabstop>m_pComboLogLevel</tabstop>
|
||||
<tabstop>m_pCheckBoxLogToFile</tabstop>
|
||||
<tabstop>m_pLineEditLogFilename</tabstop>
|
||||
<tabstop>m_pButtonBrowseLog</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SettingsDialogBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>266</x>
|
||||
<y>340</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SettingsDialogBase</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>334</x>
|
||||
<y>340</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SettingsDialogBase</class>
|
||||
<widget class="QDialog" name="SettingsDialogBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>368</width>
|
||||
<height>377</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupAdvanced">
|
||||
<property name="title">
|
||||
<string>&Miscellaneous</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_19">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sc&reen name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditScreenName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditScreenName">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_20">
|
||||
<property name="text">
|
||||
<string>P&ort:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pSpinBoxPort</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="m_pSpinBoxPort">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>24800</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_21">
|
||||
<property name="text">
|
||||
<string>&Interface:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pLineEditInterface</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditInterface">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_27">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Language:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pComboLanguage</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_pComboLanguage"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxElevateMode">
|
||||
<property name="text">
|
||||
<string>Elevate mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupCrypto">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>&Encryption</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxEnableCrypto">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_pGroupLog">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Logging</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_pLabel_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Logging level:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_pComboLogLevel</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="m_pComboLogLevel">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Warning</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Note</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="m_pCheckBoxLogToFile">
|
||||
<property name="text">
|
||||
<string>Log to file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="m_pLineEditLogFilename">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="m_pButtonBrowseLog">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>m_pComboLanguage</tabstop>
|
||||
<tabstop>m_pLineEditScreenName</tabstop>
|
||||
<tabstop>m_pSpinBoxPort</tabstop>
|
||||
<tabstop>m_pLineEditInterface</tabstop>
|
||||
<tabstop>m_pComboLogLevel</tabstop>
|
||||
<tabstop>m_pCheckBoxLogToFile</tabstop>
|
||||
<tabstop>m_pLineEditLogFilename</tabstop>
|
||||
<tabstop>m_pButtonBrowseLog</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SettingsDialogBase</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>266</x>
|
||||
<y>340</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SettingsDialogBase</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>334</x>
|
||||
<y>340</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -53,7 +53,6 @@ AppConfig::AppConfig(QSettings* settings) :
|
||||
m_Interface(),
|
||||
m_LogLevel(0),
|
||||
m_WizardLastRun(0),
|
||||
m_CryptoPass(),
|
||||
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
||||
m_AutoConfig(true),
|
||||
m_ElevateMode(false),
|
||||
@ -121,8 +120,6 @@ void AppConfig::loadSettings()
|
||||
m_LogToFile = settings().value("logToFile", false).toBool();
|
||||
m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString();
|
||||
m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
|
||||
m_CryptoPass = settings().value("cryptoPass", "").toString();
|
||||
m_CryptoEnabled = settings().value("cryptoEnabled", false).toBool();
|
||||
m_Language = settings().value("language", QLocale::system().name()).toString();
|
||||
m_StartedBefore = settings().value("startedBefore", false).toBool();
|
||||
m_AutoConfig = settings().value("autoConfig", true).toBool();
|
||||
@ -142,8 +139,6 @@ void AppConfig::saveSettings()
|
||||
settings().setValue("logToFile", m_LogToFile);
|
||||
settings().setValue("logFilename", m_LogFilename);
|
||||
settings().setValue("wizardLastRun", kWizardVersion);
|
||||
settings().setValue("cryptoPass", m_CryptoPass);
|
||||
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
||||
settings().setValue("language", m_Language);
|
||||
settings().setValue("startedBefore", m_StartedBefore);
|
||||
settings().setValue("autoConfig", m_AutoConfig);
|
||||
@ -154,22 +149,6 @@ void AppConfig::saveSettings()
|
||||
settings().setValue("userToken", m_UserToken);
|
||||
}
|
||||
|
||||
void AppConfig::setCryptoPass(const QString &s)
|
||||
{
|
||||
// clear field to user doesn't get confused.
|
||||
if (s.isEmpty())
|
||||
{
|
||||
m_CryptoPass.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// only hash if password changes -- don't re-hash the hash.
|
||||
if (m_CryptoPass != s)
|
||||
{
|
||||
m_CryptoPass = hash(s);
|
||||
}
|
||||
}
|
||||
|
||||
void AppConfig::setAutoConfig(bool autoConfig)
|
||||
{
|
||||
m_AutoConfig = autoConfig;
|
||||
|
@ -61,9 +61,6 @@ class AppConfig
|
||||
const QString& logFilename() const { return m_LogFilename; }
|
||||
const QString logFilenameCmd() const;
|
||||
QString logLevelText() const;
|
||||
const QString& cryptoPass() const { return m_CryptoPass; }
|
||||
bool cryptoEnabled() const { return m_CryptoEnabled; }
|
||||
QString cryptoModeString() const;
|
||||
ProcessMode processMode() const { return m_ProcessMode; }
|
||||
bool wizardShouldRun() const { return m_WizardLastRun < kWizardVersion; }
|
||||
const QString& language() const { return m_Language; }
|
||||
@ -96,7 +93,6 @@ class AppConfig
|
||||
void setLogLevel(int i) { m_LogLevel = i; }
|
||||
void setLogToFile(bool b) { m_LogToFile = b; }
|
||||
void setLogFilename(const QString& s) { m_LogFilename = s; }
|
||||
void setCryptoEnabled(bool b) { m_CryptoEnabled = b; }
|
||||
void setWizardHasRun() { m_WizardLastRun = kWizardVersion; }
|
||||
void setLanguage(const QString language) { m_Language = language; }
|
||||
void setStartedBefore(bool b) { m_StartedBefore = b; }
|
||||
@ -105,8 +101,6 @@ class AppConfig
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
void setCryptoPass(const QString& s);
|
||||
|
||||
private:
|
||||
QSettings* m_pSettings;
|
||||
QString m_ScreenName;
|
||||
@ -116,8 +110,6 @@ class AppConfig
|
||||
bool m_LogToFile;
|
||||
QString m_LogFilename;
|
||||
int m_WizardLastRun;
|
||||
bool m_CryptoEnabled;
|
||||
QString m_CryptoPass;
|
||||
ProcessMode m_ProcessMode;
|
||||
QString m_Language;
|
||||
bool m_StartedBefore;
|
||||
|
@ -418,11 +418,6 @@ void MainWindow::startSynergy()
|
||||
|
||||
args << "--name" << getScreenName();
|
||||
|
||||
if (appConfig().cryptoEnabled())
|
||||
{
|
||||
args << "--crypto-pass" << appConfig().cryptoPass();
|
||||
}
|
||||
|
||||
if (desktopMode)
|
||||
{
|
||||
setSynergyProcess(new QProcess(this));
|
||||
|
@ -43,12 +43,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
m_pComboLogLevel->setCurrentIndex(appConfig().logLevel());
|
||||
m_pCheckBoxLogToFile->setChecked(appConfig().logToFile());
|
||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||
m_pCheckBoxEnableCrypto->setChecked(appConfig().cryptoEnabled());
|
||||
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
||||
if (appConfig().cryptoEnabled())
|
||||
{
|
||||
m_pLineEditCryptoPass->setText(appConfig().cryptoPass());
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
m_SuppressElevateWarning = true;
|
||||
@ -62,26 +57,12 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
const QString& cryptoPass = m_pLineEditCryptoPass->text();
|
||||
bool cryptoEnabled = m_pCheckBoxEnableCrypto->isChecked();
|
||||
if (cryptoEnabled && cryptoPass.isEmpty())
|
||||
{
|
||||
QMessageBox message;
|
||||
message.setWindowTitle("Settings");
|
||||
message.setIcon(QMessageBox::Information);
|
||||
message.setText(tr("Encryption password must not be empty."));
|
||||
message.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
||||
appConfig().setPort(m_pSpinBoxPort->value());
|
||||
appConfig().setInterface(m_pLineEditInterface->text());
|
||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
appConfig().setCryptoEnabled(cryptoEnabled);
|
||||
appConfig().setCryptoPass(cryptoPass);
|
||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||
appConfig().setElevateMode(m_pCheckBoxElevateMode->isChecked());
|
||||
appConfig().saveSettings();
|
||||
@ -141,13 +122,6 @@ void SettingsDialog::on_m_pButtonBrowseLog_clicked()
|
||||
|
||||
void SettingsDialog::on_m_pCheckBoxEnableCrypto_stateChanged(int )
|
||||
{
|
||||
bool cryptoEnabled = m_pCheckBoxEnableCrypto->isChecked();
|
||||
m_pLineEditCryptoPass->setEnabled(cryptoEnabled);
|
||||
|
||||
if (!cryptoEnabled)
|
||||
{
|
||||
m_pLineEditCryptoPass->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "synergy/FileChunker.h"
|
||||
#include "synergy/IPlatformScreen.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "io/CryptoStream.h"
|
||||
#include "net/TCPSocket.h"
|
||||
#include "net/IDataSocket.h"
|
||||
#include "net/ISocketFactory.h"
|
||||
@ -61,7 +60,6 @@ Client::Client(
|
||||
const String& name, const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
synergy::Screen* screen,
|
||||
const CryptoOptions& crypto,
|
||||
bool enableDragDrop) :
|
||||
m_mock(false),
|
||||
m_name(name),
|
||||
@ -76,8 +74,6 @@ Client::Client(
|
||||
m_suspended(false),
|
||||
m_connectOnResume(false),
|
||||
m_events(events),
|
||||
m_cryptoStream(NULL),
|
||||
m_crypto(crypto),
|
||||
m_sendFileThread(NULL),
|
||||
m_writeToDropDirThread(NULL),
|
||||
m_enableDragDrop(enableDragDrop),
|
||||
@ -165,12 +161,6 @@ Client::connect()
|
||||
bool adopt = !m_useSecureNetwork;
|
||||
m_stream = new PacketStreamFilter(m_events, m_stream, adopt);
|
||||
|
||||
if (m_crypto.m_mode != kDisabled) {
|
||||
m_cryptoStream = new CryptoStream(
|
||||
m_events, m_stream, m_crypto, true);
|
||||
m_stream = m_cryptoStream;
|
||||
}
|
||||
|
||||
// connect
|
||||
LOG((CLOG_DEBUG1 "connecting to server"));
|
||||
setupConnecting();
|
||||
@ -211,14 +201,6 @@ Client::handshakeComplete()
|
||||
sendEvent(m_events->forClient().connected(), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
Client::setDecryptIv(const UInt8* iv)
|
||||
{
|
||||
if (m_cryptoStream != NULL) {
|
||||
m_cryptoStream->setDecryptIv(iv);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Client::isConnected() const
|
||||
{
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "synergy/DragInformation.h"
|
||||
#include "synergy/INode.h"
|
||||
#include "net/NetworkAddress.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "base/EventTypes.h"
|
||||
|
||||
class EventQueueTimer;
|
||||
@ -34,7 +33,6 @@ class IDataSocket;
|
||||
class ISocketFactory;
|
||||
namespace synergy { class IStream; }
|
||||
class IEventQueue;
|
||||
class CryptoStream;
|
||||
class Thread;
|
||||
class TCPSocket;
|
||||
|
||||
@ -61,7 +59,6 @@ public:
|
||||
const String& name, const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
synergy::Screen* screen,
|
||||
const CryptoOptions& crypto,
|
||||
bool enableDragDrop);
|
||||
~Client();
|
||||
|
||||
@ -91,9 +88,6 @@ public:
|
||||
*/
|
||||
virtual void handshakeComplete();
|
||||
|
||||
//! Set crypto IV for decryption
|
||||
virtual void setDecryptIv(const UInt8* iv);
|
||||
|
||||
//! Clears the file buffer
|
||||
void clearReceivedFileData();
|
||||
|
||||
@ -223,8 +217,6 @@ private:
|
||||
IClipboard::Time m_timeClipboard[kClipboardEnd];
|
||||
String m_dataClipboard[kClipboardEnd];
|
||||
IEventQueue* m_events;
|
||||
CryptoStream* m_cryptoStream;
|
||||
CryptoOptions m_crypto;
|
||||
std::size_t m_expectedFileSize;
|
||||
String m_receivedFileData;
|
||||
DragFileList m_dragFileList;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "synergy/option_types.h"
|
||||
#include "synergy/protocol_types.h"
|
||||
#include "io/IStream.h"
|
||||
#include "io/CryptoStream.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
@ -295,10 +294,6 @@ ServerProxy::parseMessage(const UInt8* code)
|
||||
setOptions();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDCryptoIv, 4) == 0) {
|
||||
cryptoIv();
|
||||
}
|
||||
|
||||
else if (memcmp(code, kMsgDFileTransfer, 4) == 0) {
|
||||
fileChunkReceived();
|
||||
}
|
||||
@ -763,18 +758,6 @@ ServerProxy::mouseWheel()
|
||||
m_client->mouseWheel(xDelta, yDelta);
|
||||
}
|
||||
|
||||
void
|
||||
ServerProxy::cryptoIv()
|
||||
{
|
||||
// parse
|
||||
String s;
|
||||
ProtocolUtil::readf(m_stream, kMsgDCryptoIv + 4, &s);
|
||||
LOG((CLOG_DEBUG2 "recv crypto iv size=%i", s.size()));
|
||||
|
||||
// forward
|
||||
m_client->setDecryptIv(reinterpret_cast<const UInt8*>(s.c_str()));
|
||||
}
|
||||
|
||||
void
|
||||
ServerProxy::screensaver()
|
||||
{
|
||||
|
@ -99,7 +99,6 @@ private:
|
||||
void mouseMove();
|
||||
void mouseRelativeMove();
|
||||
void mouseWheel();
|
||||
void cryptoIv();
|
||||
void screensaver();
|
||||
void resetOptions();
|
||||
void setOptions();
|
||||
|
@ -23,7 +23,6 @@ endif()
|
||||
|
||||
include_directories(
|
||||
../
|
||||
../../../ext
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
@ -33,7 +32,3 @@ if (UNIX)
|
||||
endif()
|
||||
|
||||
add_library(io STATIC ${sources})
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries(io cryptopp)
|
||||
endif()
|
||||
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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/>.
|
||||
*/
|
||||
|
||||
#include "io/CryptoMode.h"
|
||||
|
||||
#include "io/XIO.h"
|
||||
|
||||
using namespace CryptoPP;
|
||||
|
||||
CryptoMode::CryptoMode(ECryptoMode mode, bool encryption) :
|
||||
m_mode(mode),
|
||||
m_crypto(NULL),
|
||||
m_encryption(encryption)
|
||||
{
|
||||
if (m_encryption) {
|
||||
switch (m_mode) {
|
||||
case kCfb:
|
||||
m_crypto = new CfbModeEnc;
|
||||
break;
|
||||
|
||||
case kDisabled:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw XIOBadCryptoMode();
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (m_mode) {
|
||||
case kCfb:
|
||||
m_crypto = new CfbModeDec;
|
||||
break;
|
||||
|
||||
case kDisabled:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw XIOBadCryptoMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CryptoMode::~CryptoMode()
|
||||
{
|
||||
if (m_crypto == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_encryption) {
|
||||
delete reinterpret_cast<CfbModeEnc*>(m_crypto);
|
||||
}
|
||||
else {
|
||||
delete reinterpret_cast<CfbModeDec*>(m_crypto);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CryptoMode::processData(byte* out, const byte* in, size_t length)
|
||||
{
|
||||
if (m_crypto == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_encryption) {
|
||||
reinterpret_cast<CfbModeEnc*>(m_crypto)->ProcessData(out, in, length);
|
||||
}
|
||||
else {
|
||||
reinterpret_cast<CfbModeDec*>(m_crypto)->ProcessData(out, in, length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CryptoMode::setKeyWithIv(const byte* key, size_t length, const byte* iv)
|
||||
{
|
||||
if (m_crypto == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_encryption) {
|
||||
reinterpret_cast<CfbModeEnc*>(m_crypto)->SetKeyWithIV(key, length, iv);
|
||||
}
|
||||
else {
|
||||
reinterpret_cast<CfbModeDec*>(m_crypto)->SetKeyWithIV(key, length, iv);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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
|
||||
|
||||
#include "io/ECryptoMode.h"
|
||||
|
||||
#include "io/CryptoMode_cryptopp.h"
|
||||
#include "base/String.h"
|
||||
|
||||
//! Encapsulation of modes
|
||||
/*!
|
||||
Polymorphism is tricky in Crypto++, so we encapsulate all crypto modes
|
||||
and switch based on an enum for ctor, dtor and all functions.
|
||||
*/
|
||||
class CryptoMode {
|
||||
public:
|
||||
CryptoMode(ECryptoMode mode, bool encryption = true);
|
||||
~CryptoMode();
|
||||
|
||||
//! Encrypt or decrypt data
|
||||
void processData(byte* out, const byte* in, size_t length);
|
||||
|
||||
//! Variable length key and initialization vector
|
||||
void setKeyWithIv(const byte* key, size_t length, const byte* iv);
|
||||
|
||||
private:
|
||||
typedef CryptoPP::OFB_Mode<CryptoPP::AES>::Encryption OfbModeEnc;
|
||||
typedef CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption CfbModeEnc;
|
||||
typedef CryptoPP::CTR_Mode<CryptoPP::AES>::Encryption CtrModeEnc;
|
||||
typedef CryptoPP::GCM<CryptoPP::AES>::Encryption GcmModeEnc;
|
||||
|
||||
typedef CryptoPP::OFB_Mode<CryptoPP::AES>::Decryption OfbModeDec;
|
||||
typedef CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption CfbModeDec;
|
||||
typedef CryptoPP::CTR_Mode<CryptoPP::AES>::Decryption CtrModeDec;
|
||||
typedef CryptoPP::GCM<CryptoPP::AES>::Decryption GcmModeDec;
|
||||
|
||||
static ECryptoMode parseMode(String& mode);
|
||||
|
||||
ECryptoMode m_mode;
|
||||
void* m_crypto;
|
||||
bool m_encryption;
|
||||
};
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2014 Synergy Si 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
|
||||
|
||||
// HACK: gcc on osx106 doesn't give you an easy way to hide warnings
|
||||
// from included headers, so use the system_header pragma. the downside
|
||||
// is that everything in the header file following this also has warnings
|
||||
// ignored, so we need to put it in a separate header file (this file).
|
||||
#if __APPLE__
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <cryptopp562/gcm.h>
|
||||
#include <cryptopp562/modes.h>
|
||||
#include <cryptopp562/aes.h>
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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/>.
|
||||
*/
|
||||
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "io/XIO.h"
|
||||
|
||||
CryptoOptions::CryptoOptions(
|
||||
const String& modeString,
|
||||
const String& pass) :
|
||||
m_pass(pass),
|
||||
m_mode(parseMode(modeString))
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CryptoOptions::setMode(String modeString)
|
||||
{
|
||||
m_modeString = modeString;
|
||||
m_mode = parseMode(modeString);
|
||||
}
|
||||
|
||||
ECryptoMode
|
||||
CryptoOptions::parseMode(String modeString)
|
||||
{
|
||||
if (modeString == "cfb") {
|
||||
return kCfb;
|
||||
}
|
||||
else {
|
||||
throw XIOBadCryptoMode();
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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
|
||||
|
||||
#include "base/String.h"
|
||||
#include "io/ECryptoMode.h"
|
||||
|
||||
//! Encapsulates basic crypto options
|
||||
class CryptoOptions {
|
||||
public:
|
||||
CryptoOptions() : m_mode(kDisabled) { }
|
||||
CryptoOptions(const String& modeString, const String& pass);
|
||||
|
||||
//! Return enum for mode string
|
||||
static ECryptoMode parseMode(String modeString);
|
||||
|
||||
//! Parse and set mode string
|
||||
void setMode(String modeString);
|
||||
|
||||
String m_pass;
|
||||
ECryptoMode m_mode;
|
||||
String m_modeString;
|
||||
};
|
@ -1,155 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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/>.
|
||||
*/
|
||||
|
||||
#include "io/CryptoStream.h"
|
||||
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "base/Log.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace CryptoPP;
|
||||
using namespace synergy::crypto;
|
||||
|
||||
CryptoStream::CryptoStream(
|
||||
IEventQueue* events,
|
||||
synergy::IStream* stream,
|
||||
const CryptoOptions& options,
|
||||
bool adoptStream) :
|
||||
StreamFilter(events, stream, adoptStream),
|
||||
m_key(NULL),
|
||||
m_encryption(options.m_mode, true),
|
||||
m_decryption(options.m_mode, false)
|
||||
{
|
||||
LOG((CLOG_INFO "crypto mode: %s", options.m_modeString.c_str()));
|
||||
|
||||
m_key = new byte[kKeyLength];
|
||||
if (!options.m_pass.empty()) {
|
||||
createKey(m_key, options.m_pass, kKeyLength, static_cast<UInt8>(options.m_pass.length()));
|
||||
|
||||
byte iv[CRYPTO_IV_SIZE];
|
||||
createKey(iv, options.m_pass, CRYPTO_IV_SIZE, static_cast<UInt8>(options.m_pass.length()) * 2);
|
||||
setEncryptIv(iv);
|
||||
setDecryptIv(iv);
|
||||
}
|
||||
}
|
||||
|
||||
CryptoStream::~CryptoStream()
|
||||
{
|
||||
delete[] m_key;
|
||||
}
|
||||
|
||||
UInt32
|
||||
CryptoStream::read(void* out, UInt32 n)
|
||||
{
|
||||
assert(m_key != NULL);
|
||||
LOG((CLOG_DEBUG4 "crypto: read %i (decrypt)", n));
|
||||
|
||||
byte* cypher = new byte[n];
|
||||
size_t result = getStream()->read(cypher, n);
|
||||
if (result == 0) {
|
||||
// nothing to read.
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (result != n) {
|
||||
LOG((CLOG_ERR "crypto: decrypt failed, only %i of %i bytes", result, n));
|
||||
return 0;
|
||||
}
|
||||
|
||||
logBuffer("cypher", cypher, n);
|
||||
m_decryption.processData(static_cast<byte*>(out), cypher, n);
|
||||
logBuffer("plaintext", static_cast<byte*>(out), n);
|
||||
delete[] cypher;
|
||||
return static_cast<UInt32>(result);
|
||||
}
|
||||
|
||||
void
|
||||
CryptoStream::write(const void* in, UInt32 n)
|
||||
{
|
||||
assert(m_key != NULL);
|
||||
LOG((CLOG_DEBUG4 "crypto: write %i (encrypt)", n));
|
||||
|
||||
logBuffer("plaintext", static_cast<byte*>(const_cast<void*>(in)), n);
|
||||
byte* cypher = new byte[n];
|
||||
m_encryption.processData(cypher, static_cast<const byte*>(in), n);
|
||||
logBuffer("cypher", cypher, n);
|
||||
getStream()->write(cypher, n);
|
||||
delete[] cypher;
|
||||
}
|
||||
|
||||
void
|
||||
CryptoStream::createKey(byte* out, const String& password, UInt8 keyLength, UInt8 hashCount)
|
||||
{
|
||||
assert(keyLength <= SHA256::DIGESTSIZE);
|
||||
|
||||
byte temp[SHA256::DIGESTSIZE];
|
||||
byte* in = reinterpret_cast<byte*>(const_cast<char*>(password.c_str()));
|
||||
SHA256().CalculateDigest(temp, in, password.length());
|
||||
|
||||
byte* tempKey = new byte[SHA256::DIGESTSIZE];
|
||||
for (int i = 0; i < hashCount; ++i) {
|
||||
memcpy(tempKey, temp, SHA256::DIGESTSIZE);
|
||||
SHA256().CalculateDigest(temp, tempKey, SHA256::DIGESTSIZE);
|
||||
}
|
||||
delete[] tempKey;
|
||||
|
||||
memcpy(out, temp, keyLength);
|
||||
}
|
||||
|
||||
void
|
||||
CryptoStream::setEncryptIv(const byte* iv)
|
||||
{
|
||||
assert(m_key != NULL);
|
||||
logBuffer("encrypt iv", iv, CRYPTO_IV_SIZE);
|
||||
m_encryption.setKeyWithIv(m_key, kKeyLength, iv);
|
||||
}
|
||||
|
||||
void
|
||||
CryptoStream::setDecryptIv(const byte* iv)
|
||||
{
|
||||
assert(m_key != NULL);
|
||||
logBuffer("decrypt iv", iv, CRYPTO_IV_SIZE);
|
||||
m_decryption.setKeyWithIv(m_key, kKeyLength, iv);
|
||||
}
|
||||
|
||||
void
|
||||
CryptoStream::newIv(byte* out)
|
||||
{
|
||||
m_autoSeedRandomPool.GenerateBlock(out, CRYPTO_IV_SIZE);
|
||||
}
|
||||
|
||||
void
|
||||
CryptoStream::logBuffer(const char* name, const byte* buf, int length)
|
||||
{
|
||||
if (CLOG->getFilter() < kDEBUG4) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "crypto: " << name << ":";
|
||||
|
||||
char buffer[4];
|
||||
for (int i = 0; i < length; i++) {
|
||||
sprintf(buffer, " %02X", buf[i]);
|
||||
ss << buffer;
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG4 "%s", ss.str().c_str()));
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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
|
||||
|
||||
#include "io/StreamFilter.h"
|
||||
#include "io/CryptoMode.h"
|
||||
#include "io/CryptoStream_cryptopp.h"
|
||||
#include "base/EventTypes.h"
|
||||
|
||||
class CryptoOptions;
|
||||
|
||||
#define CRYPTO_IV_SIZE CryptoPP::AES::BLOCKSIZE
|
||||
|
||||
//! Bidirectional encrypted stream
|
||||
/*!
|
||||
Encrypts (on write) and decrypts (on read) to and from an underlying stream.
|
||||
*/
|
||||
class CryptoStream : public StreamFilter {
|
||||
public:
|
||||
CryptoStream(IEventQueue* events, synergy::IStream* stream, const CryptoOptions& options, bool adoptStream = true);
|
||||
virtual ~CryptoStream();
|
||||
|
||||
//! @name manipulators
|
||||
//@{
|
||||
|
||||
//! Read from stream
|
||||
/*!
|
||||
Read up to \p n bytes into \p buffer to the stream using encryption.
|
||||
Returns the number of bytes read by the underlying stream.
|
||||
*/
|
||||
virtual UInt32 read(void* out, UInt32 n);
|
||||
|
||||
//! Write to stream
|
||||
/*!
|
||||
Write \c n bytes from \c buffer to the stream using encryption.
|
||||
*/
|
||||
virtual void write(const void* in, UInt32 n);
|
||||
|
||||
//! Set the IV for encryption
|
||||
void setEncryptIv(const byte* iv);
|
||||
|
||||
//! Set the IV for decryption
|
||||
void setDecryptIv(const byte* iv);
|
||||
|
||||
//! Get a new IV
|
||||
/*!
|
||||
Writes a new IV to the \c out buffer, and also uses the IV for further
|
||||
crypto.
|
||||
*/
|
||||
void newIv(byte* out);
|
||||
|
||||
//! Creates a key from a password
|
||||
static void createKey(byte* out, const String& password, UInt8 keyLength, UInt8 hashCount);
|
||||
|
||||
private:
|
||||
void logBuffer(const char* name, const byte* buf, int length);
|
||||
|
||||
byte* m_key;
|
||||
CryptoMode m_encryption;
|
||||
CryptoMode m_decryption;
|
||||
CryptoPP::AutoSeededRandomPool m_autoSeedRandomPool;
|
||||
};
|
||||
|
||||
namespace synergy {
|
||||
namespace crypto {
|
||||
|
||||
const UInt32 kKeyLength = 32;
|
||||
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2014 Synergy Si 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
|
||||
|
||||
// HACK: gcc on osx106 doesn't give you an easy way to hide warnings
|
||||
// from included headers, so use the system_header pragma. the downside
|
||||
// is that everything in the header file following this also has warnings
|
||||
// ignored, so we need to put it in a separate header file (this file).
|
||||
#if __APPLE__
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <cryptopp562/osrng.h>
|
||||
#include <cryptopp562/sha.h>
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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 ECryptoMode {
|
||||
kDisabled,
|
||||
kCfb,
|
||||
kNumOfModes
|
||||
};
|
@ -49,13 +49,3 @@ XIOWouldBlock::getWhat() const throw()
|
||||
{
|
||||
return format("XIOWouldBlock", "stream operation would block");
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XBadCryptoMode
|
||||
//
|
||||
String
|
||||
XIOBadCryptoMode::getWhat() const throw()
|
||||
{
|
||||
return "XBadCryptoMode";
|
||||
}
|
||||
|
@ -47,9 +47,3 @@ XBASE_SUBCLASS_WHAT(XIOEndOfStream, XIO);
|
||||
Thrown if an operation on a stream would block.
|
||||
*/
|
||||
XBASE_SUBCLASS_WHAT(XIOWouldBlock, XIO);
|
||||
|
||||
//! I/O bad crypto mode exception
|
||||
/*!
|
||||
Thrown when the user enters an invalid crypto mode.
|
||||
*/
|
||||
XBASE_SUBCLASS_WHAT(XIOBadCryptoMode, XIO);
|
||||
|
@ -55,7 +55,7 @@ if (UNIX)
|
||||
endif()
|
||||
|
||||
target_link_libraries(ns
|
||||
arch base client common io mt net ipc platform server synergy cryptopp ${libs} ${OPENSSL_LIBS})
|
||||
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
|
||||
|
||||
if (WIN32)
|
||||
add_custom_command(
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "net/IListenSocket.h"
|
||||
#include "net/ISocketFactory.h"
|
||||
#include "net/XSocket.h"
|
||||
#include "io/CryptoStream.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
@ -43,11 +41,9 @@ static const char s_networkSecurity[] = { "libns" };
|
||||
|
||||
ClientListener::ClientListener(const NetworkAddress& address,
|
||||
ISocketFactory* socketFactory,
|
||||
const CryptoOptions& crypto,
|
||||
IEventQueue* events) :
|
||||
m_socketFactory(socketFactory),
|
||||
m_server(NULL),
|
||||
m_crypto(crypto),
|
||||
m_events(events)
|
||||
{
|
||||
assert(m_socketFactory != NULL);
|
||||
@ -149,12 +145,6 @@ ClientListener::handleClientConnecting(const Event&, void*)
|
||||
// filter socket messages, including a packetizing filter
|
||||
bool adopt = !m_useSecureNetwork;
|
||||
stream = new PacketStreamFilter(m_events, stream, adopt);
|
||||
|
||||
if (m_crypto.m_mode != kDisabled) {
|
||||
CryptoStream* cryptoStream = new CryptoStream(
|
||||
m_events, stream, m_crypto, true);
|
||||
stream = cryptoStream;
|
||||
}
|
||||
|
||||
assert(m_server != NULL);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "server/Config.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "base/EventTypes.h"
|
||||
#include "base/Event.h"
|
||||
#include "common/stddeque.h"
|
||||
@ -38,7 +37,6 @@ public:
|
||||
// The factories are adopted.
|
||||
ClientListener(const NetworkAddress&,
|
||||
ISocketFactory*,
|
||||
const CryptoOptions& crypto,
|
||||
IEventQueue* events);
|
||||
~ClientListener();
|
||||
|
||||
@ -84,7 +82,6 @@ private:
|
||||
NewClients m_newClients;
|
||||
WaitingClients m_waitingClients;
|
||||
Server* m_server;
|
||||
CryptoOptions m_crypto;
|
||||
IEventQueue* m_events;
|
||||
bool m_useSecureNetwork;
|
||||
};
|
||||
|
@ -49,8 +49,7 @@ public:
|
||||
|
||||
//! Get stream
|
||||
/*!
|
||||
Returns a crypto stream if the user has this enabled,
|
||||
otherwise returns the original stream passed to the c'tor.
|
||||
Returns the original stream passed to the c'tor.
|
||||
*/
|
||||
synergy::IStream* getStream() const;
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "server/Server.h"
|
||||
#include "synergy/ProtocolUtil.h"
|
||||
#include "io/CryptoStream.h"
|
||||
#include "base/Log.h"
|
||||
#include "base/IEventQueue.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
@ -45,47 +44,23 @@ ClientProxy1_4::~ClientProxy1_4()
|
||||
void
|
||||
ClientProxy1_4::keyDown(KeyID key, KeyModifierMask mask, KeyButton button)
|
||||
{
|
||||
cryptoIv();
|
||||
ClientProxy1_3::keyDown(key, mask, button);
|
||||
}
|
||||
|
||||
void
|
||||
ClientProxy1_4::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button)
|
||||
{
|
||||
cryptoIv();
|
||||
ClientProxy1_3::keyRepeat(key, mask, count, button);
|
||||
}
|
||||
|
||||
void
|
||||
ClientProxy1_4::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
|
||||
{
|
||||
cryptoIv();
|
||||
ClientProxy1_3::keyUp(key, mask, button);
|
||||
}
|
||||
|
||||
void
|
||||
ClientProxy1_4::keepAlive()
|
||||
{
|
||||
cryptoIv();
|
||||
ClientProxy1_3::keepAlive();
|
||||
}
|
||||
|
||||
void
|
||||
ClientProxy1_4::cryptoIv()
|
||||
{
|
||||
CryptoStream* cryptoStream = dynamic_cast<CryptoStream*>(getStream());
|
||||
if (cryptoStream == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
byte iv[CRYPTO_IV_SIZE];
|
||||
cryptoStream->newIv(iv);
|
||||
String data(reinterpret_cast<const char*>(iv), CRYPTO_IV_SIZE);
|
||||
|
||||
LOG((CLOG_DEBUG2 "send crypto iv change to \"%s\"", getName().c_str()));
|
||||
ProtocolUtil::writef(getStream(), kMsgDCryptoIv, &data);
|
||||
|
||||
// change IV only after we've sent the current IV, otherwise
|
||||
// the client won't be able to decrypt the new IV.
|
||||
cryptoStream->setEncryptIv(iv);
|
||||
}
|
||||
|
@ -42,8 +42,5 @@ public:
|
||||
virtual void keyUp(KeyID key, KeyModifierMask mask, KeyButton button);
|
||||
virtual void keepAlive();
|
||||
|
||||
//! Send IV to make
|
||||
void cryptoIv();
|
||||
|
||||
Server* m_server;
|
||||
};
|
||||
|
@ -163,7 +163,6 @@ private:
|
||||
"* --restart restart the server automatically if it fails.\n" \
|
||||
" -l --log <file> write log messages to file.\n" \
|
||||
" --no-tray disable the system tray icon.\n" \
|
||||
" --crypto-pass <pass> enable encryption, using the given password.\n" \
|
||||
" --enable-drag-drop enable file drag & drop.\n"
|
||||
|
||||
#define HELP_COMMON_INFO_2 \
|
||||
|
@ -245,10 +245,6 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i)
|
||||
else if (isArg(i, argc, argv, NULL, "--client")) {
|
||||
// HACK: stop error happening when using portable (synergyp)
|
||||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--crypto-pass")) {
|
||||
argsBase().m_crypto.m_pass = argv[++i];
|
||||
argsBase().m_crypto.setMode("cfb");
|
||||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--enable-drag-drop")) {
|
||||
bool useDragDrop = true;
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/String.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
|
||||
class ArgsBase {
|
||||
public:
|
||||
@ -36,7 +35,6 @@ public:
|
||||
String m_name;
|
||||
bool m_disableTray;
|
||||
bool m_enableIpc;
|
||||
CryptoOptions m_crypto;
|
||||
bool m_enableDragDrop;
|
||||
#if SYSAPI_WIN32
|
||||
bool m_debugServiceWait;
|
||||
|
@ -334,7 +334,7 @@ ClientApp::handleClientDisconnected(const Event&, void*)
|
||||
|
||||
Client*
|
||||
ClientApp::openClient(const String& name, const NetworkAddress& address,
|
||||
synergy::Screen* screen, const CryptoOptions& crypto)
|
||||
synergy::Screen* screen)
|
||||
{
|
||||
Client* client = new Client(
|
||||
m_events,
|
||||
@ -342,7 +342,6 @@ ClientApp::openClient(const String& name, const NetworkAddress& address,
|
||||
address,
|
||||
new TCPSocketFactory(m_events, getSocketMultiplexer()),
|
||||
screen,
|
||||
crypto,
|
||||
args().m_enableDragDrop);
|
||||
|
||||
try {
|
||||
@ -401,7 +400,7 @@ ClientApp::startClient()
|
||||
if (m_clientScreen == NULL) {
|
||||
clientScreen = openClientScreen();
|
||||
m_client = openClient(args().m_name,
|
||||
*m_serverAddress, clientScreen, args().m_crypto);
|
||||
*m_serverAddress, clientScreen);
|
||||
m_clientScreen = clientScreen;
|
||||
LOG((CLOG_NOTE "started client"));
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ class Client;
|
||||
class NetworkAddress;
|
||||
class Thread;
|
||||
class ClientArgs;
|
||||
class CryptoOptions;
|
||||
|
||||
class ClientApp : public App {
|
||||
public:
|
||||
@ -66,7 +65,7 @@ public:
|
||||
void handleClientFailed(const Event& e, void*);
|
||||
void handleClientDisconnected(const Event&, void*);
|
||||
Client* openClient(const String& name, const NetworkAddress& address,
|
||||
synergy::Screen* screen, const CryptoOptions& crypto);
|
||||
synergy::Screen* screen);
|
||||
void closeClient(Client* client);
|
||||
bool startClient();
|
||||
void stopClient();
|
||||
|
@ -632,9 +632,7 @@ ServerApp::openClientListener(const NetworkAddress& address)
|
||||
{
|
||||
ClientListener* listen = new ClientListener(
|
||||
address,
|
||||
new TCPSocketFactory(m_events, getSocketMultiplexer()),
|
||||
args().m_crypto,
|
||||
m_events);
|
||||
new TCPSocketFactory(m_events, getSocketMultiplexer()), m_events);
|
||||
|
||||
m_events->adoptHandler(
|
||||
m_events->forClientListener().connected(), listen,
|
||||
|
@ -44,7 +44,6 @@ const char* kMsgDMouseWheel1_0 = "DMWM%2i";
|
||||
const char* kMsgDClipboard = "DCLP%1i%4i%s";
|
||||
const char* kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i";
|
||||
const char* kMsgDSetOptions = "DSOP%4I";
|
||||
const char* kMsgDCryptoIv = "DCIV%s";
|
||||
const char* kMsgDFileTransfer = "DFTR%1i%s";
|
||||
const char* kMsgDDragInfo = "DDRG%2i%s";
|
||||
const char* kMsgQInfo = "QINF";
|
||||
|
@ -27,6 +27,7 @@
|
||||
// 1.3: adds keep alive and deprecates heartbeats,
|
||||
// adds horizontal mouse scrolling
|
||||
// 1.4: adds crypto support
|
||||
// 1.5: adds file transfer and removes home brew crypto
|
||||
// NOTE: with new version, synergy minor version should increment
|
||||
static const SInt16 kProtocolMajorVersion = 1;
|
||||
static const SInt16 kProtocolMinorVersion = 5;
|
||||
@ -251,11 +252,6 @@ extern const char* kMsgDInfo;
|
||||
// pairs.
|
||||
extern const char* kMsgDSetOptions;
|
||||
|
||||
// crypto iv: primary -> secondary
|
||||
// sends a new iv (initialization vector) to the client for the
|
||||
// cryptography stream.
|
||||
extern const char* kMsgDCryptoIv;
|
||||
|
||||
// file data: primary <-> secondary
|
||||
// transfer file data. A mark is used in the first byte.
|
||||
// 0 means the content followed is the file size.
|
||||
|
@ -236,7 +236,7 @@ static
|
||||
bool
|
||||
doKeyboardHookHandler(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
DWORD vkCode = wParam;
|
||||
DWORD vkCode = static_cast<DWORD>(wParam);
|
||||
bool kf_up = (lParam & (KF_UP << 16)) != 0;
|
||||
|
||||
// check for special events indicating if we should start or stop
|
||||
|
@ -68,4 +68,4 @@ endif()
|
||||
|
||||
add_executable(integtests ${sources})
|
||||
target_link_libraries(integtests
|
||||
arch base client common io ipc mt net platform server synergy gtest gmock cryptopp ${libs})
|
||||
arch base client common io ipc mt net platform server synergy gtest gmock ${libs})
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "net/SocketMultiplexer.h"
|
||||
#include "net/NetworkAddress.h"
|
||||
#include "net/TCPSocketFactory.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
#include "mt/Thread.h"
|
||||
#include "base/TMethodEventJob.h"
|
||||
#include "base/TMethodJob.h"
|
||||
@ -109,14 +108,13 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
||||
{
|
||||
// server and client
|
||||
NetworkAddress serverAddress(TEST_HOST, TEST_PORT);
|
||||
CryptoOptions cryptoOptions;
|
||||
|
||||
|
||||
serverAddress.resolve();
|
||||
|
||||
// server
|
||||
SocketMultiplexer serverSocketMultiplexer;
|
||||
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, cryptoOptions, &m_events);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, &m_events);
|
||||
NiceMock<MockScreen> serverScreen;
|
||||
NiceMock<MockPrimaryClient> primaryClient;
|
||||
NiceMock<MockConfig> serverConfig;
|
||||
@ -142,7 +140,7 @@ TEST_F(NetworkTests, sendToClient_mockData)
|
||||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, cryptoOptions, true);
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
||||
@ -162,14 +160,13 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
||||
{
|
||||
// server and client
|
||||
NetworkAddress serverAddress(TEST_HOST, TEST_PORT);
|
||||
CryptoOptions cryptoOptions;
|
||||
|
||||
|
||||
serverAddress.resolve();
|
||||
|
||||
// server
|
||||
SocketMultiplexer serverSocketMultiplexer;
|
||||
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, cryptoOptions, &m_events);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, &m_events);
|
||||
NiceMock<MockScreen> serverScreen;
|
||||
NiceMock<MockPrimaryClient> primaryClient;
|
||||
NiceMock<MockConfig> serverConfig;
|
||||
@ -195,7 +192,7 @@ TEST_F(NetworkTests, sendToClient_mockFile)
|
||||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, cryptoOptions, true);
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forIScreen().fileRecieveCompleted(), &client,
|
||||
@ -215,14 +212,12 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
||||
{
|
||||
// server and client
|
||||
NetworkAddress serverAddress(TEST_HOST, TEST_PORT);
|
||||
CryptoOptions cryptoOptions;
|
||||
|
||||
serverAddress.resolve();
|
||||
|
||||
// server
|
||||
SocketMultiplexer serverSocketMultiplexer;
|
||||
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, cryptoOptions, &m_events);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, &m_events);
|
||||
NiceMock<MockScreen> serverScreen;
|
||||
NiceMock<MockPrimaryClient> primaryClient;
|
||||
NiceMock<MockConfig> serverConfig;
|
||||
@ -243,7 +238,7 @@ TEST_F(NetworkTests, sendToServer_mockData)
|
||||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, cryptoOptions, true);
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forClientListener().connected(), &listener,
|
||||
@ -268,14 +263,13 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
||||
{
|
||||
// server and client
|
||||
NetworkAddress serverAddress(TEST_HOST, TEST_PORT);
|
||||
CryptoOptions cryptoOptions;
|
||||
|
||||
|
||||
serverAddress.resolve();
|
||||
|
||||
// server
|
||||
SocketMultiplexer serverSocketMultiplexer;
|
||||
TCPSocketFactory* serverSocketFactory = new TCPSocketFactory(&m_events, &serverSocketMultiplexer);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, cryptoOptions, &m_events);
|
||||
ClientListener listener(serverAddress, serverSocketFactory, &m_events);
|
||||
NiceMock<MockScreen> serverScreen;
|
||||
NiceMock<MockPrimaryClient> primaryClient;
|
||||
NiceMock<MockConfig> serverConfig;
|
||||
@ -296,7 +290,7 @@ TEST_F(NetworkTests, sendToServer_mockFile)
|
||||
ON_CALL(clientScreen, getShape(_, _, _, _)).WillByDefault(Invoke(getScreenShape));
|
||||
ON_CALL(clientScreen, getCursorPos(_, _)).WillByDefault(Invoke(getCursorPos));
|
||||
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, cryptoOptions, true);
|
||||
Client client(&m_events, "stub", serverAddress, clientSocketFactory, &clientScreen, true);
|
||||
|
||||
m_events.adoptHandler(
|
||||
m_events.forClientListener().connected(), &listener,
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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
|
||||
|
||||
#include "io/CryptoStream.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
|
||||
#include "test/global/gmock.h"
|
||||
|
||||
class MockCryptoStream : public CryptoStream
|
||||
{
|
||||
public:
|
||||
MockCryptoStream(IEventQueue* eventQueue, IStream* stream) :
|
||||
CryptoStream(eventQueue, stream, CryptoOptions("gcm", "stub"), false) { }
|
||||
MOCK_METHOD2(read, UInt32(void*, UInt32));
|
||||
MOCK_METHOD2(write, void(const void*, UInt32));
|
||||
};
|
@ -49,4 +49,4 @@ endif()
|
||||
|
||||
add_executable(unittests ${sources})
|
||||
target_link_libraries(unittests
|
||||
arch base client server common io net platform server synergy mt ipc gtest gmock cryptopp ${libs})
|
||||
arch base client server common io net platform server synergy mt ipc gtest gmock ${libs})
|
||||
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2012 Synergy Si Ltd.
|
||||
* Copyright (C) 2011 Nick Bolton
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#define TEST_ENV
|
||||
|
||||
#include "test/mock/client/MockClient.h"
|
||||
#include "test/mock/io/MockStream.h"
|
||||
#include "test/mock/synergy/MockEventQueue.h"
|
||||
#include "client/ServerProxy.h"
|
||||
#include "synergy/protocol_types.h"
|
||||
|
||||
#include "test/global/gtest.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::AnyNumber;
|
||||
using ::testing::ReturnRef;
|
||||
|
||||
const UInt8 g_mouseMove_bufferLen = 16;
|
||||
UInt8 g_mouseMove_buffer[g_mouseMove_bufferLen];
|
||||
UInt32 g_mouseMove_bufferIndex;
|
||||
UInt32 mouseMove_mockRead(void* buffer, UInt32 n);
|
||||
|
||||
const UInt8 g_readCryptoIv_bufferLen = 20;
|
||||
UInt8 g_readCryptoIv_buffer[g_readCryptoIv_bufferLen];
|
||||
UInt32 g_readCryptoIv_bufferIndex;
|
||||
String g_readCryptoIv_result;
|
||||
UInt32 readCryptoIv_mockRead(void* buffer, UInt32 n);
|
||||
void readCryptoIv_setDecryptIv(const UInt8*);
|
||||
|
||||
TEST(ServerProxyTests, mouseMove)
|
||||
{
|
||||
g_mouseMove_bufferIndex = 0;
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> stream;
|
||||
NiceMock<MockClient> client;
|
||||
IStreamEvents streamEvents;
|
||||
streamEvents.setEvents(&eventQueue);
|
||||
|
||||
ON_CALL(eventQueue, forIStream()).WillByDefault(ReturnRef(streamEvents));
|
||||
ON_CALL(stream, read(_, _)).WillByDefault(Invoke(mouseMove_mockRead));
|
||||
|
||||
EXPECT_CALL(client, mouseMove(1, 2)).Times(1);
|
||||
|
||||
const char data[] = "DSOP\0\0\0\0DMMV\0\1\0\2";
|
||||
memcpy(g_mouseMove_buffer, data, g_mouseMove_bufferLen);
|
||||
|
||||
ServerProxy serverProxy(&client, &stream, &eventQueue);
|
||||
serverProxy.handleDataForTest();
|
||||
}
|
||||
|
||||
TEST(ServerProxyTests, readCryptoIv)
|
||||
{
|
||||
g_readCryptoIv_bufferIndex = 0;
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockClient> client;
|
||||
NiceMock<MockStream> stream;
|
||||
IStreamEvents streamEvents;
|
||||
streamEvents.setEvents(&eventQueue);
|
||||
|
||||
ON_CALL(eventQueue, forIStream()).WillByDefault(ReturnRef(streamEvents));
|
||||
ON_CALL(stream, read(_, _)).WillByDefault(Invoke(readCryptoIv_mockRead));
|
||||
ON_CALL(client, setDecryptIv(_)).WillByDefault(Invoke(readCryptoIv_setDecryptIv));
|
||||
|
||||
const char data[] = "DSOP\0\0\0\0DCIV\0\0\0\4mock";
|
||||
memcpy(g_readCryptoIv_buffer, data, g_readCryptoIv_bufferLen);
|
||||
|
||||
ServerProxy serverProxy(&client, &stream, &eventQueue);
|
||||
serverProxy.handleDataForTest();
|
||||
|
||||
EXPECT_EQ("mock", g_readCryptoIv_result);
|
||||
}
|
||||
|
||||
UInt32
|
||||
mouseMove_mockRead(void* buffer, UInt32 n)
|
||||
{
|
||||
if (g_mouseMove_bufferIndex >= g_mouseMove_bufferLen) {
|
||||
return 0;
|
||||
}
|
||||
memcpy(buffer, &g_mouseMove_buffer[g_mouseMove_bufferIndex], n);
|
||||
g_mouseMove_bufferIndex += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
UInt32
|
||||
readCryptoIv_mockRead(void* buffer, UInt32 n)
|
||||
{
|
||||
if (g_readCryptoIv_bufferIndex >= g_readCryptoIv_bufferLen) {
|
||||
return 0;
|
||||
}
|
||||
memcpy(buffer, &g_readCryptoIv_buffer[g_readCryptoIv_bufferIndex], n);
|
||||
g_readCryptoIv_bufferIndex += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
readCryptoIv_setDecryptIv(const UInt8* data)
|
||||
{
|
||||
g_readCryptoIv_result = reinterpret_cast<const char*>(data);
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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/>.
|
||||
*/
|
||||
|
||||
#include "test/mock/server/MockServer.h"
|
||||
#include "test/mock/io/MockStream.h"
|
||||
#include "test/mock/io/MockCryptoStream.h"
|
||||
#include "test/mock/synergy/MockEventQueue.h"
|
||||
#include "server/ClientProxy1_4.h"
|
||||
|
||||
#include "test/global/gtest.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::ReturnRef;
|
||||
|
||||
const UInt8 g_cryptoIvWrite_bufferLen = 200;
|
||||
UInt8 g_cryptoIvWrite_buffer[g_cryptoIvWrite_bufferLen];
|
||||
UInt32 g_cryptoIvWrite_writeBufferIndex;
|
||||
UInt32 g_cryptoIvWrite_readBufferIndex;
|
||||
|
||||
void cryptoIv_mockWrite(const void* in, UInt32 n);
|
||||
UInt8 cryptoIv_mockRead(void* out, UInt32 n);
|
||||
|
||||
TEST(ClientProxyTests, cryptoIvWrite)
|
||||
{
|
||||
g_cryptoIvWrite_writeBufferIndex = 0;
|
||||
g_cryptoIvWrite_readBufferIndex = 0;
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
NiceMock<MockServer> server;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
IStreamEvents streamEvents;
|
||||
streamEvents.setEvents(&eventQueue);
|
||||
|
||||
CryptoStream* serverStream = new CryptoStream(&eventQueue, &innerStream, options, false);
|
||||
CryptoStream* clientStream = new CryptoStream(&eventQueue, &innerStream, options, false);
|
||||
|
||||
byte iv[CRYPTO_IV_SIZE];
|
||||
serverStream->newIv(iv);
|
||||
serverStream->setEncryptIv(iv);
|
||||
clientStream->setDecryptIv(iv);
|
||||
|
||||
ON_CALL(eventQueue, forIStream()).WillByDefault(ReturnRef(streamEvents));
|
||||
ON_CALL(innerStream, write(_, _)).WillByDefault(Invoke(cryptoIv_mockWrite));
|
||||
ON_CALL(innerStream, read(_, _)).WillByDefault(Invoke(cryptoIv_mockRead));
|
||||
|
||||
ClientProxy1_4 clientProxy("stub", serverStream, &server, &eventQueue);
|
||||
|
||||
UInt8 buffer[100];
|
||||
clientStream->read(buffer, 4);
|
||||
|
||||
g_cryptoIvWrite_writeBufferIndex = 0;
|
||||
g_cryptoIvWrite_readBufferIndex = 0;
|
||||
|
||||
// DCIV, then DKDN.
|
||||
clientProxy.keyDown(1, 2, 3);
|
||||
clientStream->read(buffer, 24);
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('C', buffer[1]);
|
||||
EXPECT_EQ('I', buffer[2]);
|
||||
EXPECT_EQ('V', buffer[3]);
|
||||
clientStream->setDecryptIv(&buffer[8]);
|
||||
clientStream->read(buffer, 10);
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('K', buffer[1]);
|
||||
EXPECT_EQ('D', buffer[2]);
|
||||
EXPECT_EQ('N', buffer[3]);
|
||||
|
||||
g_cryptoIvWrite_writeBufferIndex = 0;
|
||||
g_cryptoIvWrite_readBufferIndex = 0;
|
||||
|
||||
// DCIV, then DKUP.
|
||||
clientProxy.keyUp(1, 2, 3);
|
||||
clientStream->read(buffer, 24);
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('C', buffer[1]);
|
||||
EXPECT_EQ('I', buffer[2]);
|
||||
EXPECT_EQ('V', buffer[3]);
|
||||
clientStream->setDecryptIv(&buffer[8]);
|
||||
clientStream->read(buffer, 10);
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('K', buffer[1]);
|
||||
EXPECT_EQ('U', buffer[2]);
|
||||
EXPECT_EQ('P', buffer[3]);
|
||||
|
||||
g_cryptoIvWrite_writeBufferIndex = 0;
|
||||
g_cryptoIvWrite_readBufferIndex = 0;
|
||||
|
||||
// DCIV, then DKRP.
|
||||
clientProxy.keyRepeat(1, 2, 4, 4);
|
||||
clientStream->read(buffer, 24);
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('C', buffer[1]);
|
||||
EXPECT_EQ('I', buffer[2]);
|
||||
EXPECT_EQ('V', buffer[3]);
|
||||
clientStream->setDecryptIv(&buffer[8]);
|
||||
clientStream->read(buffer, 12);
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('K', buffer[1]);
|
||||
EXPECT_EQ('R', buffer[2]);
|
||||
EXPECT_EQ('P', buffer[3]);
|
||||
}
|
||||
|
||||
void
|
||||
cryptoIv_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
assert(g_cryptoIvWrite_writeBufferIndex <= sizeof(g_cryptoIvWrite_buffer));
|
||||
memcpy(&g_cryptoIvWrite_buffer[g_cryptoIvWrite_writeBufferIndex], in, n);
|
||||
g_cryptoIvWrite_writeBufferIndex += n;
|
||||
}
|
||||
|
||||
UInt8
|
||||
cryptoIv_mockRead(void* out, UInt32 n)
|
||||
{
|
||||
assert(g_cryptoIvWrite_readBufferIndex <= sizeof(g_cryptoIvWrite_buffer));
|
||||
memcpy(out, &g_cryptoIvWrite_buffer[g_cryptoIvWrite_readBufferIndex], n);
|
||||
g_cryptoIvWrite_readBufferIndex += n;
|
||||
return n;
|
||||
}
|
@ -1,351 +0,0 @@
|
||||
/*
|
||||
* synergy -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2013 Synergy Si 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/>.
|
||||
*/
|
||||
|
||||
#include "test/mock/io/MockStream.h"
|
||||
#include "test/mock/synergy/MockEventQueue.h"
|
||||
#include "synergy/PacketStreamFilter.h"
|
||||
#include "io/CryptoStream.h"
|
||||
#include "io/CryptoOptions.h"
|
||||
|
||||
#include "test/global/gtest.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::NiceMock;
|
||||
|
||||
using namespace std;
|
||||
|
||||
const byte kIv[] = "aaaaaaaaaaaaaaaa"; // AES block size = 16 (\0 not used)
|
||||
|
||||
UInt8 g_write_buffer[4];
|
||||
void write_mockWrite(const void* in, UInt32 n);
|
||||
|
||||
UInt8 g_read_buffer[4];
|
||||
UInt8 read_mockRead(void* out, UInt32 n);
|
||||
|
||||
UInt8 g_write4Read1_buffer[4];
|
||||
UInt32 g_write4Read1_bufferIndex;
|
||||
void write4Read1_mockWrite(const void* in, UInt32 n);
|
||||
UInt8 write4Read1_mockRead(void* out, UInt32 n);
|
||||
|
||||
UInt8 g_write1Read4_buffer[4];
|
||||
UInt32 g_write1Read4_bufferIndex;
|
||||
void write1Read4_mockWrite(const void* in, UInt32 n);
|
||||
UInt8 write1Read4_mockRead(void* out, UInt32 n);
|
||||
|
||||
UInt8 g_readWriteIvChanged_buffer[4];
|
||||
UInt32 g_readWriteIvChangeTrigger_writeBufferIndex;
|
||||
UInt32 g_readWriteIvChangeTrigger_readBufferIndex;
|
||||
void readWriteIvChanged_mockWrite(const void* in, UInt32 n);
|
||||
UInt8 readWriteIvChanged_mockRead(void* out, UInt32 n);
|
||||
|
||||
UInt8 g_readWriteIvChangeTrigger_buffer[4 + 4 + 16]; // abcd, DCIV, 16-byte IV
|
||||
void readWriteIvChangeTrigger_mockWrite(const void* in, UInt32 n);
|
||||
UInt8 readWriteIvChangeTrigger_mockRead(void* out, UInt32 n);
|
||||
|
||||
UInt8 g_newIvDoesNotChangeIv_buffer[1];
|
||||
void newIvDoesNotChangeIv_mockWrite(const void* in, UInt32 n);
|
||||
|
||||
TEST(CryptoStreamTests, write)
|
||||
{
|
||||
const UInt32 size = 4;
|
||||
UInt8* buffer = new UInt8[size];
|
||||
buffer[0] = 'D';
|
||||
buffer[1] = 'K';
|
||||
buffer[2] = 'D';
|
||||
buffer[3] = 'N';
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
|
||||
ON_CALL(innerStream, write(_, _)).WillByDefault(Invoke(write_mockWrite));
|
||||
|
||||
CryptoStream cs(&eventQueue, &innerStream, options, false);
|
||||
cs.setEncryptIv(kIv);
|
||||
cs.write(buffer, size);
|
||||
|
||||
EXPECT_EQ(95, g_write_buffer[0]);
|
||||
EXPECT_EQ(107, g_write_buffer[1]);
|
||||
EXPECT_EQ(152, g_write_buffer[2]);
|
||||
EXPECT_EQ(220, g_write_buffer[3]);
|
||||
}
|
||||
|
||||
TEST(CryptoStreamTests, read)
|
||||
{
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
|
||||
ON_CALL(innerStream, read(_, _)).WillByDefault(Invoke(read_mockRead));
|
||||
|
||||
CryptoStream cs(&eventQueue, &innerStream, options, false);
|
||||
cs.setEncryptIv(kIv);
|
||||
cs.setDecryptIv(kIv);
|
||||
|
||||
g_read_buffer[0] = 95;
|
||||
g_read_buffer[1] = 107;
|
||||
g_read_buffer[2] = 152;
|
||||
g_read_buffer[3] = 220;
|
||||
|
||||
const UInt32 size = 4;
|
||||
UInt8* buffer = new UInt8[size];
|
||||
cs.read(buffer, size);
|
||||
|
||||
EXPECT_EQ('D', buffer[0]);
|
||||
EXPECT_EQ('K', buffer[1]);
|
||||
EXPECT_EQ('D', buffer[2]);
|
||||
EXPECT_EQ('N', buffer[3]);
|
||||
}
|
||||
|
||||
TEST(CryptoStreamTests, write4Read1)
|
||||
{
|
||||
g_write4Read1_bufferIndex = 0;
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
|
||||
ON_CALL(innerStream, write(_, _)).WillByDefault(Invoke(write4Read1_mockWrite));
|
||||
ON_CALL(innerStream, read(_, _)).WillByDefault(Invoke(write4Read1_mockRead));
|
||||
|
||||
CryptoStream cs1(&eventQueue, &innerStream, options, false);
|
||||
cs1.setEncryptIv(kIv);
|
||||
|
||||
cs1.write("a", 1);
|
||||
cs1.write("b", 1);
|
||||
cs1.write("c", 1);
|
||||
cs1.write("d", 1);
|
||||
|
||||
CryptoStream cs2(&eventQueue, &innerStream, options, false);
|
||||
cs2.setDecryptIv(kIv);
|
||||
|
||||
UInt8 buffer[4];
|
||||
cs2.read(buffer, 4);
|
||||
|
||||
EXPECT_EQ('a', buffer[0]);
|
||||
EXPECT_EQ('b', buffer[1]);
|
||||
EXPECT_EQ('c', buffer[2]);
|
||||
EXPECT_EQ('d', buffer[3]);
|
||||
}
|
||||
|
||||
TEST(CryptoStreamTests, write1Read4)
|
||||
{
|
||||
g_write1Read4_bufferIndex = 0;
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
|
||||
ON_CALL(innerStream, write(_, _)).WillByDefault(Invoke(write1Read4_mockWrite));
|
||||
ON_CALL(innerStream, read(_, _)).WillByDefault(Invoke(write1Read4_mockRead));
|
||||
|
||||
CryptoStream cs1(&eventQueue, &innerStream, options, false);
|
||||
cs1.setEncryptIv(kIv);
|
||||
|
||||
UInt8 bufferIn[4];
|
||||
bufferIn[0] = 'a';
|
||||
bufferIn[1] = 'b';
|
||||
bufferIn[2] = 'c';
|
||||
bufferIn[3] = 'd';
|
||||
cs1.write(bufferIn, 4);
|
||||
|
||||
CryptoStream cs2(&eventQueue, &innerStream, options, false);
|
||||
cs2.setDecryptIv(kIv);
|
||||
|
||||
UInt8 bufferOut[4];
|
||||
cs2.read(&bufferOut[0], 1);
|
||||
cs2.read(&bufferOut[1], 1);
|
||||
cs2.read(&bufferOut[2], 1);
|
||||
cs2.read(&bufferOut[3], 1);
|
||||
|
||||
EXPECT_EQ('a', bufferOut[0]);
|
||||
EXPECT_EQ('b', bufferOut[1]);
|
||||
EXPECT_EQ('c', bufferOut[2]);
|
||||
EXPECT_EQ('d', bufferOut[3]);
|
||||
}
|
||||
|
||||
TEST(CryptoStreamTests, readWriteIvChanged)
|
||||
{
|
||||
g_readWriteIvChangeTrigger_writeBufferIndex = 0;
|
||||
g_readWriteIvChangeTrigger_readBufferIndex = 0;
|
||||
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
|
||||
ON_CALL(innerStream, write(_, _)).WillByDefault(Invoke(readWriteIvChanged_mockWrite));
|
||||
ON_CALL(innerStream, read(_, _)).WillByDefault(Invoke(readWriteIvChanged_mockRead));
|
||||
|
||||
// AES block size = 16 (\0 not used)
|
||||
const byte iv1[] = "aaaaaaaaaaaaaaaa";
|
||||
const byte iv2[] = "bbbbbbbbbbbbbbbb";
|
||||
|
||||
CryptoStream cs1(&eventQueue, &innerStream, options, false);
|
||||
cs1.setEncryptIv(iv1);
|
||||
|
||||
UInt8 bufferIn[4];
|
||||
bufferIn[0] = 'a';
|
||||
bufferIn[1] = 'b';
|
||||
bufferIn[2] = 'c';
|
||||
bufferIn[3] = 'd';
|
||||
cs1.write(bufferIn, 4);
|
||||
|
||||
CryptoStream cs2(&eventQueue, &innerStream, options, false);
|
||||
cs1.setDecryptIv(iv2);
|
||||
|
||||
UInt8 bufferOut[4];
|
||||
cs2.read(bufferOut, 4);
|
||||
|
||||
// assert that the values cannot be decrypted, since the second crypto
|
||||
// class instance is using a different IV.
|
||||
EXPECT_NE('a', bufferOut[0]);
|
||||
EXPECT_NE('b', bufferOut[1]);
|
||||
EXPECT_NE('c', bufferOut[2]);
|
||||
EXPECT_NE('d', bufferOut[3]);
|
||||
|
||||
// generate a new IV and copy it to the second crypto class, and
|
||||
// ensure that the new IV is used.
|
||||
byte iv[CRYPTO_IV_SIZE];
|
||||
cs1.newIv(iv);
|
||||
cs1.setEncryptIv(iv);
|
||||
cs2.setDecryptIv(iv);
|
||||
|
||||
cs1.write(bufferIn, 4);
|
||||
cs2.read(bufferOut, 4);
|
||||
|
||||
EXPECT_EQ('a', bufferOut[0]);
|
||||
EXPECT_EQ('b', bufferOut[1]);
|
||||
EXPECT_EQ('c', bufferOut[2]);
|
||||
EXPECT_EQ('d', bufferOut[3]);
|
||||
}
|
||||
|
||||
TEST(CryptoStreamTests, createKey)
|
||||
{
|
||||
byte hash1[16];
|
||||
CryptoStream::createKey(hash1, "MockLongPassword", 16, 16);
|
||||
EXPECT_EQ(hash1[0], 149);
|
||||
EXPECT_EQ(hash1[15], 235);
|
||||
|
||||
byte hash2[32];
|
||||
CryptoStream::createKey(hash2, "MockLongPassword", 32, 16);
|
||||
EXPECT_EQ(hash2[0], 149);
|
||||
EXPECT_EQ(hash2[15], 235);
|
||||
EXPECT_EQ(hash2[31], 7);
|
||||
|
||||
byte hash3[32];
|
||||
CryptoStream::createKey(hash3, "7accbf2f86a9191da0947107d4fe7054", 32, 16);
|
||||
EXPECT_EQ(hash3[0], 120);
|
||||
EXPECT_EQ(hash3[15], 11);
|
||||
EXPECT_EQ(hash3[31], 233);
|
||||
}
|
||||
|
||||
TEST(CryptoStreamTests, newIvDoesNotChangeIv)
|
||||
{
|
||||
NiceMock<MockEventQueue> eventQueue;
|
||||
NiceMock<MockStream> innerStream;
|
||||
CryptoOptions options("cfb", "mock");
|
||||
|
||||
ON_CALL(innerStream, write(_, _)).WillByDefault(Invoke(newIvDoesNotChangeIv_mockWrite));
|
||||
|
||||
CryptoStream cs1(&eventQueue, &innerStream, options, false);
|
||||
cs1.write("a", 1);
|
||||
EXPECT_EQ(175, g_newIvDoesNotChangeIv_buffer[0]);
|
||||
|
||||
byte iv[CRYPTO_IV_SIZE];
|
||||
cs1.newIv(iv);
|
||||
|
||||
cs1.write("a", 1);
|
||||
EXPECT_EQ(92, g_newIvDoesNotChangeIv_buffer[0]);
|
||||
}
|
||||
|
||||
void
|
||||
write_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
memcpy(g_write_buffer, in, n);
|
||||
}
|
||||
|
||||
UInt8
|
||||
read_mockRead(void* out, UInt32 n)
|
||||
{
|
||||
memcpy(out, g_read_buffer, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
write4Read1_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
UInt8* buffer = static_cast<UInt8*>(const_cast<void*>(in));
|
||||
g_write4Read1_buffer[g_write4Read1_bufferIndex++] = buffer[0];
|
||||
}
|
||||
|
||||
UInt8
|
||||
write4Read1_mockRead(void* out, UInt32 n)
|
||||
{
|
||||
memcpy(out, g_write4Read1_buffer, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
write1Read4_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
memcpy(g_write1Read4_buffer, in, n);
|
||||
}
|
||||
|
||||
UInt8
|
||||
write1Read4_mockRead(void* out, UInt32 n)
|
||||
{
|
||||
UInt8* buffer = static_cast<UInt8*>(out);
|
||||
buffer[0] = g_write1Read4_buffer[g_write1Read4_bufferIndex++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
readWriteIvChanged_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
memcpy(g_readWriteIvChanged_buffer, in, n);
|
||||
}
|
||||
|
||||
UInt8
|
||||
readWriteIvChanged_mockRead(void* out, UInt32 n)
|
||||
{
|
||||
memcpy(out, g_readWriteIvChanged_buffer, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
readWriteIvChangeTrigger_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
assert(g_readWriteIvChangeTrigger_writeBufferIndex <= sizeof(g_readWriteIvChangeTrigger_buffer));
|
||||
memcpy(&g_readWriteIvChangeTrigger_buffer[g_readWriteIvChangeTrigger_writeBufferIndex], in, n);
|
||||
g_readWriteIvChangeTrigger_writeBufferIndex += n;
|
||||
}
|
||||
|
||||
UInt8
|
||||
readWriteIvChangeTrigger_mockRead(void* out, UInt32 n)
|
||||
{
|
||||
assert(g_readWriteIvChangeTrigger_readBufferIndex <= sizeof(g_readWriteIvChangeTrigger_buffer));
|
||||
memcpy(out, &g_readWriteIvChangeTrigger_buffer[g_readWriteIvChangeTrigger_readBufferIndex], n);
|
||||
g_readWriteIvChangeTrigger_readBufferIndex += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
newIvDoesNotChangeIv_mockWrite(const void* in, UInt32 n)
|
||||
{
|
||||
memcpy(g_newIvDoesNotChangeIv_buffer, in, 1);
|
||||
}
|
@ -278,23 +278,6 @@ TEST(GenericArgsParsingTests, parseGenericArgs_ipcCmd_enableIpcTrue)
|
||||
EXPECT_EQ(1, i);
|
||||
}
|
||||
|
||||
TEST(GenericArgsParsingTests, parseGenericArgs_cryptoPassCmd_savePassword)
|
||||
{
|
||||
int i = 1;
|
||||
const int argc = 3;
|
||||
const char* kCryptoPassCmd[argc] = { "stub", "--crypto-pass", "mock_password" };
|
||||
|
||||
ArgParser argParser(NULL);
|
||||
ArgsBase argsBase;
|
||||
argParser.setArgsBase(argsBase);
|
||||
|
||||
argParser.parseGenericArgs(argc, kCryptoPassCmd, i);
|
||||
|
||||
EXPECT_EQ("mock_password", argsBase.m_crypto.m_pass);
|
||||
EXPECT_EQ(1, argsBase.m_crypto.m_mode); // 1 == kCfb
|
||||
EXPECT_EQ(2, i);
|
||||
}
|
||||
|
||||
#ifndef WINAPI_XWINDOWS
|
||||
TEST(GenericArgsParsingTests, parseGenericArgs_dragDropCmdOnNonLinux_enableDragDropTrue)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user