From 49f682883437d85ae2a59eeec221912df698c7b1 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 4 Sep 2012 10:17:27 +0000 Subject: Removed OS dependencies from CryptoPP; Removed unused modules that didn't compile on some platforms git-svn-id: http://mc-server.googlecode.com/svn/trunk@827 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Protocol132.cpp | 8 +++++--- source/cServer.cpp | 5 ++++- source/cServer.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/Protocol132.cpp b/source/Protocol132.cpp index 43aedc934..2a0b7a605 100644 --- a/source/Protocol132.cpp +++ b/source/Protocol132.cpp @@ -8,7 +8,7 @@ #include "cRoot.h" #include "cServer.h" #include "cClientHandle.h" -#include "CryptoPP/osrng.h" +#include "CryptoPP/randpool.h" #include "cItem.h" #include "ChunkDataSerializer.h" #include "cPlayer.h" @@ -568,7 +568,7 @@ void cProtocol132::SendEncryptionKeyRequest(const AString & a_Key) WriteShort((short)a_Key.size()); SendData(a_Key.data(), a_Key.size()); WriteShort(4); - WriteInt((int)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) + WriteInt((int)(intptr_t)this); // Using 'this' as the cryptographic nonce, so that we don't have to generate one each time :) Flush(); } @@ -580,7 +580,9 @@ void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const A { // Decrypt EncNonce using privkey RSAES::Decryptor rsaDecryptor(cRoot::Get()->GetServer()->GetPrivateKey()); - AutoSeededRandomPool rng; + time_t CurTime = time(NULL); + CryptoPP::RandomPool rng; + rng.Put((const byte *)&CurTime, sizeof(CurTime)); byte DecryptedNonce[MAX_ENC_LEN]; DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce); if (!res.isValidCoding || (res.messageLength != 4)) diff --git a/source/cServer.cpp b/source/cServer.cpp index 157de2388..b294842b7 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -291,7 +291,10 @@ void cServer::PrepareKeys(void) // But generating the key takes only a moment, do we even need that? LOG("Generating protocol encryption keypair..."); - CryptoPP::AutoSeededRandomPool rng; + + time_t CurTime = time(NULL); + CryptoPP::RandomPool rng; + rng.Put((const byte *)&CurTime, sizeof(CurTime)); m_PrivateKey.GenerateRandomWithKeySize(rng, 1024); CryptoPP::RSA::PublicKey pk(m_PrivateKey); m_PublicKey = pk; diff --git a/source/cServer.h b/source/cServer.h index 7baaa0d6a..9dd087299 100644 --- a/source/cServer.h +++ b/source/cServer.h @@ -13,7 +13,7 @@ #include "cSocketThreads.h" #include "CryptoPP/rsa.h" -#include "CryptoPP/osrng.h" +#include "CryptoPP/randpool.h" -- cgit v1.2.3