aboutsummaryrefslogtreecommitdiff
path: root/include/axolotl/message.hh
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-06-11 14:20:35 +0100
committerMark Haines <mark.haines@matrix.org>2015-06-11 14:20:35 +0100
commit816435a86097a6609cb6e5ad422083bc49b19632 (patch)
tree60be06f84b4fe6ee404b3cbce9b0ca1256bab1cb /include/axolotl/message.hh
parent8161b56ff050b81a20002e9d8addf947625d17be (diff)
Move AES specific details behind a cipher interface
Diffstat (limited to 'include/axolotl/message.hh')
-rw-r--r--include/axolotl/message.hh22
1 files changed, 10 insertions, 12 deletions
diff --git a/include/axolotl/message.hh b/include/axolotl/message.hh
index 5cd4211..cfbb715 100644
--- a/include/axolotl/message.hh
+++ b/include/axolotl/message.hh
@@ -30,22 +30,17 @@ std::size_t encode_message_length(
struct MessageWriter {
- std::size_t body_length;
std::uint8_t * ratchet_key;
std::uint8_t * ciphertext;
- std::uint8_t * mac;
};
struct MessageReader {
- std::size_t body_length;
std::uint8_t version;
std::uint32_t counter;
- std::size_t ratchet_key_length;
- std::size_t ciphertext_length;
- std::uint8_t const * ratchet_key;
- std::uint8_t const * ciphertext;
- std::uint8_t const * mac;
+ std::uint8_t const * input; std::size_t input_length;
+ std::uint8_t const * ratchet_key; std::size_t ratchet_key_length;
+ std::uint8_t const * ciphertext; std::size_t ciphertext_length;
};
@@ -53,7 +48,9 @@ struct MessageReader {
* Writes the message headers into the output buffer.
* Returns a writer struct populated with pointers into the output buffer.
*/
-MessageWriter encode_message(
+
+void encode_message(
+ MessageWriter & writer,
std::uint8_t version,
std::uint32_t counter,
std::size_t ratchet_key_length,
@@ -64,10 +61,11 @@ MessageWriter encode_message(
/**
* Reads the message headers from the input buffer.
- * Returns a reader struct populated with pointers into the input buffer.
- * On failure the returned body_length will be 0.
+ * Populates the reader struct with pointers into the input buffer.
+ * On failure returns std::size_t(-1).
*/
-MessageReader decode_message(
+std::size_t decode_message(
+ MessageReader & reader,
std::uint8_t const * input, std::size_t input_length,
std::size_t mac_length
);