aboutsummaryrefslogtreecommitdiff
path: root/include/axolotl/account.hh
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-06-11 18:03:22 +0100
committerMark Haines <mark.haines@matrix.org>2015-06-11 18:03:22 +0100
commit793b9b910a8f3c010a55433188e4b63414cbb314 (patch)
treeca5f8621273bc4b55f7e584a39529954a84da14c /include/axolotl/account.hh
parentbcb05d1a9982c0a22e41ecfa6f9aba212587c782 (diff)
Start writing the interfaces for session and the account objects
Diffstat (limited to 'include/axolotl/account.hh')
-rw-r--r--include/axolotl/account.hh57
1 files changed, 57 insertions, 0 deletions
diff --git a/include/axolotl/account.hh b/include/axolotl/account.hh
new file mode 100644
index 0000000..5edb799
--- /dev/null
+++ b/include/axolotl/account.hh
@@ -0,0 +1,57 @@
+#ifndef AXOLOTL_ACCOUNT_HH_
+#define AXOLOTL_ACCOUNT_HH_
+
+#include "axolotl/list.hh"
+
+#include <cstdint>
+
+namespace axolotl {
+
+
+struct LocalKey {
+ std::uint32_t id;
+ Curve25519KeyPair key;
+};
+
+
+struct SignedKey : LocalKey {
+ std::uint8_t signature[64];
+};
+
+
+static std::size_t const MAX_ONE_TIME_KEYS = 100;
+
+struct Account {
+ LocalKey identity_key;
+ LocalKey last_resort_one_time_key;
+ List<LocalKey, MAX_ONE_TIME_KEYS> one_time_keys;
+
+ /** Number of random bytes needed to create a new account */
+ std::size_t new_account_random_length();
+
+ /** Create a new account. Returns NOT_ENOUGH_RANDOM if the number of random
+ * bytes is too small. */
+ ErrorCode new_account(
+ uint8_t const * random, std::size_t random_length
+ );
+
+ /** The number of bytes needed to persist this account. */
+ std::size_t pickle_length();
+
+ /** Persists an account as a sequence of bytes
+ * Returns the number of output bytes used. */
+ std::size_t pickle(
+ std::uint8_t * output, std::size_t output_length
+ );
+
+ /** Loads an account from a sequence of bytes.
+ * Returns 0 on success, or std::size_t(-1) on failure. */
+ std::size_t unpickle(
+ std::uint8_t * input, std::size_t input_length
+ );
+};
+
+
+} // namespace axolotl
+
+#endif /* AXOLOTL_ACCOUNT_HH_ */