PR feedback

* write V1 pickles on the master branch
* the logging branch is going to write v0x80000001
This commit is contained in:
Richard van der Hoff 2016-06-30 14:01:02 +01:00
parent 8dd3c182ee
commit d8b24acb77
3 changed files with 12 additions and 19 deletions

View file

@ -363,10 +363,6 @@ std::size_t olm::pickle_length(
length += olm::pickle_length(value.sender_chain); length += olm::pickle_length(value.sender_chain);
length += olm::pickle_length(value.receiver_chains); length += olm::pickle_length(value.receiver_chains);
length += olm::pickle_length(value.skipped_message_keys); 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; return length;
} }
@ -378,11 +374,6 @@ std::uint8_t * olm::pickle(
pos = pickle(pos, value.sender_chain); pos = pickle(pos, value.sender_chain);
pos = pickle(pos, value.receiver_chains); pos = pickle(pos, value.receiver_chains);
pos = pickle(pos, value.skipped_message_keys); 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; return pos;
} }
@ -397,7 +388,7 @@ std::uint8_t const * olm::unpickle(
pos = unpickle(pos, end, value.receiver_chains); pos = unpickle(pos, end, value.receiver_chains);
pos = unpickle(pos, end, value.skipped_message_keys); pos = unpickle(pos, end, value.skipped_message_keys);
// pickle v2 includes a chain index; pickle v1 did not. // pickle v 0x80000001 includes a chain index; pickle v1 does not.
if (includes_chain_index) { if (includes_chain_index) {
std::uint32_t dummy; std::uint32_t dummy;
pos = unpickle(pos, end, dummy); pos = unpickle(pos, end, dummy);

View file

@ -396,7 +396,9 @@ std::size_t olm::Session::decrypt(
} }
namespace { namespace {
static const std::uint32_t SESSION_PICKLE_VERSION = 2; // the master branch writes pickle version 1; the logging_enabled branch writes
// 0x80000001.
static const std::uint32_t SESSION_PICKLE_VERSION = 1;
} }
std::size_t olm::pickle_length( std::size_t olm::pickle_length(
@ -440,7 +442,7 @@ std::uint8_t const * olm::unpickle(
includes_chain_index = false; includes_chain_index = false;
break; break;
case 2: case 0x80000001UL:
includes_chain_index = true; includes_chain_index = true;
break; break;

View file

@ -116,13 +116,13 @@ int main() {
TestCase test_case("V2 session pickle"); TestCase test_case("V2 session pickle");
const uint8_t *PICKLE_KEY=(uint8_t *)"secret_key"; const uint8_t *PICKLE_KEY=(uint8_t *)"secret_key";
uint8_t pickled[1024] = uint8_t pickled[] =
"XTc0/aHUZIVjq257h6sCI1f4/EFJ42QYSOp6SDn88FSXRkO9dfrxGk8gPvZiNCnXFYWggX" "m+DS/q34MXpw2xp50ZD0B7val1mlMpQXo0mx+VPje0weFYRRuuZQBdJgcFPEpi2MVSpA4c"
"UkTkaiSd9MFuj6kB49COlLU1zKw3caJmEIgud7umbYrAXhaBMCTl8T3XFVJK5gXThOE3sI" "qgqHyj2/bU7/lz+BXkEBrCFVx0BJidxXfOLDW4TNtRhLS1YHJNGP8GvTg1+dCytBTLsCdm"
"QCRy4RP4zAVJMTwnvNTzobi3N0aCxEDC+RIol6cEv+bV04zs8wbivdBDVJ7WIDVBF42dzQ" "5f945Eq1U/pY3Cg96YTUufFP6EYrfRoDbAsRHc+h+wKKftQv+W44yUmRhcCemGHtpxk3UQ"
"qPhL4KC5TLB9FYn/eUvrn56tHa5B3udjm1dbPynkjzkRy7Mbp5zUe6XhHDesKo0VxaHhOl" "AMCI7EBv9BvveyZMy3p9qZ3xvFK34Hef+R7gjtFycz7Nk/4UF46sT3cTmUlXz9iFW4uz2F"
"t117bSOKdf72wK/bStaWTpNdAA9h0AFuj2Rgp7E42yJTHY0tv23lMH1Hd+IHdsMsgMcfvL" "rTI1Wjym+l0DadsbSpHSUjmp9zt4qRP2UjwfZ5QNLv+cdObIfqFsiThGu/PlKigdF4SLHr"
"Si"; "nG";
size_t pickle_len = _olm_enc_input( size_t pickle_len = _olm_enc_input(
PICKLE_KEY, strlen((char *)PICKLE_KEY), PICKLE_KEY, strlen((char *)PICKLE_KEY),