aboutsummaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-06-12 16:15:37 +0100
committerMark Haines <mark.haines@matrix.org>2015-06-12 16:15:37 +0100
commit6fe3b7eb73fb11e1cba27b28add5b14430b66259 (patch)
treee2e526e4f5593cb8d978f1b8955b80c9c2d88b4e /src/session.cpp
parent28541dd82a9e4a99661ba32905b8488d35e70fe3 (diff)
Move utils for pickling into a separate file
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 8c4b0b5..db8097f 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -4,6 +4,7 @@
#include "axolotl/account.hh"
#include "axolotl/memory.hh"
#include "axolotl/message.hh"
+#include "axolotl/pickle.hh"
#include <cstring>
@@ -334,3 +335,46 @@ std::size_t axolotl::Session::decrypt(
}
return result;
}
+
+
+std::size_t axolotl::pickle_length(
+ Session const & value
+) {
+ std::size_t length = 0;
+ length += axolotl::pickle_length(value.received_message);
+ length += axolotl::pickle_length(value.alice_identity_key.id);
+ length += axolotl::pickle_length(value.alice_identity_key.key);
+ length += axolotl::pickle_length(value.alice_base_key);
+ length += axolotl::pickle_length(value.bob_one_time_key_id);
+ length += axolotl::pickle_length(value.ratchet);
+ return length;
+}
+
+
+std::uint8_t * axolotl::pickle(
+ std::uint8_t * pos,
+ Session const & value
+) {
+ pos = axolotl::pickle(pos, value.received_message);
+ pos = axolotl::pickle(pos, value.alice_identity_key.id);
+ pos = axolotl::pickle(pos, value.alice_identity_key.key);
+ pos = axolotl::pickle(pos, value.alice_base_key);
+ pos = axolotl::pickle(pos, value.bob_one_time_key_id);
+ pos = axolotl::pickle(pos, value.ratchet);
+ return pos;
+}
+
+
+std::uint8_t const * axolotl::unpickle(
+ std::uint8_t const * pos, std::uint8_t const * end,
+ Session & value
+) {
+ pos = axolotl::unpickle(pos, end, value.received_message);
+ pos = axolotl::unpickle(pos, end, value.alice_identity_key.id);
+ pos = axolotl::unpickle(pos, end, value.alice_identity_key.key);
+ pos = axolotl::unpickle(pos, end, value.alice_base_key);
+ pos = axolotl::unpickle(pos, end, value.bob_one_time_key_id);
+ pos = axolotl::unpickle(pos, end, value.ratchet);
+ return pos;
+}
+