2012-06-10 16:50:54 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2012-09-04 02:09:56 +00:00
|
|
|
* Copyright (C) 2012 Bolton Software Ltd.
|
|
|
|
* Copyright (C) 2011 Chris Schoeneman
|
2012-06-10 16:50:54 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#include "server/ClientProxy1_4.h"
|
|
|
|
|
|
|
|
#include "server/Server.h"
|
|
|
|
#include "synergy/ProtocolUtil.h"
|
|
|
|
#include "io/CryptoStream.h"
|
|
|
|
#include "base/Log.h"
|
|
|
|
#include "base/IEventQueue.h"
|
|
|
|
#include "base/TMethodEventJob.h"
|
|
|
|
|
2012-06-10 16:50:54 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
//
|
|
|
|
// CClientProxy1_4
|
|
|
|
//
|
|
|
|
|
2013-06-29 14:17:49 +00:00
|
|
|
CClientProxy1_4::CClientProxy1_4(const CString& name, synergy::IStream* stream, CServer* server, IEventQueue* events) :
|
|
|
|
CClientProxy1_3(name, stream, events), m_server(server)
|
2012-06-10 16:50:54 +00:00
|
|
|
{
|
|
|
|
assert(m_server != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
CClientProxy1_4::~CClientProxy1_4()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-09 18:56:19 +00:00
|
|
|
void
|
|
|
|
CClientProxy1_4::keyDown(KeyID key, KeyModifierMask mask, KeyButton button)
|
|
|
|
{
|
|
|
|
cryptoIv();
|
|
|
|
CClientProxy1_3::keyDown(key, mask, button);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CClientProxy1_4::keyRepeat(KeyID key, KeyModifierMask mask, SInt32 count, KeyButton button)
|
|
|
|
{
|
|
|
|
cryptoIv();
|
|
|
|
CClientProxy1_3::keyRepeat(key, mask, count, button);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CClientProxy1_4::keyUp(KeyID key, KeyModifierMask mask, KeyButton button)
|
|
|
|
{
|
|
|
|
cryptoIv();
|
|
|
|
CClientProxy1_3::keyUp(key, mask, button);
|
|
|
|
}
|
|
|
|
|
2013-08-16 18:06:30 +00:00
|
|
|
void
|
|
|
|
CClientProxy1_4::keepAlive()
|
|
|
|
{
|
|
|
|
cryptoIv();
|
|
|
|
CClientProxy1_3::keepAlive();
|
|
|
|
}
|
|
|
|
|
2013-04-09 18:56:19 +00:00
|
|
|
void
|
|
|
|
CClientProxy1_4::cryptoIv()
|
|
|
|
{
|
|
|
|
CCryptoStream* cryptoStream = dynamic_cast<CCryptoStream*>(getStream());
|
|
|
|
if (cryptoStream == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte iv[CRYPTO_IV_SIZE];
|
|
|
|
cryptoStream->newIv(iv);
|
|
|
|
CString data(reinterpret_cast<const char*>(iv), CRYPTO_IV_SIZE);
|
|
|
|
|
|
|
|
LOG((CLOG_DEBUG2 "send crypto iv change to \"%s\"", getName().c_str()));
|
|
|
|
CProtocolUtil::writef(getStream(), kMsgDCryptoIv, &data);
|
2013-04-11 22:30:24 +00:00
|
|
|
|
|
|
|
// change IV only after we've sent the current IV, otherwise
|
|
|
|
// the client won't be able to decrypt the new IV.
|
2013-05-01 15:53:22 +00:00
|
|
|
cryptoStream->setEncryptIv(iv);
|
2013-04-09 18:56:19 +00:00
|
|
|
}
|