aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic/cryptonote_format_utils.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-09-25 16:37:17 +0200
committerRiccardo Spagni <ric@spagni.net>2017-09-25 16:37:17 +0200
commitc6306e75e7bb55c593aa7dcdd697cdc202696e0a (patch)
tree3f07b785f2e2ce47c8e97bdd2a86c9d1bc5f5e32 /src/cryptonote_basic/cryptonote_format_utils.cpp
parentMerge pull request #2496 (diff)
parentwallet: add encrypted seed functionality (diff)
downloadmonero-c6306e75e7bb55c593aa7dcdd697cdc202696e0a.tar.xz
Merge pull request #2257
651baaec wallet: add encrypted seed functionality (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_basic/cryptonote_format_utils.cpp')
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index 745dfb72e..e73f5d778 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -869,4 +869,21 @@ namespace cryptonote
block_hashes_calculated = block_hashes_calculated_count;
block_hashes_cached = block_hashes_cached_count;
}
+ //---------------------------------------------------------------
+ crypto::secret_key encrypt_key(const crypto::secret_key &key, const std::string &passphrase)
+ {
+ crypto::hash hash;
+ crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
+ sc_add((unsigned char*)key.data, (const unsigned char*)key.data, (const unsigned char*)hash.data);
+ return key;
+ }
+ //---------------------------------------------------------------
+ crypto::secret_key decrypt_key(const crypto::secret_key &key, const std::string &passphrase)
+ {
+ crypto::hash hash;
+ crypto::cn_slow_hash(passphrase.data(), passphrase.size(), hash);
+ sc_sub((unsigned char*)key.data, (const unsigned char*)key.data, (const unsigned char*)hash.data);
+ return key;
+ }
+
}