![]() |
Ethereum
PoC-8
The C++ Implementation of Ethereum
|
#include <SecretStore.h>
Classes | |
| struct | EncryptedKey |
Public Member Functions | |
| SecretStore ()=default | |
| SecretStore (boost::filesystem::path const &_path) | |
| Construct a new SecretStore and read all keys in the given directory. More... | |
| void | setPath (boost::filesystem::path const &_path) |
| Set a path for finding secrets. More... | |
| bytesSec | secret (h128 const &_uuid, std::function< std::string()> const &_pass, bool _useCache=true) const |
| bytesSec | secret (Address const &_address, std::function< std::string()> const &_pass) const |
| h128 | importKey (std::string const &_file) |
| Imports the (encrypted) key stored in the file _file and copies it to the managed directory. More... | |
| h128 | importKeyContent (std::string const &_content) |
| h128 | importSecret (bytesSec const &_s, std::string const &_pass) |
| h128 | importSecret (bytesConstRef _s, std::string const &_pass) |
| bool | recode (h128 const &_uuid, std::string const &_newPass, std::function< std::string()> const &_pass, KDF _kdf=KDF::Scrypt) |
| Decrypts and re-encrypts the key identified by _uuid. More... | |
| bool | recode (Address const &_address, std::string const &_newPass, std::function< std::string()> const &_pass, KDF _kdf=KDF::Scrypt) |
| Decrypts and re-encrypts the key identified by _address. More... | |
| void | kill (h128 const &_uuid) |
| Removes the key specified by _uuid from both memory and disk. More... | |
| std::vector< h128 > | keys () const |
| Returns the uuids of all stored keys. More... | |
| bool | contains (h128 const &_k) const |
| void | clearCache () const |
| h128 | readKey (boost::filesystem::path const &_file, bool _takeFileOwnership) |
| h128 | readKeyContent (std::string const &_content, boost::filesystem::path const &_file=boost::filesystem::path()) |
| void | save (boost::filesystem::path const &_keysPath) |
| Store all keys in the directory _keysPath. More... | |
| void | save () |
| Store all keys in the managed directory. More... | |
| bool | noteAddress (h128 const &_uuid, Address const &_address) |
| Address | address (h128 const &_uuid) const |
Static Public Member Functions | |
| static bytesSec | secret (std::string const &_content, std::string const &_pass) |
| static boost::filesystem::path | defaultPath () |
Manages encrypted keys stored in a certain directory on disk. The keys are read into memory and changes to the keys are automatically synced to the directory. Each file stores exactly one key in a specific JSON format whose file name is derived from the UUID of the key.
Definition at line 48 of file SecretStore.h.
|
default |
Construct a new SecretStore but don't read any keys yet. Call setPath in
| dev::SecretStore::SecretStore | ( | boost::filesystem::path const & | _path | ) |
Construct a new SecretStore and read all keys in the given directory.
Definition at line 121 of file SecretStore.h.
| void SecretStore::clearCache | ( | ) | const |
Clears all cached decrypted keys. The passwords have to be supplied in order to retrieve secrets again after calling this function.
Definition at line 178 of file SecretStore.cpp.
|
inline |
Definition at line 98 of file SecretStore.h.
|
inlinestatic |
Definition at line 124 of file SecretStore.h.
|
inline |
Imports the (encrypted) key stored in the file _file and copies it to the managed directory.
Definition at line 79 of file SecretStore.h.
|
inline |
Imports the (encrypted) key contained in the json formatted _content and stores it in the managed directory.
Definition at line 82 of file SecretStore.h.
| h128 dev::SecretStore::importSecret | ( | bytesConstRef | _s, |
| std::string const & | _pass | ||
| ) |
Imports the decrypted key given by _s and stores it, encrypted with (a key derived from) the password _pass.
|
inline |
Returns the uuids of all stored keys.
Definition at line 95 of file SecretStore.h.
| void SecretStore::kill | ( | h128 const & | _uuid | ) |
Removes the key specified by _uuid from both memory and disk.
Definition at line 168 of file SecretStore.cpp.
Definition at line 205 of file SecretStore.cpp.
| h128 SecretStore::readKey | ( | boost::filesystem::path const & | _file, |
| bool | _takeFileOwnership | ||
| ) |
Import the key from the file _file, but do not copy it to the managed directory yet.
| _takeFileOwnership | if true, deletes the file if it is not the canonical file for the key (derived from its uuid). |
Definition at line 227 of file SecretStore.cpp.
| h128 SecretStore::readKeyContent | ( | std::string const & | _content, |
| boost::filesystem::path const & | _file = boost::filesystem::path() |
||
| ) |
Import the key contained in the json-encoded _content, but do not store it in the managed directory.
| _file | if given, assume this file contains _content and delete it later, if it is not the canonical file for the key (derived from the uuid). |
Definition at line 233 of file SecretStore.cpp.
| bool dev::SecretStore::recode | ( | Address const & | _address, |
| std::string const & | _newPass, | ||
| std::function< std::string()> const & | _pass, | ||
| KDF | _kdf = KDF::Scrypt |
||
| ) |
Decrypts and re-encrypts the key identified by _address.
| bool dev::SecretStore::recode | ( | h128 const & | _uuid, |
| std::string const & | _newPass, | ||
| std::function< std::string()> const & | _pass, | ||
| KDF | _kdf = KDF::Scrypt |
||
| ) |
Decrypts and re-encrypts the key identified by _uuid.
|
inline |
Store all keys in the managed directory.
Definition at line 117 of file SecretStore.h.
| void dev::SecretStore::save | ( | boost::filesystem::path const & | _keysPath | ) |
Store all keys in the directory _keysPath.
| bytesSec dev::SecretStore::secret | ( | Address const & | _address, |
| std::function< std::string()> const & | _pass | ||
| ) | const |
| _pass | function that returns the password for the key. |
| bytesSec dev::SecretStore::secret | ( | h128 const & | _uuid, |
| std::function< std::string()> const & | _pass, | ||
| bool | _useCache = true |
||
| ) | const |
| _pass | function that returns the password for the key. |
| _useCache | if true, allow previously decrypted keys to be returned directly. |
|
static |
| _pass | function that returns the password for the key. |
| void SecretStore::setPath | ( | boost::filesystem::path const & | _path | ) |
Set a path for finding secrets.
Definition at line 99 of file SecretStore.cpp.