aboutsummaryrefslogtreecommitdiff
path: root/tests/test_ratchet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_ratchet.cpp')
-rw-r--r--tests/test_ratchet.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/test_ratchet.cpp b/tests/test_ratchet.cpp
index e262bfa..e1a0519 100644
--- a/tests/test_ratchet.cpp
+++ b/tests/test_ratchet.cpp
@@ -54,13 +54,11 @@ std::size_t message_length, random_length, output_length;
std::size_t encrypt_length, decrypt_length;
{
/* Bob sends Alice a message */
- message_length = bob.encrypt_max_output_length(plaintext_length);
+ message_length = bob.encrypt_output_length(plaintext_length);
random_length = bob.encrypt_random_length();
assert_equals(std::size_t(0), random_length);
- output_length = alice.decrypt_max_plaintext_length(message_length);
std::uint8_t message[message_length];
- std::uint8_t output[output_length];
encrypt_length = bob.encrypt(
plaintext, plaintext_length,
@@ -69,6 +67,8 @@ std::size_t encrypt_length, decrypt_length;
);
assert_equals(message_length, encrypt_length);
+ output_length = alice.decrypt_max_plaintext_length(message, message_length);
+ std::uint8_t output[output_length];
decrypt_length = alice.decrypt(
message, message_length,
output, output_length
@@ -80,13 +80,11 @@ std::size_t encrypt_length, decrypt_length;
{
/* Alice sends Bob a message */
- message_length = alice.encrypt_max_output_length(plaintext_length);
+ message_length = alice.encrypt_output_length(plaintext_length);
random_length = alice.encrypt_random_length();
assert_equals(std::size_t(32), random_length);
- output_length = bob.decrypt_max_plaintext_length(message_length);
std::uint8_t message[message_length];
- std::uint8_t output[output_length];
std::uint8_t random[] = "This is a random 32 byte string.";
encrypt_length = alice.encrypt(
@@ -96,6 +94,8 @@ std::size_t encrypt_length, decrypt_length;
);
assert_equals(message_length, encrypt_length);
+ output_length = bob.decrypt_max_plaintext_length(message, message_length);
+ std::uint8_t output[output_length];
decrypt_length = bob.decrypt(
message, message_length,
output, output_length
@@ -127,7 +127,7 @@ std::size_t encrypt_length, decrypt_length;
{
/* Alice sends Bob two messages and they arrive out of order */
- message_1_length = alice.encrypt_max_output_length(plaintext_1_length);
+ message_1_length = alice.encrypt_output_length(plaintext_1_length);
random_length = alice.encrypt_random_length();
assert_equals(std::size_t(32), random_length);
@@ -140,7 +140,7 @@ std::size_t encrypt_length, decrypt_length;
);
assert_equals(message_1_length, encrypt_length);
- message_2_length = alice.encrypt_max_output_length(plaintext_2_length);
+ message_2_length = alice.encrypt_output_length(plaintext_2_length);
random_length = alice.encrypt_random_length();
assert_equals(std::size_t(0), random_length);
@@ -152,7 +152,9 @@ std::size_t encrypt_length, decrypt_length;
);
assert_equals(message_2_length, encrypt_length);
- output_length = bob.decrypt_max_plaintext_length(message_2_length);
+ output_length = bob.decrypt_max_plaintext_length(
+ message_2, message_2_length
+ );
std::uint8_t output_1[output_length];
decrypt_length = bob.decrypt(
message_2, message_2_length,
@@ -161,7 +163,9 @@ std::size_t encrypt_length, decrypt_length;
assert_equals(plaintext_2_length, decrypt_length);
assert_equals(plaintext_2, output_1, decrypt_length);
- output_length = bob.decrypt_max_plaintext_length(message_1_length);
+ output_length = bob.decrypt_max_plaintext_length(
+ message_1, message_1_length
+ );
std::uint8_t output_2[output_length];
decrypt_length = bob.decrypt(
message_1, message_1_length,