Dash Core  0.12.2.1
P2P Digital Currency
keepass.cpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2017 The Dash Core developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include "keepass.h"
6 
7 #include "wallet/crypter.h"
8 #include "clientversion.h"
9 #include "protocol.h"
10 #include "random.h"
11 #include "rpc/protocol.h"
12 
13 // Necessary to prevent compile errors due to forward declaration of
14 //CScript in serialize.h (included from crypter.h)
15 #include "script/script.h"
16 #include "script/standard.h"
17 
18 #include "util.h"
19 #include "utilstrencodings.h"
20 
21 #include <boost/foreach.hpp>
22 
23 #include <event2/event.h>
24 #include <event2/http.h>
25 #include <event2/buffer.h>
26 #include <event2/keyvalq_struct.h>
27 
28 #include <openssl/bio.h>
29 #include <openssl/evp.h>
30 #include <openssl/buffer.h>
31 #include "support/cleanse.h" // for OPENSSL_cleanse()
32 
33 const char* CKeePassIntegrator::KEEPASS_HTTP_HOST = "localhost";
34 
36 
37 // Base64 decoding with secure memory allocation
39 {
40  SecureString output;
41 
42  // Init openssl BIO with base64 filter and memory input
43  BIO *b64, *mem;
44  b64 = BIO_new(BIO_f_base64());
45  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer
46  mem = BIO_new_mem_buf((void *) &sInput[0], sInput.size());
47  BIO_push(b64, mem);
48 
49  // Prepare buffer to receive decoded data
50  if(sInput.size() % 4 != 0) {
51  throw std::runtime_error("Input length should be a multiple of 4");
52  }
53  size_t nMaxLen = sInput.size() / 4 * 3; // upper bound, guaranteed divisible by 4
54  output.resize(nMaxLen);
55 
56  // Decode the string
57  size_t nLen;
58  nLen = BIO_read(b64, (void *) &output[0], sInput.size());
59  output.resize(nLen);
60 
61  // Free memory
62  BIO_free_all(b64);
63  return output;
64 }
65 
66 // Base64 encoding with secure memory allocation
68 {
69  // Init openssl BIO with base64 filter and memory output
70  BIO *b64, *mem;
71  b64 = BIO_new(BIO_f_base64());
72  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); // No newlines in output
73  mem = BIO_new(BIO_s_mem());
74  BIO_push(b64, mem);
75 
76  // Decode the string
77  BIO_write(b64, &sInput[0], sInput.size());
78  (void) BIO_flush(b64);
79 
80  // Create output variable from buffer mem ptr
81  BUF_MEM *bptr;
82  BIO_get_mem_ptr(b64, &bptr);
83  SecureString output(bptr->data, bptr->length);
84 
85  // Cleanse secure data buffer from memory
86  memory_cleanse((void *) bptr->data, bptr->length);
87 
88  // Free memory
89  BIO_free_all(b64);
90  return output;
91 }
92 
94  :sKeyBase64(" "), sKey(" "), sUrl(" ") // Prevent LockedPageManagerBase complaints
95 {
96  sKeyBase64.clear(); // Prevent LockedPageManagerBase complaints
97  sKey.clear(); // Prevent LockedPageManagerBase complaints
98  sUrl.clear(); // Prevent LockedPageManagerBase complaints
99  bIsActive = false;
101 }
102 
103 // Initialze from application context
105 {
106  bIsActive = GetBoolArg("-keepass", false);
107  nPort = GetArg("-keepassport", DEFAULT_KEEPASS_HTTP_PORT);
108  sKeyBase64 = SecureString(GetArg("-keepasskey", "").c_str());
109  strKeePassId = GetArg("-keepassid", "");
110  strKeePassEntryName = GetArg("-keepassname", "");
111  // Convert key if available
112  if(sKeyBase64.size() > 0)
113  {
115  }
116  // Construct url if available
117  if(strKeePassEntryName.size() > 0)
118  {
119  sUrl = SecureString("http://");
121  sUrl += SecureString("/");
122  //sSubmitUrl = "http://";
123  //sSubmitUrl += SecureString(strKeePassEntryName.c_str());
124  }
125 }
126 
127 void CKeePassIntegrator::CKeePassRequest::addStrParameter(std::string strName, std::string strValue)
128 {
129  requestObj.push_back(Pair(strName, strValue));
130 }
131 
133 {
134  std::string sCipherValue;
135 
136  if(!EncryptAES256(sKey, sValue, strIV, sCipherValue))
137  {
138  throw std::runtime_error("Unable to encrypt Verifier");
139  }
140 
141  addStrParameter(strName, EncodeBase64(sCipherValue));
142 }
143 
145 {
146  return requestObj.write();
147 }
148 
150 {
152  strIV = std::string(&sIVSecure[0], sIVSecure.size());
153  // Generate Nonce, Verifier and RequestType
154  SecureString sNonceBase64Secure = EncodeBase64Secure(sIVSecure);
155  addStrParameter("Nonce", std::string(&sNonceBase64Secure[0], sNonceBase64Secure.size())); // Plain
156  addStrParameter("Verifier", sNonceBase64Secure); // Encoded
157  addStrParameter("RequestType", strType);
158 }
159 
161 {
162  UniValue responseValue;
163  if(!responseValue.read(strResponse))
164  {
165  throw std::runtime_error("Unable to parse KeePassHttp response");
166  }
167 
168  responseObj = responseValue;
169 
170  // retrieve main values
171  bSuccess = responseObj["Success"].get_bool();
172  strType = getStr("RequestType");
173  strIV = DecodeBase64(getStr("Nonce"));
174 }
175 
176 std::string CKeePassIntegrator::CKeePassResponse::getStr(std::string strName)
177 {
178  return responseObj[strName].get_str();
179 }
180 
182 {
183  std::string strValueBase64Encrypted(responseObj[strName].get_str());
184  SecureString sValue;
185  try
186  {
187  sValue = decrypt(strValueBase64Encrypted);
188  }
189  catch (std::exception &e)
190  {
191  std::string strError = "Exception occured while decrypting ";
192  strError += strName + ": " + e.what();
193  throw std::runtime_error(strError);
194  }
195  return sValue;
196 }
197 
199 {
200  std::string strValueEncrypted = DecodeBase64(strValueBase64Encrypted);
201  SecureString sValue;
202  if(!DecryptAES256(sKey, strValueEncrypted, strIV, sValue))
203  {
204  throw std::runtime_error("Unable to decrypt value.");
205  }
206  return sValue;
207 }
208 
209 std::vector<CKeePassIntegrator::CKeePassEntry> CKeePassIntegrator::CKeePassResponse::getEntries()
210 {
211 
212  std::vector<CKeePassEntry> vEntries;
213 
214  UniValue aEntries = responseObj["Entries"].get_array();
215  for(size_t i = 0; i < aEntries.size(); i++)
216  {
217  SecureString sEntryUuid(decrypt(aEntries[i]["Uuid"].get_str().c_str()));
218  SecureString sEntryName(decrypt(aEntries[i]["Name"].get_str().c_str()));
219  SecureString sEntryLogin(decrypt(aEntries[i]["Login"].get_str().c_str()));
220  SecureString sEntryPassword(decrypt(aEntries[i]["Password"].get_str().c_str()));
221  CKeePassEntry entry(sEntryUuid, sEntryName, sEntryLogin, sEntryPassword);
222  vEntries.push_back(entry);
223  }
224 
225  return vEntries;
226 
227 }
228 
230 {
231  // Generates random key
233  sKey.resize(nSize);
234 
236  GetRandBytes((unsigned char *) &sKey[0], nSize);
237 
238  return sKey;
239 }
240 
241 // Construct POST body for RPC JSON call
242 std::string CKeePassIntegrator::constructHTTPPost(const std::string& strMsg, const std::map<std::string,std::string>& mapRequestHeaders)
243 {
244  std::ostringstream streamOut;
245  streamOut << "POST / HTTP/1.1\r\n"
246  << "User-Agent: dash-json-rpc/" << FormatFullVersion() << "\r\n"
247  << "Host: localhost\r\n"
248  << "Content-Type: application/json\r\n"
249  << "Content-Length: " << strMsg.size() << "\r\n"
250  << "Connection: close\r\n"
251  << "Accept: application/json\r\n";
252  BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, mapRequestHeaders)
253  streamOut << item.first << ": " << item.second << "\r\n";
254  streamOut << "\r\n" << strMsg;
255 
256  return streamOut.str();
257 }
258 
260 struct HTTPReply
261 {
262  int nStatus;
263  std::string strBody;
264 };
265 
266 static void http_request_done(struct evhttp_request *req, void *ctx)
267 {
268  HTTPReply *reply = static_cast<HTTPReply*>(ctx);
269 
270  if (req == NULL) {
271  /* If req is NULL, it means an error occurred while connecting, but
272  * I'm not sure how to find out which one. We also don't really care.
273  */
274  reply->nStatus = 0;
275  return;
276  }
277 
278  reply->nStatus = evhttp_request_get_response_code(req);
279 
280  struct evbuffer *buf = evhttp_request_get_input_buffer(req);
281  if (buf)
282  {
283  size_t size = evbuffer_get_length(buf);
284  const char *data = (const char*)evbuffer_pullup(buf, size);
285  if (data)
286  reply->strBody = std::string(data, size);
287  evbuffer_drain(buf, size);
288  }
289 }
290 
291 // Send RPC message to KeePassHttp
292 void CKeePassIntegrator::doHTTPPost(const std::string& sRequest, int& nStatus, std::string& strResponse)
293 {
294 // // Prepare communication
295 // boost::asio::io_service io_service;
296 
297 // // Get a list of endpoints corresponding to the server name.
298 // tcp::resolver resolver(io_service);
299 // tcp::resolver::query query(KEEPASS_HTTP_HOST, boost::lexical_cast<std::string>(nPort));
300 // tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
301 // tcp::resolver::iterator end;
302 
303 // // Try each endpoint until we successfully establish a connection.
304 // tcp::socket socket(io_service);
305 // boost::system::error_code error = boost::asio::error::host_not_found;
306 // while (error && endpoint_iterator != end)
307 // {
308 // socket.close();
309 // socket.connect(*endpoint_iterator++, error);
310 // }
311 
312 // if(error)
313 // {
314 // throw boost::system::system_error(error);
315 // }
316  // Create event base
317  struct event_base *base = event_base_new(); // TODO RAII
318  if (!base)
319  throw std::runtime_error("cannot create event_base");
320 
321  // Synchronously look up hostname
322  struct evhttp_connection *evcon = evhttp_connection_base_new(base, NULL, KEEPASS_HTTP_HOST, DEFAULT_KEEPASS_HTTP_PORT); // TODO RAII
323  if (evcon == NULL)
324  throw std::runtime_error("create connection failed");
325  evhttp_connection_set_timeout(evcon, KEEPASS_HTTP_CONNECT_TIMEOUT);
326 
327  // Form the request.
328 // std::map<std::string, std::string> mapRequestHeaders;
329 // std::string strPost = constructHTTPPost(sRequest, mapRequestHeaders);
330 
331  HTTPReply response;
332  struct evhttp_request *req = evhttp_request_new(http_request_done, (void*)&response); // TODO RAII
333  if (req == NULL)
334  throw std::runtime_error("create http request failed");
335 
336  struct evkeyvalq *output_headers = evhttp_request_get_output_headers(req);
337  assert(output_headers);
338 // s << "POST / HTTP/1.1\r\n"
339  evhttp_add_header(output_headers, "User-Agent", ("dash-json-rpc/" + FormatFullVersion()).c_str());
340  evhttp_add_header(output_headers, "Host", KEEPASS_HTTP_HOST);
341  evhttp_add_header(output_headers, "Accept", "application/json");
342  evhttp_add_header(output_headers, "Content-Type", "application/json");
343 // evhttp_add_header(output_headers, "Content-Length", itostr(strMsg.size()).c_str());
344  evhttp_add_header(output_headers, "Connection", "close");
345 
346  // Logging of actual post data disabled as to not write passphrase in debug.log. Only enable temporarily when needed
347  //LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- send POST data: %s\n", strPost);
348  LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- send POST data\n");
349 
350 // boost::asio::streambuf request;
351 // std::ostream request_stream(&request);
352 // request_stream << strPost;
353 
354 // // Send the request.
355 // boost::asio::write(socket, request);
356 
357 // LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- request written\n");
358 
359 // // Read the response status line. The response streambuf will automatically
360 // // grow to accommodate the entire line. The growth may be limited by passing
361 // // a maximum size to the streambuf constructor.
362 // boost::asio::streambuf response;
363 // boost::asio::read_until(socket, response, "\r\n");
364 
365 // LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- request status line read\n");
366 
367 // // Receive HTTP reply status
368 // int nProto = 0;
369 // std::istream response_stream(&response);
370 // nStatus = ReadHTTPStatus(response_stream, nProto);
371 
372  // Attach request data
373 // std::string sRequest = JSONRPCRequest(strMethod, params, 1);
374  struct evbuffer * output_buffer = evhttp_request_get_output_buffer(req);
375  assert(output_buffer);
376  evbuffer_add(output_buffer, sRequest.data(), sRequest.size());
377 
378  int r = evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/");
379  if (r != 0) {
380  evhttp_connection_free(evcon);
381  event_base_free(base);
382  throw std::runtime_error("send http request failed");
383  }
384 
385  event_base_dispatch(base);
386  evhttp_connection_free(evcon);
387  event_base_free(base);
388 
389 // LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- reading response body start\n");
390 // // Read until EOF, writing data to output as we go.
391 // while (boost::asio::read(socket, response, boost::asio::transfer_at_least(1), error))
392 // {
393 // if (error != boost::asio::error::eof)
394 // {
395 // if (error != 0)
396 // { // 0 is success
397 // throw boost::system::system_error(error);
398 // }
399 // }
400 // }
401 // LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- reading response body end\n");
402 //
403 // // Receive HTTP reply message headers and body
404 // std::map<std::string, std::string> mapHeaders;
405 // ReadHTTPMessage(response_stream, mapHeaders, strResponse, nProto, std::numeric_limits<size_t>::max());
406 // LogPrint("keepass", "CKeePassIntegrator::doHTTPPost -- Processed body\n");
407 
408  nStatus = response.nStatus;
409  if (response.nStatus == 0)
410  throw std::runtime_error("couldn't connect to server");
411  else if (response.nStatus >= 400 && response.nStatus != HTTP_BAD_REQUEST && response.nStatus != HTTP_NOT_FOUND && response.nStatus != HTTP_INTERNAL_SERVER_ERROR)
412  throw std::runtime_error(strprintf("server returned HTTP error %d", response.nStatus));
413  else if (response.strBody.empty())
414  throw std::runtime_error("no response from server");
415 
416  // Parse reply
417  UniValue valReply(UniValue::VSTR);
418  if (!valReply.read(response.strBody))
419  throw std::runtime_error("couldn't parse reply from server");
420  const UniValue& reply = valReply.get_obj();
421  if (reply.empty())
422  throw std::runtime_error("expected reply to have result, error and id properties");
423 
424  strResponse = valReply.get_str();
425 }
426 
427 void CKeePassIntegrator::rpcTestAssociation(bool bTriggerUnlock)
428 {
429  CKeePassRequest request(sKey, "test-associate");
430  request.addStrParameter("TriggerUnlock", std::string(bTriggerUnlock ? "true" : "false"));
431 
432  int nStatus;
433  std::string strResponse;
434 
435  doHTTPPost(request.getJson(), nStatus, strResponse);
436 
437  LogPrint("keepass", "CKeePassIntegrator::rpcTestAssociation -- send result: status: %d response: %s\n", nStatus, strResponse);
438 }
439 
440 std::vector<CKeePassIntegrator::CKeePassEntry> CKeePassIntegrator::rpcGetLogins()
441 {
442 
443  // Convert key format
445 
446  CKeePassRequest request(sKey, "get-logins");
447  request.addStrParameter("addStrParameter", std::string("true"));
448  request.addStrParameter("TriggerUnlock", std::string("true"));
449  request.addStrParameter("Id", strKeePassId);
450  request.addStrParameter("Url", sUrl);
451 
452  int nStatus;
453  std::string strResponse;
454 
455  doHTTPPost(request.getJson(), nStatus, strResponse);
456 
457  // Logging of actual response data disabled as to not write passphrase in debug.log. Only enable temporarily when needed
458  //LogPrint("keepass", "CKeePassIntegrator::rpcGetLogins -- send result: status: %d response: %s\n", nStatus, strResponse);
459  LogPrint("keepass", "CKeePassIntegrator::rpcGetLogins -- send result: status: %d\n", nStatus);
460 
461  if(nStatus != 200)
462  {
463  std::string strError = "Error returned by KeePassHttp: HTTP code ";
464  strError += itostr(nStatus);
465  strError += " - Response: ";
466  strError += " response: [";
467  strError += strResponse;
468  strError += "]";
469  throw std::runtime_error(strError);
470  }
471 
472  // Parse the response
473  CKeePassResponse response(sKey, strResponse);
474 
475  if(!response.getSuccess())
476  {
477  std::string strError = "KeePassHttp returned failure status";
478  throw std::runtime_error(strError);
479  }
480 
481  return response.getEntries();
482 }
483 
484 void CKeePassIntegrator::rpcSetLogin(const SecureString& sWalletPass, const SecureString& sEntryId)
485 {
486 
487  // Convert key format
489 
490  CKeePassRequest request(sKey, "set-login");
491  request.addStrParameter("Id", strKeePassId);
492  request.addStrParameter("Url", sUrl);
493 
494  LogPrint("keepass", "CKeePassIntegrator::rpcSetLogin -- send Url: %s\n", sUrl);
495 
496  //request.addStrParameter("SubmitUrl", sSubmitUrl); // Is used to construct the entry title
497  request.addStrParameter("Login", SecureString("dash"));
498  request.addStrParameter("Password", sWalletPass);
499  if(sEntryId.size() != 0)
500  {
501  request.addStrParameter("Uuid", sEntryId); // Update existing
502  }
503 
504  int nStatus;
505  std::string strResponse;
506 
507  doHTTPPost(request.getJson(), nStatus, strResponse);
508 
509 
510  LogPrint("keepass", "CKeePassIntegrator::rpcSetLogin -- send result: status: %d response: %s\n", nStatus, strResponse);
511 
512  if(nStatus != 200)
513  {
514  std::string strError = "Error returned: HTTP code ";
515  strError += itostr(nStatus);
516  strError += " - Response: ";
517  strError += " response: [";
518  strError += strResponse;
519  strError += "]";
520  throw std::runtime_error(strError);
521  }
522 
523  // Parse the response
524  CKeePassResponse response(sKey, strResponse);
525 
526  if(!response.getSuccess())
527  {
528  throw std::runtime_error("KeePassHttp returned failure status");
529  }
530 }
531 
532 
534 {
537  return sKeyBase64;
538 }
539 
541 {
543  CKeePassRequest request(sKey, "associate");
544 
546  request.addStrParameter("Key", std::string(&sKeyBase64[0], sKeyBase64.size()));
547 
548  int nStatus;
549  std::string strResponse;
550 
551  doHTTPPost(request.getJson(), nStatus, strResponse);
552 
553  LogPrint("keepass", "CKeePassIntegrator::rpcAssociate -- send result: status: %d response: %s\n", nStatus, strResponse);
554 
555  if(nStatus != 200)
556  {
557  std::string strError = "Error returned: HTTP code ";
558  strError += itostr(nStatus);
559  strError += " - Response: ";
560  strError += " response: [";
561  strError += strResponse;
562  strError += "]";
563  throw std::runtime_error(strError);
564  }
565 
566  // Parse the response
567  CKeePassResponse response(sKey, strResponse);
568 
569  if(!response.getSuccess())
570  {
571  throw std::runtime_error("KeePassHttp returned failure status");
572  }
573 
574  // If we got here, we were successful. Return the information
575  strId = response.getStr("Id");
576 }
577 
578 // Retrieve wallet passphrase from KeePass
580 {
581 
582  // Check we have all required information
583  if(sKey.size() == 0)
584  {
585  throw std::runtime_error("keepasskey parameter is not defined. Please specify the configuration parameter.");
586  }
587  if(strKeePassId.size() == 0)
588  {
589  throw std::runtime_error("keepassid parameter is not defined. Please specify the configuration parameter.");
590  }
591  if(strKeePassEntryName == "")
592  {
593  throw std::runtime_error("keepassname parameter is not defined. Please specify the configuration parameter.");
594  }
595 
596  // Retrieve matching logins from KeePass
597  std::vector<CKeePassIntegrator::CKeePassEntry> vecEntries = rpcGetLogins();
598 
599  // Only accept one unique match
600  if(vecEntries.size() == 0)
601  {
602  throw std::runtime_error("KeePassHttp returned 0 matches, please verify the keepassurl setting.");
603  }
604  if(vecEntries.size() > 1)
605  {
606  throw std::runtime_error("KeePassHttp returned multiple matches, bailing out.");
607  }
608 
609  return vecEntries[0].getPassword();
610 }
611 
612 // Update wallet passphrase in keepass
614 {
615  // Check we have all required information
616  if(sKey.size() == 0)
617  {
618  throw std::runtime_error("keepasskey parameter is not defined. Please specify the configuration parameter.");
619  }
620  if(strKeePassId.size() == 0)
621  {
622  throw std::runtime_error("keepassid parameter is not defined. Please specify the configuration parameter.");
623  }
624  if(strKeePassEntryName == "")
625  {
626  throw std::runtime_error("keepassname parameter is not defined. Please specify the configuration parameter.");
627  }
628 
629  SecureString sEntryId("");
630 
631  std::string strError;
632 
633  // Lookup existing entry
634  std::vector<CKeePassIntegrator::CKeePassEntry> vecEntries = rpcGetLogins();
635 
636  if(vecEntries.size() > 1)
637  {
638  throw std::runtime_error("KeePassHttp returned multiple matches, bailing out.");
639  }
640 
641  if(vecEntries.size() == 1)
642  {
643  sEntryId = vecEntries[0].getUuid();
644  }
645 
646  // Update wallet passphrase in KeePass
647  rpcSetLogin(sWalletPassphrase, sEntryId);
648 }
SecureString decrypt(std::string strValue)
Definition: keepass.cpp:198
std::vector< CKeePassEntry > rpcGetLogins()
Definition: keepass.cpp:440
bool EncryptAES256(const SecureString &sKey, const SecureString &sPlaintext, const std::string &sIV, std::string &sCiphertext)
Definition: crypter.cpp:125
static const unsigned int DEFAULT_KEEPASS_HTTP_PORT
Definition: keepass.h:14
SecureString EncodeBase64Secure(const SecureString &sInput)
Definition: keepass.cpp:67
#define strprintf
Definition: tinyformat.h:1011
struct event_base * base
Definition: torcontrol.cpp:659
void RandAddSeedPerfmon()
Definition: random.cpp:46
SecureString sKey
Definition: keepass.h:28
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:61
std::string strKeePassId
Definition: keepass.h:31
static const char * KEEPASS_HTTP_HOST
Definition: keepass.h:23
static std::string constructHTTPPost(const std::string &strMsg, const std::map< std::string, std::string > &mapRequestHeaders)
Definition: keepass.cpp:242
void rpcTestAssociation(bool bTriggerUnlock)
Definition: keepass.cpp:427
bool DecryptAES256(const SecureString &sKey, const std::string &sCiphertext, const std::string &sIV, SecureString &sPlaintext)
Definition: crypter.cpp:174
bool push_back(const UniValue &val)
Definition: univalue.cpp:176
string EncodeBase64(const unsigned char *pch, size_t len)
void addStrParameter(std::string strName, std::string strValue)
Definition: keepass.cpp:127
SecureString DecodeBase64Secure(const SecureString &sInput)
Definition: keepass.cpp:38
std::string getStr(std::string strName)
Definition: keepass.cpp:176
static SecureString generateRandomKey(size_t nSize)
Definition: keepass.cpp:229
void memory_cleanse(void *ptr, size_t len)
Definition: cleanse.cpp:10
const UniValue & get_obj() const
Definition: univalue.cpp:347
bool GetBoolArg(const std::string &strArg, bool fDefault)
Definition: util.cpp:455
static const int KEEPASS_CRYPTO_BLOCK_SIZE
Definition: keepass.h:21
static int LogPrint(const char *category, const char *format)
Definition: util.h:126
vector< unsigned char > DecodeBase64(const char *p, bool *pfInvalid)
static secp256k1_context * ctx
Definition: tests.c:42
static void http_request_done(struct evhttp_request *req, void *ctx)
Definition: keepass.cpp:266
int nStatus
Definition: keepass.cpp:262
void parseResponse(std::string strResponse)
Definition: keepass.cpp:160
static std::pair< std::string, UniValue > Pair(const char *cKey, const char *cVal)
Definition: univalue.h:166
static const int KEEPASS_HTTP_CONNECT_TIMEOUT
Definition: keepass.h:22
std::string FormatFullVersion()
void updatePassphrase(const SecureString &sWalletPassphrase)
Definition: keepass.cpp:613
CKeePassIntegrator keePassInt
Definition: keepass.cpp:35
void rpcSetLogin(const SecureString &sWalletPass, const SecureString &sEntryId)
Definition: keepass.cpp:484
bool get_bool() const
Definition: univalue.cpp:303
static SecureString generateKeePassKey()
Definition: keepass.cpp:533
SecureString sKeyBase64
Definition: keepass.h:27
void rpcAssociate(std::string &strId, SecureString &sKeyBase64)
Definition: keepass.cpp:540
void GetRandBytes(unsigned char *buf, int num)
Definition: random.cpp:86
std::string strBody
Definition: keepass.cpp:263
SecureString retrievePassphrase()
Definition: keepass.cpp:579
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Definition: util.cpp:441
void doHTTPPost(const std::string &strRequest, int &nStatus, std::string &strResponse)
Definition: keepass.cpp:292
SecureString sUrl
Definition: keepass.h:29
static const int KEEPASS_CRYPTO_KEY_SIZE
Definition: keepass.h:20
std::vector< CKeePassEntry > getEntries()
Definition: keepass.cpp:209
bool read(const char *raw)
bool empty() const
Definition: univalue.h:67
std::string strKeePassEntryName
Definition: keepass.h:32
unsigned int nPort
Definition: keepass.h:26
#define PAIRTYPE(t1, t2)
size_t size() const
Definition: univalue.h:69
const UniValue & get_array() const
Definition: univalue.cpp:354
std::string get_str() const
Definition: univalue.cpp:310
std::string itostr(int n)
SecureString getSecureStr(std::string strName)
Definition: keepass.cpp:181