From 539364846a89987ac2679988653f50332cb91d26 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Thu, 30 Aug 2012 21:06:13 +0000 Subject: Implemented 1.3.2 protocol encryption using CryptoPP, up to Client Status packet (http://wiki.vg/Protocol_FAQ step 14) git-svn-id: http://mc-server.googlecode.com/svn/trunk@808 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cServer.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/cServer.cpp') diff --git a/source/cServer.cpp b/source/cServer.cpp index 330a69873..157de2388 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -241,6 +241,8 @@ bool cServer::InitServer( int a_Port ) m_NotifyWriteThread.Start(this); + PrepareKeys(); + return true; } @@ -283,6 +285,22 @@ cServer::~cServer() +void cServer::PrepareKeys(void) +{ + // TODO: Save and load key for persistence across sessions + // But generating the key takes only a moment, do we even need that? + + LOG("Generating protocol encryption keypair..."); + CryptoPP::AutoSeededRandomPool rng; + m_PrivateKey.GenerateRandomWithKeySize(rng, 1024); + CryptoPP::RSA::PublicKey pk(m_PrivateKey); + m_PublicKey = pk; +} + + + + + void cServer::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude) { cCSLock Lock(m_CSClients); -- cgit v1.2.3