aboutsummaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 4abf6cf..654cf1f 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -353,11 +353,15 @@ std::size_t olm::Session::decrypt(
return result;
}
+namespace {
+static const std::uint32_t SESSION_PICKLE_VERSION = 1;
+}
std::size_t olm::pickle_length(
Session const & value
) {
std::size_t length = 0;
+ length += olm::pickle_length(SESSION_PICKLE_VERSION);
length += olm::pickle_length(value.received_message);
length += olm::pickle_length(value.alice_identity_key);
length += olm::pickle_length(value.alice_base_key);
@@ -371,6 +375,7 @@ std::uint8_t * olm::pickle(
std::uint8_t * pos,
Session const & value
) {
+ pos = olm::pickle(pos, SESSION_PICKLE_VERSION);
pos = olm::pickle(pos, value.received_message);
pos = olm::pickle(pos, value.alice_identity_key);
pos = olm::pickle(pos, value.alice_base_key);
@@ -384,6 +389,12 @@ std::uint8_t const * olm::unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
Session & value
) {
+ uint32_t pickle_version;
+ pos = olm::unpickle(pos, end, pickle_version);
+ if (pickle_version != SESSION_PICKLE_VERSION) {
+ value.last_error = olm::ErrorCode::UNKNOWN_PICKLE_VERSION;
+ return end;
+ }
pos = olm::unpickle(pos, end, value.received_message);
pos = olm::unpickle(pos, end, value.alice_identity_key);
pos = olm::unpickle(pos, end, value.alice_base_key);