diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-06-11 15:57:45 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-06-11 15:57:45 +0100 |
commit | e44c82a7b4f108086d7d6d203bb129745cd67fc6 (patch) | |
tree | ef42e676cde0f5f26a07a89a0629ebf079343cb9 /src/ratchet.cpp | |
parent | 816435a86097a6609cb6e5ad422083bc49b19632 (diff) |
Add encoder and decoder for PreKey messages
Diffstat (limited to 'src/ratchet.cpp')
-rw-r--r-- | src/ratchet.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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); } |