aboutsummaryrefslogtreecommitdiff
path: root/tests/test_olm_signature.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-05 01:45:06 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-05 01:45:06 +0100
commit2a8202e74846d191a321cca1202175af9db6107d (patch)
treea6f455caf07da1186851f343a237a4c4e4484f46 /tests/test_olm_signature.cpp
parent8efa0ec17d8c262f9c3fd7603e8074f74a053708 (diff)
Convert to sibs projectHEADmaster
Diffstat (limited to 'tests/test_olm_signature.cpp')
-rw-r--r--tests/test_olm_signature.cpp91
1 files changed, 0 insertions, 91 deletions
diff --git a/tests/test_olm_signature.cpp b/tests/test_olm_signature.cpp
deleted file mode 100644
index f53bcec..0000000
--- a/tests/test_olm_signature.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "olm/olm.h"
-#include "unittest.hh"
-
-#include <cstddef>
-#include <cstdint>
-#include <cstring>
-
-struct MockRandom {
- MockRandom(std::uint8_t tag, std::uint8_t offset = 0)
- : tag(tag), current(offset) {}
- void operator()(
- void * buf, std::size_t length
- ) {
- std::uint8_t * bytes = (std::uint8_t *) buf;
- while (length > 32) {
- bytes[0] = tag;
- std::memset(bytes + 1, current, 31);
- length -= 32;
- bytes += 32;
- current += 1;
- }
- if (length) {
- bytes[0] = tag;
- std::memset(bytes + 1, current, length - 1);
- current += 1;
- }
- }
- std::uint8_t tag;
- std::uint8_t current;
-};
-
-std::uint8_t * check_malloc(std::size_t size) {
- if (size == std::size_t(-1)) {
- assert_not_equals(std::size_t(-1), size);
- }
- return (std::uint8_t *)::malloc(size);
-}
-
-
-int main() {
-
-{ /** Signing Test */
-TestCase test_case("Signing test");
-
-MockRandom mock_random_a('A', 0x00);
-
-void * account_buffer = check_malloc(::olm_account_size());
-::OlmAccount * account = ::olm_account(account_buffer);
-
-std::size_t random_size = ::olm_create_account_random_length(account);
-void * random = check_malloc(random_size);
-mock_random_a(random, random_size);
-::olm_create_account(account, random, random_size);
-::free(random);
-
-std::size_t message_size = 12;
-void * message = check_malloc(message_size);
-::memcpy(message, "Hello, World", message_size);
-
-std::size_t signature_size = ::olm_account_signature_length(account);
-void * signature = check_malloc(signature_size);
-assert_not_equals(std::size_t(-1), ::olm_account_sign(
- account, message, message_size, signature, signature_size
-));
-
-std::size_t id_keys_size = ::olm_account_identity_keys_length(account);
-std::uint8_t * id_keys = (std::uint8_t *) check_malloc(id_keys_size);
-assert_not_equals(std::size_t(-1), ::olm_account_identity_keys(
- account, id_keys, id_keys_size
-));
-
-olm_clear_account(account);
-free(account_buffer);
-
-void * utility_buffer = check_malloc(::olm_utility_size());
-::OlmUtility * utility = ::olm_utility(utility_buffer);
-
-assert_not_equals(std::size_t(-1), ::olm_ed25519_verify(
- utility, id_keys + 71, 43, message, message_size, signature, signature_size
-));
-
-olm_clear_utility(utility);
-free(utility_buffer);
-
-free(id_keys);
-free(signature);
-free(message);
-
-}
-
-}