aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-05-24 13:33:33 +0100
committerRichard van der Hoff <richard@matrix.org>2016-05-24 13:33:33 +0100
commit2e7800cf650197f4b8998ef8ac24d08daa316a2f (patch)
tree1f9e5e06b755f929c7bad363b77eaafdd21d706c /tests
parentb1c5732fc8c89ee9217d0f54408f860565fa01f4 (diff)
parent2fd28a66824bda7b86c08b065736009c39761987 (diff)
Merge branch 'rav/c_bindings'
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.cpp2
-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.cpp7
8 files changed, 48 insertions, 15 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 4ec873c..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[] = {
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 8f89048..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;