diff options
Diffstat (limited to 'src/ratchet.cpp')
-rw-r--r-- | src/ratchet.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ratchet.cpp b/src/ratchet.cpp index dd1d42c..671d260 100644 --- a/src/ratchet.cpp +++ b/src/ratchet.cpp @@ -363,6 +363,10 @@ std::size_t olm::pickle_length( length += olm::pickle_length(value.sender_chain); length += olm::pickle_length(value.receiver_chains); length += olm::pickle_length(value.skipped_message_keys); + + // the logging_enabled branch includes a 'chain_index' field + length += olm::pickle_length(std::uint32_t(0)); + return length; } @@ -374,18 +378,30 @@ std::uint8_t * olm::pickle( pos = pickle(pos, value.sender_chain); pos = pickle(pos, value.receiver_chains); pos = pickle(pos, value.skipped_message_keys); + + // the logging_enabled branch includes a 'chain_index' field; for us, it is + // empty. + pos = pickle(pos, std::uint32_t(0)); + return pos; } std::uint8_t const * olm::unpickle( std::uint8_t const * pos, std::uint8_t const * end, - olm::Ratchet & value + olm::Ratchet & value, + bool includes_chain_index ) { pos = unpickle(pos, end, value.root_key); pos = unpickle(pos, end, value.sender_chain); pos = unpickle(pos, end, value.receiver_chains); pos = unpickle(pos, end, value.skipped_message_keys); + + // pickle v2 includes a chain index; pickle v1 did not. + if (includes_chain_index) { + std::uint32_t dummy; + pos = unpickle(pos, end, dummy); + } return pos; } |