aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/account.cpp44
-rw-r--r--src/session.cpp2
2 files changed, 41 insertions, 5 deletions
diff --git a/src/account.cpp b/src/account.cpp
index c73ef1b..02ad5ba 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -2,7 +2,6 @@
#include "axolotl/pickle.hh"
-
axolotl::LocalKey const * axolotl::Account::lookup_key(
std::uint32_t id
) {
@@ -12,6 +11,43 @@ axolotl::LocalKey const * axolotl::Account::lookup_key(
return 0;
}
+
+std::size_t axolotl::Account::new_account_random_length() {
+ return 103 * 32;
+}
+
+std::size_t axolotl::Account::new_account(
+ uint8_t const * random, std::size_t random_length
+) {
+ if (random_length < new_account_random_length()) {
+ last_error = axolotl::ErrorCode::NOT_ENOUGH_RANDOM;
+ }
+
+ unsigned id = 0;
+
+ identity_key.id = ++id;
+ axolotl::generate_key(random, identity_key.key);
+ random += 32;
+
+ random += 32;
+
+ last_resort_one_time_key.id = ++id;
+ axolotl::generate_key(random, last_resort_one_time_key.key);
+ random += 32;
+
+ for (unsigned i = 0; i < 100; ++i) {
+ LocalKey & key = *one_time_keys.insert(one_time_keys.end());
+ key.id = ++id;
+ axolotl::generate_key(random, key.key);
+ random += 32;
+ }
+
+ return 0;
+}
+
+
+
+
namespace axolotl {
@@ -72,7 +108,7 @@ static std::uint8_t const * unpickle(
} // namespace axolotl
-std::size_t pickle_length(
+std::size_t axolotl::pickle_length(
axolotl::Account const & value
) {
std::size_t length = 0;
@@ -83,7 +119,7 @@ std::size_t pickle_length(
}
-std::uint8_t * pickle(
+std::uint8_t * axolotl::pickle(
std::uint8_t * pos,
axolotl::Account const & value
) {
@@ -94,7 +130,7 @@ std::uint8_t * pickle(
}
-std::uint8_t const * unpickle(
+std::uint8_t const * axolotl::unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
axolotl::Account & value
) {
diff --git a/src/session.cpp b/src/session.cpp
index db8097f..0582d56 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -190,7 +190,7 @@ axolotl::MessageType axolotl::Session::encrypt_message_type() {
if (received_message) {
return axolotl::MessageType::MESSAGE;
} else {
- return axolotl::MessageType::PRE_KEY_MESSAGE;
+ return axolotl::MessageType::PRE_KEY;
}
}