Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

keepass.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2019 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 #ifndef _KEEPASS_H_
6 #define _KEEPASS_H_
7 
9 
10 #include <univalue.h>
11 
12 class CKeePassIntegrator;
13 
14 static const unsigned int DEFAULT_KEEPASS_HTTP_PORT = 19455;
15 
17 
19 private:
20  static const int KEEPASS_CRYPTO_KEY_SIZE = 32;
21  static const int KEEPASS_CRYPTO_BLOCK_SIZE = 16;
22  static const int KEEPASS_HTTP_CONNECT_TIMEOUT = 30;
23  static const char* KEEPASS_HTTP_HOST;
24 
25  bool bIsActive;
26  unsigned int nPort;
30  //SecureString sSubmitUrl;
31  std::string strKeePassId;
32  std::string strKeePassEntryName;
33 
35 
37  std::string strType;
38  std::string strIV;
40 
41  void init();
42 
43  public:
44  void addStrParameter(const std::string& strName, const std::string& strValue); // Regular
45  void addStrParameter(const std::string& strName, const SecureString& sValue); // Encrypt
46  std::string getJson();
47 
48  CKeePassRequest(const SecureString& sKey, const std::string& strType)
49  {
50  this->sKey = sKey;
51  this->strType = strType;
52  init();
53  };
54  };
55 
56 
57  class CKeePassEntry {
58 
63 
64  public:
67  }
68 
70  return sUuid;
71  }
72 
74  return sName;
75  }
76 
78  return sLogin;
79  }
80 
82  return sPassword;
83  }
84 
85  };
86 
87 
89 
90  bool bSuccess;
91  std::string strType;
92  std::string strIV;
94 
95  void parseResponse(const std::string& strResponse);
96 
97  public:
99  CKeePassResponse(const SecureString& sKey, const std::string& strResponse) {
100  this->sKey = sKey;
101  parseResponse(strResponse);
102  }
103 
104  bool getSuccess() {
105  return bSuccess;
106  }
107 
108  SecureString getSecureStr(const std::string& strName);
109  std::string getStr(const std::string& strName);
110  std::vector<CKeePassEntry> getEntries();
111 
112  SecureString decrypt(const std::string& strValue); // DecodeBase64 and decrypt arbitrary string value
113 
114  };
115 
116  static SecureString generateRandomKey(size_t nSize);
117  static std::string constructHTTPPost(const std::string& strMsg, const std::map<std::string,std::string>& mapRequestHeaders);
118  void doHTTPPost(const std::string& strRequest, int& nStatusRet, std::string& strResponseRet);
119  void rpcTestAssociation(bool bTriggerUnlock);
120  std::vector<CKeePassEntry> rpcGetLogins();
121  void rpcSetLogin(const SecureString& sWalletPass, const SecureString& sEntryId);
122 
123 public:
125  void init();
127  void rpcAssociate(std::string& strIdRet, SecureString& sKeyBase64Ret);
129  void updatePassphrase(const SecureString& sWalletPassphrase);
130 
131 };
132 
133 #endif
SecureString sKey
Definition: keepass.h:28
std::string strKeePassId
Definition: keepass.h:31
SecureString sUuid
Definition: keepass.h:59
void parseResponse(const std::string &strResponse)
Definition: keepass.cpp:156
void addStrParameter(const std::string &strName, const std::string &strValue)
Definition: keepass.cpp:123
SecureString sKeyBase64
Definition: keepass.h:27
CKeePassEntry(const SecureString &sUuid, const SecureString &sName, const SecureString &sLogin, const SecureString &sPassword)
Definition: keepass.h:65
void updatePassphrase(const SecureString &sWalletPassphrase)
Definition: keepass.cpp:533
SecureString getPassword()
Definition: keepass.h:81
static const unsigned int DEFAULT_KEEPASS_HTTP_PORT
Definition: keepass.h:14
CKeePassResponse(const SecureString &sKey, const std::string &strResponse)
Definition: keepass.h:99
CKeePassRequest(const SecureString &sKey, const std::string &strType)
Definition: keepass.h:48
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:57
std::vector< CKeePassEntry > getEntries()
Definition: keepass.cpp:205
SecureString sPassword
Definition: keepass.h:62
void rpcAssociate(std::string &strIdRet, SecureString &sKeyBase64Ret)
Definition: keepass.cpp:460
static SecureString generateKeePassKey()
Definition: keepass.cpp:453
static const int KEEPASS_CRYPTO_BLOCK_SIZE
Definition: keepass.h:21
CKeePassIntegrator keePassInt
Definition: keepass.cpp:33
unsigned int nPort
Definition: keepass.h:26
Definition: keepass.h:57
static const int KEEPASS_CRYPTO_KEY_SIZE
Definition: keepass.h:20
std::string strKeePassEntryName
Definition: keepass.h:32
SecureString getUuid()
Definition: keepass.h:69
SecureString getLogin()
Definition: keepass.h:77
void doHTTPPost(const std::string &strRequest, int &nStatusRet, std::string &strResponseRet)
Definition: keepass.cpp:287
SecureString sName
Definition: keepass.h:60
static const int KEEPASS_HTTP_CONNECT_TIMEOUT
Definition: keepass.h:22
SecureString getSecureStr(const std::string &strName)
Definition: keepass.cpp:177
static SecureString generateRandomKey(size_t nSize)
Definition: keepass.cpp:225
SecureString decrypt(const std::string &strValue)
Definition: keepass.cpp:194
SecureString retrievePassphrase()
Definition: keepass.cpp:499
static const char * KEEPASS_HTTP_HOST
Definition: keepass.h:23
void rpcTestAssociation(bool bTriggerUnlock)
Definition: keepass.cpp:349
SecureString sLogin
Definition: keepass.h:61
std::vector< CKeePassEntry > rpcGetLogins()
Definition: keepass.cpp:362
SecureString getName()
Definition: keepass.h:73
void rpcSetLogin(const SecureString &sWalletPass, const SecureString &sEntryId)
Definition: keepass.cpp:404
static std::string constructHTTPPost(const std::string &strMsg, const std::map< std::string, std::string > &mapRequestHeaders)
Definition: keepass.cpp:237
SecureString sUrl
Definition: keepass.h:29
std::string getStr(const std::string &strName)
Definition: keepass.cpp:172
Released under the MIT license