aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_message.cpp11
-rw-r--r--tests/test_ratchet.cpp16
2 files changed, 15 insertions, 12 deletions
diff --git a/tests/test_message.cpp b/tests/test_message.cpp
index ca36ff5..9c0ab4a 100644
--- a/tests/test_message.cpp
+++ b/tests/test_message.cpp
@@ -27,9 +27,9 @@ std::uint8_t hmacsha2[9] = "hmacsha2";
TestCase test_case("Message decode test");
-axolotl::MessageReader reader(axolotl::decode_message(message1, 35, 8));
+axolotl::MessageReader reader;
+axolotl::decode_message(reader, message1, 35, 8);
-assert_equals(std::size_t(27), reader.body_length);
assert_equals(std::uint8_t(3), reader.version);
assert_equals(std::uint32_t(1), reader.counter);
assert_equals(std::size_t(10), reader.ratchet_key_length);
@@ -37,7 +37,6 @@ assert_equals(std::size_t(10), reader.ciphertext_length);
assert_equals(ratchetkey, reader.ratchet_key, 10);
assert_equals(ciphertext, reader.ciphertext, 10);
-assert_equals(hmacsha2, reader.mac, 8);
} /* Message decode test */
@@ -51,12 +50,12 @@ assert_equals(std::size_t(35), length);
std::uint8_t output[length];
-axolotl::MessageWriter writer(axolotl::encode_message(3, 1, 10, 10, output));
-assert_equals(std::size_t(27), writer.body_length);
+axolotl::MessageWriter writer;
+axolotl::encode_message(writer, 3, 1, 10, 10, output);
std::memcpy(writer.ratchet_key, ratchetkey, 10);
std::memcpy(writer.ciphertext, ciphertext, 10);
-std::memcpy(writer.mac, hmacsha2, 8);
+std::memcpy(output + length - 8, hmacsha2, 8);
assert_equals(message2, output, 35);
diff --git a/tests/test_ratchet.cpp b/tests/test_ratchet.cpp
index 95391e3..18c22e3 100644
--- a/tests/test_ratchet.cpp
+++ b/tests/test_ratchet.cpp
@@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "axolotl/ratchet.hh"
+#include "axolotl/cipher.hh"
#include "unittest.hh"
@@ -24,10 +25,13 @@ std::uint8_t message_info[] = "AxolotlMessageKeys";
axolotl::KdfInfo kdf_info = {
root_info, sizeof(root_info) - 1,
- ratchet_info, sizeof(ratchet_info - 1),
- message_info, sizeof(ratchet_info - 1)
+ ratchet_info, sizeof(ratchet_info) - 1
};
+axolotl::CipherAesSha256 cipher(
+ message_info, sizeof(message_info) - 1
+);
+
std::uint8_t random_bytes[] = "0123456789ABDEF0123456789ABCDEF";
axolotl::Curve25519KeyPair bob_key;
axolotl::generate_key(random_bytes, bob_key);
@@ -37,8 +41,8 @@ std::uint8_t shared_secret[] = "A secret";
{ /* Send/Receive test case */
TestCase test_case("Axolotl Send/Receive");
-axolotl::Session alice(kdf_info);
-axolotl::Session bob(kdf_info);
+axolotl::Session alice(kdf_info, cipher);
+axolotl::Session bob(kdf_info, cipher);
alice.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, bob_key);
bob.initialise_as_alice(shared_secret, sizeof(shared_secret) - 1, bob_key);
@@ -106,8 +110,8 @@ std::size_t encrypt_length, decrypt_length;
TestCase test_case("Axolotl Out of Order");
-axolotl::Session alice(kdf_info);
-axolotl::Session bob(kdf_info);
+axolotl::Session alice(kdf_info, cipher);
+axolotl::Session bob(kdf_info, cipher);
alice.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, bob_key);
bob.initialise_as_alice(shared_secret, sizeof(shared_secret) - 1, bob_key);