aboutsummaryrefslogtreecommitdiff
path: root/src/account.cpp
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-06-22 11:02:42 +0100
committerMark Haines <mark.haines@matrix.org>2015-06-22 11:02:42 +0100
commit408530adf9ec0fd7aa8a201103262eebfc9cfc3e (patch)
tree7eeeab21e409727b2d7b2b6b05332046081e8a01 /src/account.cpp
parentfb980849c4ffc99bca7a2dd5a347e9f0b4b99469 (diff)
Add API for removing used one time keys
Diffstat (limited to 'src/account.cpp')
-rw-r--r--src/account.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/account.cpp b/src/account.cpp
index 02ad5ba..95bafa8 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -11,6 +11,18 @@ axolotl::LocalKey const * axolotl::Account::lookup_key(
return 0;
}
+std::size_t axolotl::Account::remove_key(
+ std::uint32_t id
+) {
+ LocalKey * i;
+ for (i = one_time_keys.begin(); i != one_time_keys.end(); ++i) {
+ if (i->id == id) {
+ one_time_keys.erase(i);
+ return id;
+ }
+ }
+ return std::size_t(-1);
+}
std::size_t axolotl::Account::new_account_random_length() {
return 103 * 32;
@@ -21,6 +33,7 @@ std::size_t axolotl::Account::new_account(
) {
if (random_length < new_account_random_length()) {
last_error = axolotl::ErrorCode::NOT_ENOUGH_RANDOM;
+ return std::size_t(-1);
}
unsigned id = 0;
@@ -46,8 +59,6 @@ std::size_t axolotl::Account::new_account(
}
-
-
namespace axolotl {