aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_base64.cpp38
-rw-r--r--tests/test_crypto.cpp8
-rw-r--r--tests/test_olm.cpp2
-rw-r--r--tests/test_olm_decrypt.cpp4
-rw-r--r--tests/test_olm_sha256.cpp2
-rw-r--r--tests/test_olm_signature.cpp2
-rw-r--r--tests/test_olm_using_malloc.cpp2
-rw-r--r--tests/test_ratchet.cpp11
8 files changed, 51 insertions, 18 deletions
diff --git a/tests/test_base64.cpp b/tests/test_base64.cpp
index 5bae2f9..c95e3c9 100644
--- a/tests/test_base64.cpp
+++ b/tests/test_base64.cpp
@@ -1,10 +1,11 @@
#include "olm/base64.hh"
+#include "olm/base64.h"
#include "unittest.hh"
int main() {
{ /* Base64 encode test */
-TestCase test_case("Base64 encode test");
+TestCase test_case("Base64 C++ binding encode test");
std::uint8_t input[] = "Hello World";
std::uint8_t expected_output[] = "SGVsbG8gV29ybGQ";
@@ -18,8 +19,24 @@ olm::encode_base64(input, input_length, output);
assert_equals(expected_output, output, output_length);
}
+{
+TestCase test_case("Base64 C binding encode test");
+
+std::uint8_t input[] = "Hello World";
+std::uint8_t expected_output[] = "SGVsbG8gV29ybGQ";
+std::size_t input_length = sizeof(input) - 1;
+
+std::size_t output_length = ::_olm_encode_base64_length(input_length);
+assert_equals(std::size_t(15), output_length);
+
+std::uint8_t output[output_length];
+output_length = ::_olm_encode_base64(input, input_length, output);
+assert_equals(std::size_t(15), output_length);
+assert_equals(expected_output, output, output_length);
+}
+
{ /* Base64 decode test */
-TestCase test_case("Base64 decode test");
+TestCase test_case("Base64 C++ binding decode test");
std::uint8_t input[] = "SGVsbG8gV29ybGQ";
std::uint8_t expected_output[] = "Hello World";
@@ -33,4 +50,21 @@ olm::decode_base64(input, input_length, output);
assert_equals(expected_output, output, output_length);
}
+{
+TestCase test_case("Base64 C binding decode test");
+
+std::uint8_t input[] = "SGVsbG8gV29ybGQ";
+std::uint8_t expected_output[] = "Hello World";
+std::size_t input_length = sizeof(input) - 1;
+
+std::size_t output_length = ::_olm_decode_base64_length(input_length);
+assert_equals(std::size_t(11), output_length);
+
+std::uint8_t output[output_length];
+output_length = ::_olm_decode_base64(input, input_length, output);
+assert_equals(std::size_t(11), output_length);
+assert_equals(expected_output, output, output_length);
+}
+
+
}
diff --git a/tests/test_crypto.cpp b/tests/test_crypto.cpp
index 4606c52..1041538 100644
--- a/tests/test_crypto.cpp
+++ b/tests/test_crypto.cpp
@@ -186,7 +186,7 @@ std::uint8_t expected[32] = {
std::uint8_t actual[32];
-olm::sha256(input, sizeof(input), actual);
+_olm_crypto_sha256(input, sizeof(input), actual);
assert_equals(expected, actual, 32);
@@ -207,7 +207,7 @@ std::uint8_t expected[32] = {
std::uint8_t actual[32];
-olm::hmac_sha256(input, sizeof(input), input, sizeof(input), actual);
+_olm_crypto_hmac_sha256(input, sizeof(input), input, sizeof(input), actual);
assert_equals(expected, actual, 32);
@@ -242,7 +242,7 @@ std::uint8_t hmac_expected_output[32] = {
std::uint8_t hmac_actual_output[32] = {};
-olm::hmac_sha256(
+_olm_crypto_hmac_sha256(
salt, sizeof(salt),
input, sizeof(input),
hmac_actual_output
@@ -261,7 +261,7 @@ std::uint8_t hkdf_expected_output[42] = {
std::uint8_t hkdf_actual_output[42] = {};
-olm::hkdf_sha256(
+_olm_crypto_hkdf_sha256(
input, sizeof(input),
salt, sizeof(salt),
info, sizeof(info),
diff --git a/tests/test_olm.cpp b/tests/test_olm.cpp
index fbc14cf..de7e236 100644
--- a/tests/test_olm.cpp
+++ b/tests/test_olm.cpp
@@ -1,4 +1,4 @@
-#include "olm/olm.hh"
+#include "olm/olm.h"
#include "unittest.hh"
#include <cstddef>
diff --git a/tests/test_olm_decrypt.cpp b/tests/test_olm_decrypt.cpp
index 2a2db98..95cb18e 100644
--- a/tests/test_olm_decrypt.cpp
+++ b/tests/test_olm_decrypt.cpp
@@ -1,4 +1,4 @@
-#include "olm/olm.hh"
+#include "olm/olm.h"
#include "unittest.hh"
const char * test_cases[] = {
@@ -67,7 +67,7 @@ int main() {
{
TestCase my_test("Olm decrypt test");
-for (int i = 0; i < sizeof(test_cases)/ sizeof(const char *); ++i) {
+for (unsigned int i = 0; i < sizeof(test_cases)/ sizeof(const char *); ++i) {
decrypt_case(0, test_cases[i]);
}
diff --git a/tests/test_olm_sha256.cpp b/tests/test_olm_sha256.cpp
index fe5bf42..c6d0242 100644
--- a/tests/test_olm_sha256.cpp
+++ b/tests/test_olm_sha256.cpp
@@ -1,4 +1,4 @@
-#include "olm/olm.hh"
+#include "olm/olm.h"
#include "unittest.hh"
int main() {
diff --git a/tests/test_olm_signature.cpp b/tests/test_olm_signature.cpp
index a7cce63..d7259de 100644
--- a/tests/test_olm_signature.cpp
+++ b/tests/test_olm_signature.cpp
@@ -1,4 +1,4 @@
-#include "olm/olm.hh"
+#include "olm/olm.h"
#include "unittest.hh"
#include <cstddef>
diff --git a/tests/test_olm_using_malloc.cpp b/tests/test_olm_using_malloc.cpp
index 84fbbd7..fff3ea2 100644
--- a/tests/test_olm_using_malloc.cpp
+++ b/tests/test_olm_using_malloc.cpp
@@ -1,4 +1,4 @@
-#include "olm/olm.hh"
+#include "olm/olm.h"
#include "unittest.hh"
#include <cstddef>
diff --git a/tests/test_ratchet.cpp b/tests/test_ratchet.cpp
index cbb3c52..2f8412e 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,9 +28,8 @@ 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;
@@ -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))];