aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_crypto.cpp48
-rw-r--r--tests/test_ratchet.cpp10
-rw-r--r--tests/test_session.cpp4
3 files changed, 31 insertions, 31 deletions
diff --git a/tests/test_crypto.cpp b/tests/test_crypto.cpp
index 56abdcd..7dad892 100644
--- a/tests/test_crypto.cpp
+++ b/tests/test_crypto.cpp
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "olm/crypto.hh"
+#include "olm/crypto.h"
#include "unittest.hh"
@@ -58,25 +58,25 @@ std::uint8_t expected_agreement[32] = {
0x76, 0xF0, 0x9B, 0x3C, 0x1E, 0x16, 0x17, 0x42
};
-olm::Curve25519KeyPair alice_pair;
-olm::curve25519_generate_key(alice_private, alice_pair);
+_olm_curve25519_key_pair alice_pair;
+_olm_crypto_curve25519_generate_key(alice_private, &alice_pair);
-assert_equals(alice_private, alice_pair.private_key, 32);
-assert_equals(alice_public, alice_pair.public_key, 32);
+assert_equals(alice_private, alice_pair.private_key.private_key, 32);
+assert_equals(alice_public, alice_pair.public_key.public_key, 32);
-olm::Curve25519KeyPair bob_pair;
-olm::curve25519_generate_key(bob_private, bob_pair);
+_olm_curve25519_key_pair bob_pair;
+_olm_crypto_curve25519_generate_key(bob_private, &bob_pair);
-assert_equals(bob_private, bob_pair.private_key, 32);
-assert_equals(bob_public, bob_pair.public_key, 32);
+assert_equals(bob_private, bob_pair.private_key.private_key, 32);
+assert_equals(bob_public, bob_pair.public_key.public_key, 32);
std::uint8_t actual_agreement[CURVE25519_SHARED_SECRET_LENGTH] = {};
-olm::curve25519_shared_secret(alice_pair, bob_pair, actual_agreement);
+_olm_crypto_curve25519_shared_secret(&alice_pair, &bob_pair.public_key, actual_agreement);
assert_equals(expected_agreement, actual_agreement, 32);
-olm::curve25519_shared_secret(bob_pair, alice_pair, actual_agreement);
+_olm_crypto_curve25519_shared_secret(&bob_pair, &alice_pair.public_key, actual_agreement);
assert_equals(expected_agreement, actual_agreement, 32);
@@ -90,22 +90,22 @@ std::uint8_t private_key[33] = "This key is a string of 32 bytes";
std::uint8_t message[] = "Hello, World";
std::size_t message_length = sizeof(message) - 1;
-olm::Ed25519KeyPair key_pair;
-olm::ed25519_generate_key(private_key, key_pair);
+_olm_ed25519_key_pair key_pair;
+_olm_crypto_ed25519_generate_key(private_key, &key_pair);
std::uint8_t signature[64];
-olm::ed25519_sign(
- key_pair, message, message_length, signature
+_olm_crypto_ed25519_sign(
+ &key_pair, message, message_length, signature
);
-bool result = olm::ed25519_verify(
- key_pair, message, message_length, signature
+bool result = _olm_crypto_ed25519_verify(
+ &key_pair.public_key, message, message_length, signature
);
assert_equals(true, result);
message[0] = 'n';
-result = olm::ed25519_verify(
- key_pair, message, message_length, signature
+result = _olm_crypto_ed25519_verify(
+ &key_pair.public_key, message, message_length, signature
);
assert_equals(false, result);
}
@@ -115,8 +115,8 @@ assert_equals(false, result);
TestCase test_case("AES Test Case 1");
-olm::Aes256Key key = {};
-olm::Aes256Iv iv = {};
+_olm_aes256_key key = {};
+_olm_aes256_iv iv = {};
std::uint8_t input[16] = {};
std::uint8_t expected[32] = {
@@ -126,16 +126,16 @@ std::uint8_t expected[32] = {
0x4B, 0xAE, 0xDF, 0xFC, 0x3D, 0x21, 0x4C, 0x38
};
-std::size_t length = olm::aes_encrypt_cbc_length(sizeof(input));
+std::size_t length = _olm_crypto_aes_encrypt_cbc_length(sizeof(input));
assert_equals(std::size_t(32), length);
std::uint8_t actual[32] = {};
-olm::aes_encrypt_cbc(key, iv, input, sizeof(input), actual);
+_olm_crypto_aes_encrypt_cbc(&key, &iv, input, sizeof(input), actual);
assert_equals(expected, actual, 32);
-length = olm::aes_decrypt_cbc(key, iv, expected, sizeof(expected), actual);
+length = _olm_crypto_aes_decrypt_cbc(&key, &iv, expected, sizeof(expected), actual);
assert_equals(std::size_t(16), length);
assert_equals(input, actual, length);
diff --git a/tests/test_ratchet.cpp b/tests/test_ratchet.cpp
index 2f8412e..fb60ba9 100644
--- a/tests/test_ratchet.cpp
+++ b/tests/test_ratchet.cpp
@@ -32,8 +32,8 @@ _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";
@@ -44,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;
@@ -113,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;
@@ -185,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));
diff --git a/tests/test_session.cpp b/tests/test_session.cpp
index c4c5b2a..e2c3199 100644
--- a/tests/test_session.cpp
+++ b/tests/test_session.cpp
@@ -33,12 +33,12 @@ void check_session(const olm::Session &session) {
assert_equals(
decode_hex("f77a03eaa9b301fa7d2a5aa6b50286906de12cc96044f526dbbcb12839ad7003"),
- session.ratchet.sender_chain[0].ratchet_key.public_key, 32
+ session.ratchet.sender_chain[0].ratchet_key.public_key.public_key, 32
);
assert_equals(
decode_hex("d945c6ed4c7c277117adf11fb133a7936d287afe97c0b3ac989644b4490d4f31"),
- session.ratchet.sender_chain[0].ratchet_key.private_key, 32
+ session.ratchet.sender_chain[0].ratchet_key.private_key.private_key, 32
);
assert_equals(