From e44c82a7b4f108086d7d6d203bb129745cd67fc6 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Thu, 11 Jun 2015 15:57:45 +0100 Subject: Add encoder and decoder for PreKey messages --- src/ratchet.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ratchet.cpp') diff --git a/src/ratchet.cpp b/src/ratchet.cpp index cd4f8f7..cbafa83 100644 --- a/src/ratchet.cpp +++ b/src/ratchet.cpp @@ -444,7 +444,7 @@ std::size_t axolotl::Session::decrypt( } axolotl::MessageReader reader; - std::size_t body_length = axolotl::decode_message( + axolotl::decode_message( reader, input, input_length, ratchet_cipher.mac_length() ); @@ -453,7 +453,12 @@ std::size_t axolotl::Session::decrypt( return std::size_t(-1); } - if (body_length == size_t(-1) || reader.ratchet_key_length != KEY_LENGTH) { + if (!reader.has_counter || !reader.ratchet_key || !reader.ciphertext) { + last_error = axolotl::ErrorCode::BAD_MESSAGE_FORMAT; + return std::size_t(-1); + } + + if (reader.ratchet_key_length != KEY_LENGTH) { last_error = axolotl::ErrorCode::BAD_MESSAGE_FORMAT; return std::size_t(-1); } -- cgit v1.2.3