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.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/test_ratchet.cpp b/tests/test_ratchet.cpp
index cbb3c52..fb60ba9 100644
--- a/tests/test_ratchet.cpp
+++ b/tests/test_ratchet.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "olm/ratchet.hh"
-#include "olm/cipher.hh"
+#include "olm/cipher.h"
#include "unittest.hh"
@@ -28,13 +28,12 @@ olm::KdfInfo kdf_info = {
ratchet_info, sizeof(ratchet_info) - 1
};
-olm::CipherAesSha256 cipher(
- message_info, sizeof(message_info) - 1
-);
+_olm_cipher_aes_sha_256 cipher0 = OLM_CIPHER_INIT_AES_SHA_256(message_info);
+_olm_cipher *cipher = OLM_CIPHER_BASE(&cipher0);
std::uint8_t random_bytes[] = "0123456789ABDEF0123456789ABCDEF";
-olm::Curve25519KeyPair alice_key;
-olm::curve25519_generate_key(random_bytes, alice_key);
+_olm_curve25519_key_pair alice_key;
+_olm_crypto_curve25519_generate_key(random_bytes, &alice_key);
std::uint8_t shared_secret[] = "A secret";
@@ -45,7 +44,7 @@ olm::Ratchet alice(kdf_info, cipher);
olm::Ratchet bob(kdf_info, cipher);
alice.initialise_as_alice(shared_secret, sizeof(shared_secret) - 1, alice_key);
-bob.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, alice_key);
+bob.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, alice_key.public_key);
std::uint8_t plaintext[] = "Message";
std::size_t plaintext_length = sizeof(plaintext) - 1;
@@ -114,7 +113,7 @@ olm::Ratchet alice(kdf_info, cipher);
olm::Ratchet bob(kdf_info, cipher);
alice.initialise_as_alice(shared_secret, sizeof(shared_secret) - 1, alice_key);
-bob.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, alice_key);
+bob.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, alice_key.public_key);
std::uint8_t plaintext_1[] = "First Message";
std::size_t plaintext_1_length = sizeof(plaintext_1) - 1;
@@ -186,7 +185,7 @@ olm::Ratchet alice(kdf_info, cipher);
olm::Ratchet bob(kdf_info, cipher);
alice.initialise_as_alice(shared_secret, sizeof(shared_secret) - 1, alice_key);
-bob.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, alice_key);
+bob.initialise_as_bob(shared_secret, sizeof(shared_secret) - 1, alice_key.public_key);
std::uint8_t plaintext[] = "These 15 bytes";
assert_equals(std::size_t(15), sizeof(plaintext));
@@ -195,7 +194,7 @@ std::uint8_t random[] = "This is a random 32 byte string";
for (unsigned i = 0; i < 8; ++i) {
{
std::uint8_t msg[alice.encrypt_output_length(sizeof(plaintext))];
- std::uint8_t encrypt_length = alice.encrypt(
+ alice.encrypt(
plaintext, 15, random, 32, msg, sizeof(msg)
);
std::uint8_t output[bob.decrypt_max_plaintext_length(msg, sizeof(msg))];
@@ -206,7 +205,7 @@ for (unsigned i = 0; i < 8; ++i) {
random[31]++;
{
std::uint8_t msg[bob.encrypt_output_length(sizeof(plaintext))];
- std::uint8_t encrypt_length = bob.encrypt(
+ bob.encrypt(
plaintext, 15, random, 32, msg, sizeof(msg)
);
std::uint8_t output[alice.decrypt_max_plaintext_length(msg, sizeof(msg))];