#include <PasswordVault.hpp>
Public Member Functions | |
| PasswordVault () | |
| bool | initialize () |
| bool | isUnlocked () const |
| bool | isFirstRun () const |
| bool | createMasterPassword (const std::string &masterPassword) |
| bool | unlock (const std::string &masterPassword) |
| void | lock () |
| std::vector< PasswordEntry > | loadIndex () const |
| bool | saveIndex (const std::vector< PasswordEntry > &entries) const |
| bool | addEntry (const PasswordEntry &entry, const std::string &secret) |
| bool | updateEntry (const PasswordEntry &entry, const std::string &secret) |
| bool | deleteEntry (const std::string &id) |
| void | deleteAllEntries (std::function< void(bool)> onDone) |
| void | addEntriesBulk (const std::vector< std::pair< PasswordEntry, std::string > > &items, std::function< void(int ok, int fail)> onDone) |
| void | exportToCSV (std::function< void(std::string csv, std::string err)> onDone) const |
| void | getSecretAsync (const std::string &id, std::function< void(std::string)> callback) const |
| bool | setSecret (const std::string &id, const std::string &secret) |
| bool | isCacheReady () const |
| std::string | generateId () const |
| std::string | nowIso () const |
| std::string | getIndexPath () const |
Private Member Functions | |
| std::string | getHashPath () const |
| std::string | getSecretsPath () const |
| std::string | pbkdf2Hex (const std::string &password, const std::string &saltHex, int iterations=200000) const |
| std::string | generateSaltHex () const |
| std::string | generateNonceHex () const |
| bool | saveSecretsFile (const std::unordered_map< std::string, std::string > &secrets) const |
| bool | loadSecretsFile (std::unordered_map< std::string, std::string > &secrets) const |
| bool | aesEncrypt (const std::string &key32, const std::string &nonce12, const std::string &plaintext, std::string &ciphertext, std::string &tag16) const |
| bool | aesDecrypt (const std::string &key32, const std::string &nonce12, const std::string &ciphertext, const std::string &tag16, std::string &plaintext) const |
| std::string | deriveKey (const std::string &saltHex) const |
| void | flushAsync (std::unordered_map< std::string, std::string > snapshot) const |
| std::string | makeSecretKey (const std::string &id) const |
Static Private Member Functions | |
| static bool | atomicWriteFile (const std::string &path, const std::string &content) |
Private Attributes | |
| std::atomic< bool > | unlocked_ { false } |
| std::string | masterPassword_ |
| std::unordered_map< std::string, std::string > | secretCache_ |
| std::mutex | cacheMutex_ |
| std::atomic< bool > | cacheReady_ { false } |
Definition at line 32 of file PasswordVault.hpp.
| PasswordVault::PasswordVault | ( | ) |
| void PasswordVault::addEntriesBulk | ( | const std::vector< std::pair< PasswordEntry, std::string > > & | items, |
| std::function< void(int ok, int fail)> | onDone ) |
Definition at line 473 of file PasswordVault.cpp.
References cacheMutex_, flushAsync(), loadIndex(), saveIndex(), secretCache_, and unlocked_.
Referenced by PasswordManagerPage::onImportClicked().
| bool PasswordVault::addEntry | ( | const PasswordEntry & | entry, |
| const std::string & | secret ) |
Definition at line 396 of file PasswordVault.cpp.
References cacheMutex_, flushAsync(), PasswordEntry::id, loadIndex(), PasswordEntry::name, saveIndex(), secretCache_, and unlocked_.
Referenced by PasswordManagerPage::onAddClicked().
|
private |
Definition at line 134 of file PasswordVault.cpp.
Referenced by loadSecretsFile().
|
private |
Definition at line 97 of file PasswordVault.cpp.
Referenced by saveSecretsFile().
|
staticprivate |
Definition at line 85 of file PasswordVault.cpp.
Referenced by createMasterPassword(), deleteAllEntries(), initialize(), saveIndex(), and saveSecretsFile().
| bool PasswordVault::createMasterPassword | ( | const std::string & | masterPassword | ) |
Definition at line 286 of file PasswordVault.cpp.
References atomicWriteFile(), cacheReady_, generateSaltHex(), getHashPath(), masterPassword_, pbkdf2Hex(), and unlocked_.
Referenced by PasswordManagerPage::onUnlockClicked().
| void PasswordVault::deleteAllEntries | ( | std::function< void(bool)> | onDone | ) |
Definition at line 455 of file PasswordVault.cpp.
References atomicWriteFile(), cacheMutex_, getIndexPath(), getSecretsPath(), secretCache_, and unlocked_.
Referenced by PasswordManagerPage::onDeleteAllClicked().
| bool PasswordVault::deleteEntry | ( | const std::string & | id | ) |
Definition at line 434 of file PasswordVault.cpp.
References cacheMutex_, flushAsync(), loadIndex(), saveIndex(), secretCache_, and unlocked_.
Referenced by PasswordManagerPage::onDeleteEntry().
|
private |
Definition at line 170 of file PasswordVault.cpp.
References fromHex(), and masterPassword_.
Referenced by loadSecretsFile(), and saveSecretsFile().
| void PasswordVault::exportToCSV | ( | std::function< void(std::string csv, std::string err)> | onDone | ) | const |
Definition at line 507 of file PasswordVault.cpp.
References cacheMutex_, csvEscape(), loadIndex(), secretCache_, and unlocked_.
Referenced by PasswordVaultView::onExportClicked().
|
private |
Definition at line 389 of file PasswordVault.cpp.
References saveSecretsFile().
Referenced by addEntriesBulk(), addEntry(), deleteEntry(), setSecret(), and updateEntry().
| std::string PasswordVault::generateId | ( | ) | const |
Definition at line 588 of file PasswordVault.cpp.
Referenced by PasswordManagerPage::onAddClicked(), and PasswordManagerPage::onImportClicked().
|
private |
Definition at line 196 of file PasswordVault.cpp.
References toHex().
Referenced by saveSecretsFile().
|
private |
Definition at line 190 of file PasswordVault.cpp.
References toHex().
Referenced by createMasterPassword(), and saveSecretsFile().
|
private |
Definition at line 343 of file PasswordVault.cpp.
Referenced by createMasterPassword(), isFirstRun(), and unlock().
| std::string PasswordVault::getIndexPath | ( | ) | const |
Definition at line 340 of file PasswordVault.cpp.
Referenced by deleteAllEntries(), initialize(), loadIndex(), and saveIndex().
| void PasswordVault::getSecretAsync | ( | const std::string & | id, |
| std::function< void(std::string)> | callback ) const |
Definition at line 539 of file PasswordVault.cpp.
References cacheMutex_, cacheReady_, secretCache_, and unlocked_.
Referenced by PasswordManagerPage::onEditEntry(), PasswordManagerPage::onRevealEntry(), and PasswordVaultView::showEntryDetail().
|
private |
Definition at line 346 of file PasswordVault.cpp.
Referenced by deleteAllEntries(), loadSecretsFile(), and saveSecretsFile().
| bool PasswordVault::initialize | ( | ) |
Definition at line 265 of file PasswordVault.cpp.
References atomicWriteFile(), and getIndexPath().
Referenced by PasswordManagerPage::PasswordManagerPage().
|
inline |
| bool PasswordVault::isFirstRun | ( | ) | const |
Definition at line 281 of file PasswordVault.cpp.
References getHashPath().
Referenced by PasswordManagerPage::onUnlockClicked().
| bool PasswordVault::isUnlocked | ( | ) | const |
Definition at line 279 of file PasswordVault.cpp.
References unlocked_.
Referenced by PasswordManagerPage::onAddClicked(), PasswordManagerPage::onDeleteAllClicked(), PasswordManagerPage::onDeleteEntry(), PasswordManagerPage::onEditEntry(), PasswordManagerPage::onImportClicked(), PasswordManagerPage::onRevealEntry(), PasswordManagerPage::onUnlockClicked(), and PasswordManagerPage::onVaultViewClicked().
| std::vector< PasswordEntry > PasswordVault::loadIndex | ( | ) | const |
Definition at line 353 of file PasswordVault.cpp.
References PasswordEntry::created_at, getIndexPath(), PasswordEntry::id, PasswordEntry::name, PasswordEntry::notes, PasswordEntry::tags, PasswordEntry::updated_at, PasswordEntry::url, and PasswordEntry::username.
Referenced by addEntriesBulk(), addEntry(), deleteEntry(), exportToCSV(), PasswordVaultView::present(), PasswordManagerPage::reload(), and updateEntry().
|
private |
Definition at line 227 of file PasswordVault.cpp.
References aesDecrypt(), deriveKey(), fromHex(), and getSecretsPath().
Referenced by unlock().
| void PasswordVault::lock | ( | ) |
Definition at line 332 of file PasswordVault.cpp.
References cacheMutex_, cacheReady_, masterPassword_, secretCache_, secureClear(), and unlocked_.
Referenced by PasswordManagerPage::onLockClicked().
|
private |
Definition at line 349 of file PasswordVault.cpp.
| std::string PasswordVault::nowIso | ( | ) | const |
Definition at line 606 of file PasswordVault.cpp.
Referenced by PasswordManagerPage::onAddClicked(), and PasswordManagerPage::onImportClicked().
|
private |
Definition at line 179 of file PasswordVault.cpp.
References fromHex(), and toHex().
Referenced by createMasterPassword(), and unlock().
| bool PasswordVault::saveIndex | ( | const std::vector< PasswordEntry > & | entries | ) | const |
Definition at line 379 of file PasswordVault.cpp.
References atomicWriteFile(), and getIndexPath().
Referenced by addEntriesBulk(), addEntry(), deleteEntry(), and updateEntry().
|
private |
Definition at line 203 of file PasswordVault.cpp.
References aesEncrypt(), atomicWriteFile(), deriveKey(), fromHex(), generateNonceHex(), generateSaltHex(), getSecretsPath(), and toHex().
Referenced by flushAsync().
| bool PasswordVault::setSecret | ( | const std::string & | id, |
| const std::string & | secret ) |
Definition at line 576 of file PasswordVault.cpp.
References cacheMutex_, flushAsync(), and secretCache_.
| bool PasswordVault::unlock | ( | const std::string & | masterPassword | ) |
Definition at line 298 of file PasswordVault.cpp.
References cacheMutex_, cacheReady_, getHashPath(), loadSecretsFile(), masterPassword_, pbkdf2Hex(), secretCache_, and unlocked_.
Referenced by PasswordManagerPage::onUnlockClicked().
| bool PasswordVault::updateEntry | ( | const PasswordEntry & | entry, |
| const std::string & | secret ) |
Definition at line 414 of file PasswordVault.cpp.
References cacheMutex_, flushAsync(), PasswordEntry::id, loadIndex(), saveIndex(), secretCache_, and unlocked_.
|
mutableprivate |
Definition at line 74 of file PasswordVault.hpp.
Referenced by addEntriesBulk(), addEntry(), deleteAllEntries(), deleteEntry(), exportToCSV(), getSecretAsync(), lock(), setSecret(), unlock(), and updateEntry().
|
mutableprivate |
Definition at line 75 of file PasswordVault.hpp.
Referenced by createMasterPassword(), getSecretAsync(), isCacheReady(), lock(), and unlock().
|
private |
Definition at line 72 of file PasswordVault.hpp.
Referenced by createMasterPassword(), deriveKey(), lock(), and unlock().
|
mutableprivate |
Definition at line 73 of file PasswordVault.hpp.
Referenced by addEntriesBulk(), addEntry(), deleteAllEntries(), deleteEntry(), exportToCSV(), getSecretAsync(), lock(), setSecret(), unlock(), and updateEntry().
|
private |
Definition at line 71 of file PasswordVault.hpp.
Referenced by addEntriesBulk(), addEntry(), createMasterPassword(), deleteAllEntries(), deleteEntry(), exportToCSV(), getSecretAsync(), isUnlocked(), lock(), PasswordVault(), unlock(), and updateEntry().