Store DHParams in sqlite.

This commit is contained in:
Arthur Britto
2012-04-29 16:48:51 -07:00
parent 2d9eff0ecf
commit 024f14efa4
4 changed files with 38 additions and 37 deletions

View File

@@ -6,9 +6,10 @@
#include <boost/bind.hpp>
#include <boost/mem_fn.hpp>
//#include <boost/log/trivial.hpp>
#include <openssl/dh.h>
#include "Application.h"
#include "Config.h"
#include "utils.h"
using namespace std;
using namespace boost::asio::ip;
@@ -16,33 +17,7 @@ using namespace boost::asio::ip;
// Generate DH for SSL connection.
static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
{
// We don't care if for export.
static DH* sdh512 = 0;
static DH* sdh1024 = 0;
if (!sdh512 && 512 == iKeyLength)
{
int iCodes;
do {
sdh512 = DH_generate_parameters(512, DH_GENERATOR_5, NULL, NULL);
iCodes = 0;
DH_check(sdh512, &iCodes);
} while (iCodes & (DH_CHECK_P_NOT_PRIME|DH_CHECK_P_NOT_SAFE_PRIME|DH_UNABLE_TO_CHECK_GENERATOR|DH_NOT_SUITABLE_GENERATOR));
}
if (!sdh1024 && 512 != iKeyLength)
{
int iCodes;
do {
sdh1024 = DH_generate_parameters(1024, DH_GENERATOR_5, NULL, NULL);
iCodes = 0;
DH_check(sdh1024, &iCodes);
} while (iCodes & (DH_CHECK_P_NOT_PRIME|DH_CHECK_P_NOT_SAFE_PRIME|DH_UNABLE_TO_CHECK_GENERATOR|DH_NOT_SUITABLE_GENERATOR));
}
return 512 == iKeyLength ? sdh512 : sdh1024;
return 512 == iKeyLength ? theApp->getWallet().getDh512() : theApp->getWallet().getDh1024();
}
PeerDoor::PeerDoor(boost::asio::io_service& io_service) :