From f00ce242b5ac1af56937cb6df813cc7cc7f5a1fb Mon Sep 17 00:00:00 2001 From: Jon Spock Date: Sun, 23 Apr 2017 15:11:42 -0700 Subject: [PATCH] Remove Keepass code due to Valgrind warnings --- src/Makefile.am | 2 - src/alert.cpp | 2 +- src/coins.cpp | 2 +- src/init.cpp | 11 +- src/keepass.cpp | 463 ---------------------------------------- src/keepass.h | 136 ------------ src/qt/overviewpage.cpp | 1 + src/qt/splashscreen.cpp | 2 +- src/rpcserver.cpp | 1 - src/rpcserver.h | 1 - src/rpcwallet.cpp | 49 ----- src/util.cpp | 1 - src/wallet.cpp | 55 +---- 13 files changed, 10 insertions(+), 716 deletions(-) delete mode 100644 src/keepass.cpp delete mode 100644 src/keepass.h diff --git a/src/Makefile.am b/src/Makefile.am index 9dc129ec6f49b..f8dda88ec680e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -103,7 +103,6 @@ BITCOIN_CORE_H = \ kernel.h \ swifttx.h \ key.h \ - keepass.h \ keystore.h \ leveldbwrapper.h \ limitedmap.h \ @@ -229,7 +228,6 @@ libbitcoin_wallet_a_SOURCES = \ wallet.cpp \ wallet_ismine.cpp \ walletdb.cpp \ - keepass.cpp \ $(BITCOIN_CORE_H) # crypto primitives library diff --git a/src/alert.cpp b/src/alert.cpp index 571bb05f58826..9f102cda76ec3 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -48,7 +48,7 @@ void CUnsignedAlert::SetNull() std::string CUnsignedAlert::ToString() const { std::string strSetCancel; - BOOST_FOREACH (int n, setCancel) + for (auto& n: setCancel) strSetCancel += strprintf("%d ", n); std::string strSetSubVer; BOOST_FOREACH (std::string str, setSubVer) diff --git a/src/coins.cpp b/src/coins.cpp index f67dd8fe9f3d5..e5e8ba8f07745 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -248,7 +248,7 @@ double CCoinsViewCache::GetPriority(const CTransaction& tx, int nHeight) const if (tx.IsCoinBase() || tx.IsCoinStake()) return 0.0; double dResult = 0.0; - BOOST_FOREACH (const CTxIn& txin, tx.vin) { + for (const CTxIn& txin: tx.vin) { const CCoins* coins = AccessCoins(txin.prevout.hash); assert(coins); if (!coins->IsAvailable(txin.prevout.n)) continue; diff --git a/src/init.cpp b/src/init.cpp index 3b18e6d7e455e..0c2bfabce8ab2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -33,7 +33,6 @@ #include "utilmoneystr.h" #ifdef ENABLE_WALLET #include "db.h" -#include "keepass.h" #include "wallet.h" #include "walletdb.h" #endif @@ -343,11 +342,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += "\n" + _("Wallet options:") + "\n"; strUsage += " -createwalletbackups= " + _("Number of automatic wallet backups (default: 10)") + "\n"; strUsage += " -disablewallet " + _("Do not load the wallet and disable wallet RPC calls") + "\n"; - strUsage += " -keepass " + strprintf(_("Use KeePass 2 integration using KeePassHttp plugin (default: %u)"), 0) + "\n"; - strUsage += " -keepassport= " + strprintf(_("Connect to KeePassHttp on port (default: %u)"), 19455) + "\n"; - strUsage += " -keepasskey= " + _("KeePassHttp key for AES encrypted communication with KeePass") + "\n"; - strUsage += " -keepassid= " + _("KeePassHttp id for the established association") + "\n"; - strUsage += " -keepassname= " + _("Name to construct url for KeePass entry that stores the wallet passphrase") + "\n"; strUsage += " -keypool= " + strprintf(_("Set key pool size to (default: %u)"), 100) + "\n"; if (GetBoolArg("-help-debug", false)) strUsage += " -mintxfee= " + strprintf(_("Fees (in PIV/Kb) smaller than this are considered zero fee for transaction creation (default: %s)"), FormatMoney(CWallet::minTxFee.GetFeePerK())) + "\n"; @@ -382,7 +376,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += " " + _("If is not supplied, output all debugging information.") + "\n"; strUsage += " " + _(" can be:\n"); strUsage += " addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, net,\n"; // Don't translate these and qt below - strUsage += " pivx (or specifically: obfuscation, swifttx, masternode, keepass, mnpayments, mnbudget)"; // Don't translate these and qt below + strUsage += " pivx (or specifically: obfuscation, swifttx, masternode, mnpayments, mnbudget)"; // Don't translate these and qt below if (mode == HMM_BITCOIN_QT) strUsage += ", qt"; strUsage += ".\n"; @@ -1008,9 +1002,6 @@ bool AppInit2(boost::thread_group& threadGroup) return InitError(_("wallet.dat corrupt, salvage failed")); } - // Initialize KeePass Integration - keePassInt.init(); - } // (!fDisableWallet) #endif // ENABLE_WALLET // ********************************************************* Step 6: network initialization diff --git a/src/keepass.cpp b/src/keepass.cpp deleted file mode 100644 index 1b0ff33c8288c..0000000000000 --- a/src/keepass.cpp +++ /dev/null @@ -1,463 +0,0 @@ -// Copyright (c) 2014 The Dash developers -// Copyright (c) 2015-2017 The PIVX developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "keepass.h" - -#include -// #include -#include -#include -// #include - -#include "json/json_spirit_reader_template.h" -#include "json/json_spirit_writer_template.h" - -#include "clientversion.h" -#include "crypter.h" -#include "random.h" -#include "rpcprotocol.h" - -// Necessary to prevent compile errors due to forward declaration of -//CScript in serialize.h (included from crypter.h) -#include "script/script.h" -#include "script/standard.h" - -#include "util.h" -#include "utilstrencodings.h" - -using boost::asio::ip::tcp; - -CKeePassIntegrator keePassInt; - -CKeePassIntegrator::CKeePassIntegrator() - : sKeyBase64(" "), sKey(" "), sUrl(" ") // Prevent LockedPageManagerBase complaints -{ - sKeyBase64.clear(); // Prevent LockedPageManagerBase complaints - sKey.clear(); // Prevent LockedPageManagerBase complaints - sUrl.clear(); // Prevent LockedPageManagerBase complaints - bIsActive = false; - nPort = KEEPASS_KEEPASSHTTP_PORT; -} - -// Initialze from application context -void CKeePassIntegrator::init() -{ - bIsActive = GetBoolArg("-keepass", false); - nPort = boost::lexical_cast(GetArg("-keepassport", KEEPASS_KEEPASSHTTP_PORT)); - sKeyBase64 = SecureString(GetArg("-keepasskey", "").c_str()); - sKeePassId = GetArg("-keepassid", ""); - sKeePassEntryName = GetArg("-keepassname", ""); - // Convert key if available - if (sKeyBase64.size() > 0) { - sKey = DecodeBase64Secure(sKeyBase64); - } - // Construct url if available - if (sKeePassEntryName.size() > 0) { - sUrl = SecureString("http://"); - sUrl += SecureString(sKeePassEntryName.c_str()); - sUrl += SecureString("/"); - //sSubmitUrl = "http://"; - //sSubmitUrl += SecureString(sKeePassEntryName.c_str()); - } -} - -void CKeePassIntegrator::CKeePassRequest::addStrParameter(std::string sName, std::string sValue) -{ - requestObj.push_back(json_spirit::Pair(sName, sValue)); -} - -void CKeePassIntegrator::CKeePassRequest::addStrParameter(std::string sName, SecureString sValue) -{ - std::string sCipherValue; - - if (!EncryptAES256(sKey, sValue, sIV, sCipherValue)) { - throw std::runtime_error("Unable to encrypt Verifier"); - } - - addStrParameter(sName, EncodeBase64(sCipherValue)); -} - -std::string CKeePassIntegrator::CKeePassRequest::getJson() -{ - return json_spirit::write_string(json_spirit::Value(requestObj), false); -} - -void CKeePassIntegrator::CKeePassRequest::init() -{ - SecureString sIVSecure = generateRandomKey(KEEPASS_CRYPTO_BLOCK_SIZE); - sIV = std::string(&sIVSecure[0], sIVSecure.size()); - // Generate Nonce, Verifier and RequestType - SecureString sNonceBase64Secure = EncodeBase64Secure(sIVSecure); - addStrParameter("Nonce", std::string(&sNonceBase64Secure[0], sNonceBase64Secure.size())); // Plain - addStrParameter("Verifier", sNonceBase64Secure); // Encoded - addStrParameter("RequestType", sType); -} - -void CKeePassIntegrator::CKeePassResponse::parseResponse(std::string sResponse) -{ - json_spirit::Value responseValue; - if (!json_spirit::read_string(sResponse, responseValue)) { - throw std::runtime_error("Unable to parse KeePassHttp response"); - } - - responseObj = responseValue.get_obj(); - - // retrieve main values - bSuccess = json_spirit::find_value(responseObj, "Success").get_bool(); - sType = getStr("RequestType"); - sIV = DecodeBase64(getStr("Nonce")); -} - -std::string CKeePassIntegrator::CKeePassResponse::getStr(std::string sName) -{ - std::string sValue(json_spirit::find_value(responseObj, sName).get_str()); - return sValue; -} - -SecureString CKeePassIntegrator::CKeePassResponse::getSecureStr(std::string sName) -{ - std::string sValueBase64Encrypted(json_spirit::find_value(responseObj, sName).get_str()); - SecureString sValue; - try { - sValue = decrypt(sValueBase64Encrypted); - } catch (std::exception& e) { - std::string sErrorMessage = "Exception occured while decrypting "; - sErrorMessage += sName + ": " + e.what(); - throw std::runtime_error(sErrorMessage); - } - return sValue; -} - -SecureString CKeePassIntegrator::CKeePassResponse::decrypt(std::string sValueBase64Encrypted) -{ - std::string sValueEncrypted = DecodeBase64(sValueBase64Encrypted); - SecureString sValue; - if (!DecryptAES256(sKey, sValueEncrypted, sIV, sValue)) { - throw std::runtime_error("Unable to decrypt value."); - } - return sValue; -} - -std::vector CKeePassIntegrator::CKeePassResponse::getEntries() -{ - std::vector vEntries; - - json_spirit::Array aEntries = json_spirit::find_value(responseObj, "Entries").get_array(); - for (json_spirit::Array::iterator it = aEntries.begin(); it != aEntries.end(); ++it) { - SecureString sEntryUuid(decrypt(json_spirit::find_value((*it).get_obj(), "Uuid").get_str().c_str())); - SecureString sEntryName(decrypt(json_spirit::find_value((*it).get_obj(), "Name").get_str().c_str())); - SecureString sEntryLogin(decrypt(json_spirit::find_value((*it).get_obj(), "Login").get_str().c_str())); - SecureString sEntryPassword(decrypt(json_spirit::find_value((*it).get_obj(), "Password").get_str().c_str())); - CKeePassEntry entry(sEntryUuid, sEntryUuid, sEntryLogin, sEntryPassword); - vEntries.push_back(entry); - } - - return vEntries; -} - -SecureString CKeePassIntegrator::generateRandomKey(size_t nSize) -{ - // Generates random key - SecureString key; - key.resize(nSize); - - RandAddSeedPerfmon(); - RAND_bytes((unsigned char*)&key[0], nSize); - - return key; -} - -// Construct POST body for RPC JSON call -std::string CKeePassIntegrator::constructHTTPPost(const std::string& strMsg, const std::map& mapRequestHeaders) -{ - std::ostringstream s; - s << "POST / HTTP/1.1\r\n" - << "User-Agent: pivx-json-rpc/" << FormatFullVersion() << "\r\n" - << "Host: localhost\r\n" - << "Content-Type: application/json\r\n" - << "Content-Length: " << strMsg.size() << "\r\n" - << "Connection: close\r\n" - << "Accept: application/json\r\n"; - BOOST_FOREACH (const PAIRTYPE(std::string, std::string) & item, mapRequestHeaders) - s << item.first << ": " << item.second << "\r\n"; - s << "\r\n" - << strMsg; - - return s.str(); -} - -// Send RPC message to KeePassHttp -void CKeePassIntegrator::doHTTPPost(const std::string& sRequest, int& nStatus, std::string& sResponse) -{ - // Prepare communication - boost::asio::io_service io_service; - - // Get a list of endpoints corresponding to the server name. - tcp::resolver resolver(io_service); - tcp::resolver::query query(KEEPASS_KEEPASSHTTP_HOST, boost::lexical_cast(nPort)); - tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); - tcp::resolver::iterator end; - - // Try each endpoint until we successfully establish a connection. - tcp::socket socket(io_service); - boost::system::error_code error = boost::asio::error::host_not_found; - while (error && endpoint_iterator != end) { - socket.close(); - socket.connect(*endpoint_iterator++, error); - } - - if (error) { - throw boost::system::system_error(error); - } - - // Form the request. - std::map mapRequestHeaders; - std::string strPost = constructHTTPPost(sRequest, mapRequestHeaders); - - // Logging of actual post data disabled as to not write passphrase in debug.log. Only enable temporarily when needed - //LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - send POST data: %s\n", strPost); - LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - send POST data\n"); - - boost::asio::streambuf request; - std::ostream request_stream(&request); - request_stream << strPost; - - // Send the request. - boost::asio::write(socket, request); - - LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - request written\n"); - - // Read the response status line. The response streambuf will automatically - // grow to accommodate the entire line. The growth may be limited by passing - // a maximum size to the streambuf constructor. - boost::asio::streambuf response; - boost::asio::read_until(socket, response, "\r\n"); - - LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - request status line read\n"); - - // Receive HTTP reply status - int nProto = 0; - std::istream response_stream(&response); - nStatus = ReadHTTPStatus(response_stream, nProto); - - LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - reading response body start\n"); - // Read until EOF, writing data to output as we go. - while (boost::asio::read(socket, response, boost::asio::transfer_at_least(1), error)) { - if (error != boost::asio::error::eof) { - if (error != 0) { // 0 is success - throw boost::system::system_error(error); - } - } - } - LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - reading response body end\n"); - - // Receive HTTP reply message headers and body - std::map mapHeaders; - ReadHTTPMessage(response_stream, mapHeaders, sResponse, nProto, std::numeric_limits::max()); - LogPrint("keepass", "CKeePassIntegrator::doHTTPPost - Processed body\n"); -} - -void CKeePassIntegrator::rpcTestAssociation(bool bTriggerUnlock) -{ - CKeePassRequest request(sKey, "test-associate"); - request.addStrParameter("TriggerUnlock", std::string(bTriggerUnlock ? "true" : "false")); - - int nStatus; - std::string sResponse; - - doHTTPPost(request.getJson(), nStatus, sResponse); - - LogPrint("keepass", "CKeePassIntegrator::rpcTestAssociation - send result: status: %d response: %s\n", nStatus, sResponse); -} - -std::vector CKeePassIntegrator::rpcGetLogins() -{ - // Convert key format - SecureString sKey = DecodeBase64Secure(sKeyBase64); - - CKeePassRequest request(sKey, "get-logins"); - request.addStrParameter("addStrParameter", std::string("true")); - request.addStrParameter("TriggerUnlock", std::string("true")); - request.addStrParameter("Id", sKeePassId); - request.addStrParameter("Url", sUrl); - - int nStatus; - std::string sResponse; - - doHTTPPost(request.getJson(), nStatus, sResponse); - - // Logging of actual response data disabled as to not write passphrase in debug.log. Only enable temporarily when needed - //LogPrint("keepass", "CKeePassIntegrator::rpcGetLogins - send result: status: %d response: %s\n", nStatus, sResponse); - LogPrint("keepass", "CKeePassIntegrator::rpcGetLogins - send result: status: %d\n", nStatus); - - if (nStatus != 200) { - std::string sErrorMessage = "Error returned by KeePassHttp: HTTP code "; - sErrorMessage += boost::lexical_cast(nStatus); - sErrorMessage += " - Response: "; - sErrorMessage += " response: ["; - sErrorMessage += sResponse; - sErrorMessage += "]"; - throw std::runtime_error(sErrorMessage); - } - - // Parse the response - CKeePassResponse response(sKey, sResponse); - - if (!response.getSuccess()) { - std::string sErrorMessage = "KeePassHttp returned failure status"; - throw std::runtime_error(sErrorMessage); - } - - return response.getEntries(); -} - -void CKeePassIntegrator::rpcSetLogin(const SecureString& strWalletPass, const SecureString& sEntryId) -{ - // Convert key format - SecureString sKey = DecodeBase64Secure(sKeyBase64); - - CKeePassRequest request(sKey, "set-login"); - request.addStrParameter("Id", sKeePassId); - request.addStrParameter("Url", sUrl); - - LogPrint("keepass", "CKeePassIntegrator::rpcSetLogin - send Url: %s\n", sUrl); - - //request.addStrParameter("SubmitUrl", sSubmitUrl); // Is used to construct the entry title - request.addStrParameter("Login", SecureString("pivx")); - request.addStrParameter("Password", strWalletPass); - if (sEntryId.size() != 0) { - request.addStrParameter("Uuid", sEntryId); // Update existing - } - - int nStatus; - std::string sResponse; - - doHTTPPost(request.getJson(), nStatus, sResponse); - - - LogPrint("keepass", "CKeePassIntegrator::rpcSetLogin - send result: status: %d response: %s\n", nStatus, sResponse); - - if (nStatus != 200) { - std::string sErrorMessage = "Error returned: HTTP code "; - sErrorMessage += boost::lexical_cast(nStatus); - sErrorMessage += " - Response: "; - sErrorMessage += " response: ["; - sErrorMessage += sResponse; - sErrorMessage += "]"; - throw std::runtime_error(sErrorMessage); - } - - // Parse the response - CKeePassResponse response(sKey, sResponse); - - if (!response.getSuccess()) { - throw std::runtime_error("KeePassHttp returned failure status"); - } -} - - -SecureString CKeePassIntegrator::generateKeePassKey() -{ - SecureString sKey = generateRandomKey(KEEPASS_CRYPTO_KEY_SIZE); - SecureString sKeyBase64 = EncodeBase64Secure(sKey); - return sKeyBase64; -} - -void CKeePassIntegrator::rpcAssociate(std::string& sId, SecureString& sKeyBase64) -{ - sKey = generateRandomKey(KEEPASS_CRYPTO_KEY_SIZE); - CKeePassRequest request(sKey, "associate"); - - sKeyBase64 = EncodeBase64Secure(sKey); - request.addStrParameter("Key", std::string(&sKeyBase64[0], sKeyBase64.size())); - - int nStatus; - std::string sResponse; - - doHTTPPost(request.getJson(), nStatus, sResponse); - - LogPrint("keepass", "CKeePassIntegrator::rpcAssociate - send result: status: %d response: %s\n", nStatus, sResponse); - - if (nStatus != 200) { - std::string sErrorMessage = "Error returned: HTTP code "; - sErrorMessage += boost::lexical_cast(nStatus); - sErrorMessage += " - Response: "; - sErrorMessage += " response: ["; - sErrorMessage += sResponse; - sErrorMessage += "]"; - throw std::runtime_error(sErrorMessage); - } - - // Parse the response - CKeePassResponse response(sKey, sResponse); - - if (!response.getSuccess()) { - throw std::runtime_error("KeePassHttp returned failure status"); - } - - // If we got here, we were successful. Return the information - sId = response.getStr("Id"); -} - -// Retrieve wallet passphrase from KeePass -SecureString CKeePassIntegrator::retrievePassphrase() -{ - // Check we have all required information - if (sKey.size() == 0) { - throw std::runtime_error("keepasskey parameter is not defined. Please specify the configuration parameter."); - } - if (sKeePassId.size() == 0) { - throw std::runtime_error("keepassid parameter is not defined. Please specify the configuration parameter."); - } - if (sKeePassEntryName == "") { - throw std::runtime_error("keepassname parameter is not defined. Please specify the configuration parameter."); - } - - // Retrieve matching logins from KeePass - std::vector entries = rpcGetLogins(); - - // Only accept one unique match - if (entries.size() == 0) { - throw std::runtime_error("KeePassHttp returned 0 matches, please verify the keepassurl setting."); - } - if (entries.size() > 1) { - throw std::runtime_error("KeePassHttp returned multiple matches, bailing out."); - } - - return entries[0].getPassword(); -} - -// Update wallet passphrase in keepass -void CKeePassIntegrator::updatePassphrase(const SecureString& sWalletPassphrase) -{ - // Check we have all required information - if (sKey.size() == 0) { - throw std::runtime_error("keepasskey parameter is not defined. Please specify the configuration parameter."); - } - if (sKeePassId.size() == 0) { - throw std::runtime_error("keepassid parameter is not defined. Please specify the configuration parameter."); - } - if (sKeePassEntryName == "") { - throw std::runtime_error("keepassname parameter is not defined. Please specify the configuration parameter."); - } - - SecureString sEntryId(""); - - std::string sErrorMessage; - - // Lookup existing entry - std::vector vEntries = rpcGetLogins(); - - if (vEntries.size() > 1) { - throw std::runtime_error("KeePassHttp returned multiple matches, bailing out."); - } - - if (vEntries.size() == 1) { - sEntryId = vEntries[0].getUuid(); - } - - // Update wallet passphrase in KeePass - rpcSetLogin(sWalletPassphrase, sEntryId); -} diff --git a/src/keepass.h b/src/keepass.h deleted file mode 100644 index 3553db338e34d..0000000000000 --- a/src/keepass.h +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2014 The Dash developers -// Copyright (c) 2015-2017 The PIVX developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef _KEEPASS_H_ -#define _KEEPASS_H_ - -#define KEEPASS_CRYPTO_KEY_SIZE 32 -#define KEEPASS_CRYPTO_BLOCK_SIZE 16 -#define KEEPASS_KEEPASSHTTP_HOST "localhost" -#define KEEPASS_KEEPASSHTTP_PORT 19455 - -#include -#include -#include - -#include "allocators.h" -#include "json/json_spirit_value.h" - -class CKeePassIntegrator -{ - bool bIsActive; - unsigned int nPort; - SecureString sKeyBase64; - SecureString sKey; - SecureString sUrl; - //SecureString sSubmitUrl; - std::string sKeePassId; - std::string sKeePassEntryName; - - class CKeePassRequest - { - json_spirit::Object requestObj; - std::string sType; - std::string sIV; - SecureString sKey; - - void init(); - - public: - void addStrParameter(std::string sName, std::string sValue); // Regular - void addStrParameter(std::string sName, SecureString sValue); // Encrypt - std::string getJson(); - - CKeePassRequest(SecureString sKey, std::string sType) - { - this->sKey = sKey; - this->sType = sType; - init(); - }; - }; - - - class CKeePassEntry - { - SecureString uuid; - SecureString name; - SecureString login; - SecureString password; - - public: - CKeePassEntry(SecureString uuid, SecureString name, SecureString login, SecureString password) : uuid(uuid), name(name), login(login), password(password) - { - } - - SecureString getUuid() - { - return uuid; - } - - SecureString getName() - { - return name; - } - - SecureString getLogin() - { - return login; - } - - SecureString getPassword() - { - return password; - } - }; - - - class CKeePassResponse - { - bool bSuccess; - std::string sType; - std::string sIV; - SecureString sKey; - - void parseResponse(std::string sResponse); - - public: - json_spirit::Object responseObj; - CKeePassResponse(SecureString sKey, std::string sResponse) - { - this->sKey = sKey; - parseResponse(sResponse); - } - - bool getSuccess() - { - return bSuccess; - } - - SecureString getSecureStr(std::string sName); - std::string getStr(std::string sName); - std::vector getEntries(); - - SecureString decrypt(std::string sValue); // DecodeBase64 and decrypt arbitrary string value - }; - - static SecureString generateRandomKey(size_t nSize); - static std::string constructHTTPPost(const std::string& strMsg, const std::map& mapRequestHeaders); - void doHTTPPost(const std::string& sRequest, int& nStatus, std::string& sResponse); - void rpcTestAssociation(bool bTriggerUnlock); - std::vector rpcGetLogins(); - void rpcSetLogin(const SecureString& strWalletPass, const SecureString& sEntryId); - -public: - CKeePassIntegrator(); - void init(); - static SecureString generateKeePassKey(); - void rpcAssociate(std::string& sId, SecureString& sKeyBase64); - SecureString retrievePassphrase(); - void updatePassphrase(const SecureString& sWalletPassphrase); -}; - -extern CKeePassIntegrator keePassInt; - -#endif diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 7a189de74f4b0..78b3aa0dc5b1f 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -114,6 +114,7 @@ OverviewPage::OverviewPage(QWidget* parent) : QWidget(parent), txdelegate(new TxViewDelegate()), filter(0) { + nDisplayUnit = 0; // just make sure it's not unitialized ui->setupUi(this); // Recent transactions diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index efaa0d4765d0b..c2e5bda853436 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -59,7 +59,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle* networkStyle) pixPaint.setFont(QFont(font, 28 * fontFactor)); fm = pixPaint.fontMetrics(); - titleTextWidth = fm.width(titleText); + //titleTextWidth = fm.width(titleText); pixPaint.drawText(paddingLeft, paddingTop, titleText); pixPaint.setFont(QFont(font, 15 * fontFactor)); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 380e12a06023e..7b7d9218aa2fc 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -336,7 +336,6 @@ static const CRPCCommand vRPCCommands[] = {"wallet", "importwallet", &importwallet, true, false, true}, {"wallet", "importaddress", &importaddress, true, false, true}, {"wallet", "keypoolrefill", &keypoolrefill, true, false, true}, - {"wallet", "keepass", &keepass, false, false, true}, {"wallet", "listaccounts", &listaccounts, false, false, true}, {"wallet", "listaddressgroupings", &listaddressgroupings, false, false, true}, {"wallet", "listlockunspent", &listlockunspent, false, false, true}, diff --git a/src/rpcserver.h b/src/rpcserver.h index f34d8668c76f4..5f5e8bcf59e20 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -206,7 +206,6 @@ extern json_spirit::Value getinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getwalletinfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getblockchaininfo(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value keepass(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value setmocktime(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value reservebalance(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value multisend(const json_spirit::Array& params, bool fHelp); diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 1f410ca704035..b552752fda04e 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -9,7 +9,6 @@ #include "base58.h" #include "core_io.h" #include "init.h" -#include "keepass.h" #include "net.h" #include "netbase.h" #include "rpcserver.h" @@ -1925,54 +1924,6 @@ Value getwalletinfo(const Array& params, bool fHelp) return obj; } -Value keepass(const Array& params, bool fHelp) -{ - string strCommand; - - if (params.size() >= 1) - strCommand = params[0].get_str(); - - if (fHelp || - (strCommand != "genkey" && strCommand != "init" && strCommand != "setpassphrase")) - throw runtime_error( - "keepass \n"); - - if (strCommand == "genkey") { - SecureString result; - // Generate RSA key - //std::string keePassKey = CKeePassIntegrator::generateKey(); - //return keePassKey; - SecureString sKey = CKeePassIntegrator::generateKeePassKey(); - result = "Generated Key: "; - result += sKey; - return result.c_str(); - } else if (strCommand == "init") { - // Generate base64 encoded 256 bit RSA key and associate with KeePassHttp - SecureString result; - SecureString sKey; - std::string sId; - std::string sErrorMessage; - keePassInt.rpcAssociate(sId, sKey); - result = "Association successful. Id: "; - result += sId.c_str(); - result += " - Key: "; - result += sKey.c_str(); - return result.c_str(); - } else if (strCommand == "setpassphrase") { - if (params.size() != 2) { - return "setlogin: invalid number of parameters. Requires a passphrase"; - } - - SecureString sPassphrase = SecureString(params[1].get_str().c_str()); - - keePassInt.updatePassphrase(sPassphrase); - - return "setlogin: Updated credentials."; - } - - return "Invalid command"; -} - // ppcoin: reserve balance from being staked for network protection Value reservebalance(const Array& params, bool fHelp) { diff --git a/src/util.cpp b/src/util.cpp index 3ec2eebeedbf2..99c6c1c60ac4f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -236,7 +236,6 @@ bool LogAcceptCategory(const char* category) ptrCategory->insert(string("obfuscation")); ptrCategory->insert(string("swifttx")); ptrCategory->insert(string("masternode")); - ptrCategory->insert(string("keepass")); ptrCategory->insert(string("mnpayments")); ptrCategory->insert(string("mnbudget")); } diff --git a/src/wallet.cpp b/src/wallet.cpp index 731c3cc8cc013..10cae439fa87a 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -10,7 +10,6 @@ #include "base58.h" #include "checkpoints.h" #include "coincontrol.h" -#include "keepass.h" #include "kernel.h" #include "masternode-budget.h" #include "net.h" @@ -219,17 +218,8 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool anonymizeOnly return true; } - // Verify KeePassIntegration - if (strWalletPassphrase == "keepass" && GetBoolArg("-keepass", false)) { - try { - strWalletPassphraseFinal = keePassInt.retrievePassphrase(); - } catch (std::exception& e) { - LogPrintf("CWallet::Unlock could not retrieve passphrase from KeePass: Error: %s\n", e.what()); - return false; - } - } else { - strWalletPassphraseFinal = strWalletPassphrase; - } + strWalletPassphraseFinal = strWalletPassphrase; + CCrypter crypter; CKeyingMaterial vMasterKey; @@ -253,23 +243,8 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool anonymizeOnly bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase) { bool fWasLocked = IsLocked(); - bool bUseKeePass = false; - - SecureString strOldWalletPassphraseFinal; - - // Verify KeePassIntegration - if (strOldWalletPassphrase == "keepass" && GetBoolArg("-keepass", false)) { - bUseKeePass = true; - try { - strOldWalletPassphraseFinal = keePassInt.retrievePassphrase(); - } catch (std::exception& e) { - LogPrintf("CWallet::ChangeWalletPassphrase could not retrieve passphrase from KeePass: Error: %s\n", e.what()); - return false; - } - } else { - strOldWalletPassphraseFinal = strOldWalletPassphrase; - } - + SecureString strOldWalletPassphraseFinal = strOldWalletPassphrase; + { LOCK(cs_wallet); Lock(); @@ -303,17 +278,6 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, if (fWasLocked) Lock(); - // Update KeePass if necessary - if (bUseKeePass) { - LogPrintf("CWallet::ChangeWalletPassphrase - Updating KeePass with new passphrase"); - try { - keePassInt.updatePassphrase(strNewWalletPassphrase); - } catch (std::exception& e) { - LogPrintf("CWallet::ChangeWalletPassphrase - could not update passphrase in KeePass: Error: %s\n", e.what()); - return false; - } - } - return true; } } @@ -602,16 +566,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) // bits of the unencrypted private key in slack space in the database file. CDB::Rewrite(strWalletFile); - // Update KeePass if necessary - if (GetBoolArg("-keepass", false)) { - LogPrintf("CWallet::EncryptWallet - Updating KeePass with new passphrase"); - try { - keePassInt.updatePassphrase(strWalletPassphrase); - } catch (std::exception& e) { - LogPrintf("CWallet::EncryptWallet - could not update passphrase in KeePass: Error: %s\n", e.what()); - } - } - } + } NotifyStatusChanged(this); return true;