fixed: crypto++ compile errors, linux compiler syntax bugs, and code style (spaces -> tabs)

This commit is contained in:
Nick Bolton 2013-04-11 00:30:41 +00:00
parent 650da22c33
commit c0dcdd52e7
10 changed files with 99 additions and 77 deletions

View File

@ -57,7 +57,7 @@ public:
//@} //@}
#ifdef TEST_ENV #ifdef TEST_ENV
void handleDataForTest() { handleData(NULL, NULL); } void handleDataForTest() { handleData(CEvent(), NULL); }
#endif #endif
protected: protected:
@ -76,7 +76,7 @@ private:
// modifier key translation // modifier key translation
KeyID translateKey(KeyID) const; KeyID translateKey(KeyID) const;
KeyModifierMask translateModifierMask(KeyModifierMask) const; KeyModifierMask translateModifierMask(KeyModifierMask) const;
// event handlers // event handlers
void handleData(const CEvent&, void*); void handleData(const CEvent&, void*);
@ -110,7 +110,7 @@ private:
typedef EResult (CServerProxy::*MessageParser)(const UInt8*); typedef EResult (CServerProxy::*MessageParser)(const UInt8*);
CClient* m_client; CClient* m_client;
synergy::IStream* m_stream; synergy::IStream* m_stream;
UInt32 m_seqNum; UInt32 m_seqNum;
@ -121,13 +121,13 @@ private:
bool m_ignoreMouse; bool m_ignoreMouse;
KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast]; KeyModifierID m_modifierTranslationTable[kKeyModifierIDLast];
double m_keepAliveAlarm; double m_keepAliveAlarm;
CEventQueueTimer* m_keepAliveAlarmTimer; CEventQueueTimer* m_keepAliveAlarmTimer;
MessageParser m_parser; MessageParser m_parser;
IEventQueue* m_eventQueue; IEventQueue* m_eventQueue;
}; };
#endif #endif

View File

@ -16,6 +16,7 @@
*/ */
#include "CCryptoMode.h" #include "CCryptoMode.h"
#include "XSynergy.h"
using namespace CryptoPP; using namespace CryptoPP;
@ -46,7 +47,7 @@ CCryptoMode::CCryptoMode(ECryptoMode mode, bool encryption) :
break; break;
default: default:
throw std::exception("crypto mode not set"); throw XBadCryptoMode();
} }
} }
else { else {
@ -71,7 +72,7 @@ CCryptoMode::CCryptoMode(ECryptoMode mode, bool encryption) :
break; break;
default: default:
throw std::exception("crypto mode not set"); throw XBadCryptoMode();
} }
} }
} }

View File

@ -50,7 +50,7 @@ private:
typedef CryptoPP::CTR_Mode<CryptoPP::AES>::Decryption CCtrModeDec; typedef CryptoPP::CTR_Mode<CryptoPP::AES>::Decryption CCtrModeDec;
typedef CryptoPP::GCM<CryptoPP::AES>::Decryption CGcmModeDec; typedef CryptoPP::GCM<CryptoPP::AES>::Decryption CGcmModeDec;
static CCryptoMode::ECryptoMode parseMode(CString& mode); static ECryptoMode parseMode(CString& mode);
ECryptoMode m_mode; ECryptoMode m_mode;
void* m_crypto; void* m_crypto;

View File

@ -16,6 +16,7 @@
*/ */
#include "CCryptoOptions.h" #include "CCryptoOptions.h"
#include "XSynergy.h"
CCryptoOptions::CCryptoOptions( CCryptoOptions::CCryptoOptions(
const CString& modeString, const CString& modeString,
@ -48,6 +49,6 @@ CCryptoOptions::parseMode(CString modeString)
return kGcm; return kGcm;
} }
else { else {
throw std::exception("invalid crypto mode"); throw XBadCryptoMode();
} }
} }

View File

@ -17,9 +17,10 @@
#include "CCryptoStream.h" #include "CCryptoStream.h"
#include "CLog.h" #include "CLog.h"
#include "CCryptoOptions.h"
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "CCryptoOptions.h" #include <stdio.h>
using namespace CryptoPP; using namespace CryptoPP;
using namespace synergy::crypto; using namespace synergy::crypto;

View File

@ -20,9 +20,10 @@
#include "BasicTypes.h" #include "BasicTypes.h"
#include "CStreamFilter.h" #include "CStreamFilter.h"
#include "CCryptoMode.h" #include "CCryptoMode.h"
#include "CCryptoOptions.h"
#include <cryptopp562/osrng.h> #include <cryptopp562/osrng.h>
#include "cryptopp562/sha.h" #include <cryptopp562/sha.h>
class CCryptoOptions;
#define CRYPTO_IV_SIZE CryptoPP::AES::BLOCKSIZE #define CRYPTO_IV_SIZE CryptoPP::AES::BLOCKSIZE
@ -51,8 +52,8 @@ public:
*/ */
virtual void write(const void* in, UInt32 n); virtual void write(const void* in, UInt32 n);
//! Set the IV //! Set the IV
void setIv(const byte* iv); void setIv(const byte* iv);
//! Get a new IV //! Get a new IV
/*! /*!
@ -67,7 +68,7 @@ public:
private: private:
void logBuffer(const char* name, const byte* buf, int length); void logBuffer(const char* name, const byte* buf, int length);
byte* m_key; byte* m_key;
CCryptoMode m_encryption; CCryptoMode m_encryption;
CCryptoMode m_decryption; CCryptoMode m_decryption;
CryptoPP::AutoSeededRandomPool m_autoSeedRandomPool; CryptoPP::AutoSeededRandomPool m_autoSeedRandomPool;

View File

@ -29,6 +29,15 @@ XBadClient::getWhat() const throw()
return "XBadClient"; return "XBadClient";
} }
//
// XBadCryptoMode
//
CString
XBadCryptoMode::getWhat() const throw()
{
return "XBadCryptoMode";
}
// //
// XIncompatibleClient // XIncompatibleClient

View File

@ -30,6 +30,12 @@ Thrown when the client fails to follow the protocol.
*/ */
XBASE_SUBCLASS_WHAT(XBadClient, XSynergy); XBASE_SUBCLASS_WHAT(XBadClient, XSynergy);
//! Bad crypto mode
/*!
Thrown when the user enters an invalid crypto mode.
*/
XBASE_SUBCLASS_WHAT(XBadCryptoMode, XSynergy);
//! Incompatible client exception //! Incompatible client exception
/*! /*!
Thrown when a client attempting to connect has an incompatible version. Thrown when a client attempting to connect has an incompatible version.

View File

@ -20,6 +20,7 @@
#include "CMockStream.h" #include "CMockStream.h"
#include "CMockEventQueue.h" #include "CMockEventQueue.h"
#include "CPacketStreamFilter.h" #include "CPacketStreamFilter.h"
#include "CCryptoOptions.h"
using ::testing::_; using ::testing::_;
using ::testing::Invoke; using ::testing::Invoke;

View File

@ -7,45 +7,47 @@
# #
# This package is distributed in the hope that it will be useful, # This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
set(cpp_dir cryptopp562) set(cpp_dir cryptopp562)
file(GLOB cpp_src ${cpp_dir}/*.cpp) file(GLOB cpp_src ${cpp_dir}/*.cpp)
if (WIN32) if (WIN32)
file(GLOB cpp_hdr ${cpp_dir}/*.h) file(GLOB cpp_hdr ${cpp_dir}/*.h)
list(APPEND cpp_src ${cpp_hdr}) list(APPEND cpp_src ${cpp_hdr})
endif() endif()
file(GLOB cpp_ignore file(GLOB cpp_ignore
${cpp_dir}/simple.cpp ${cpp_dir}/simple.cpp
${cpp_dir}/strciphr.cpp ${cpp_dir}/strciphr.cpp
${cpp_dir}/polynomi.cpp ${cpp_dir}/polynomi.cpp
${cpp_dir}/eprecomp.cpp ${cpp_dir}/eprecomp.cpp
${cpp_dir}/eccrypto.cpp ${cpp_dir}/eccrypto.cpp
${cpp_dir}/algebra.cpp) ${cpp_dir}/algebra.cpp)
list(REMOVE_ITEM cpp_src ${cpp_ignore}) list(REMOVE_ITEM cpp_src ${cpp_ignore})
# 64-bit windows - compile asm file. # if 64-bit windows, compile asm file.
if(CMAKE_CL_64) if (CMAKE_CL_64)
list(APPEND cpp_src ${cpp_dir}/x64dll.asm ${cpp_dir}/x64masm.asm) list(APPEND cpp_src ${cpp_dir}/x64dll.asm ${cpp_dir}/x64masm.asm)
add_custom_command(OUTPUT $(IntDir)x64dll.obj add_custom_command(OUTPUT $(IntDir)x64dll.obj
COMMAND ml64.exe /c /nologo /Fo$(IntDir)x64dll.obj /Zi COMMAND ml64.exe /c /nologo /Fo$(IntDir)x64dll.obj /Zi
"${CMAKE_CURRENT_SOURCE_DIR}/${cpp_dir}/x64dll.asm" "${CMAKE_CURRENT_SOURCE_DIR}/${cpp_dir}/x64dll.asm"
MAIN_DEPENDENCY ${cpp_dir}/x64dll.asm MAIN_DEPENDENCY ${cpp_dir}/x64dll.asm
VERBATIM) VERBATIM)
add_custom_command(OUTPUT $(IntDir)x64masm.obj add_custom_command(OUTPUT $(IntDir)x64masm.obj
COMMAND ml64.exe /c /nologo /Fo$(IntDir)x64masm.obj /Zi COMMAND ml64.exe /c /nologo /Fo$(IntDir)x64masm.obj /Zi
"${CMAKE_CURRENT_SOURCE_DIR}/${cpp_dir}/x64masm.asm" "${CMAKE_CURRENT_SOURCE_DIR}/${cpp_dir}/x64masm.asm"
MAIN_DEPENDENCY ${cpp_dir}/x64masm.asm MAIN_DEPENDENCY ${cpp_dir}/x64masm.asm
VERBATIM) VERBATIM)
else()
add_definitions(-DCRYPTOPP_DISABLE_ASM)
endif() endif()
if (APPLE) if (APPLE)