aboutsummaryrefslogtreecommitdiff
path: root/tests/test_crypto.cpp
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2019-04-22 10:12:42 -0400
committerHubert Chathi <hubert@uhoreg.ca>2019-04-22 10:12:42 -0400
commitea13edcae00cc4ab1805e85322e73b7aa2faba7a (patch)
tree1960e726574ebcb8ce52230c0cc86ecce4833f91 /tests/test_crypto.cpp
parent157c0fa67e1ccdaac5a66983004dab8e978f2b4f (diff)
don't use variable length or zero-length arrays in test files
as some compilers don't handle that
Diffstat (limited to 'tests/test_crypto.cpp')
-rw-r--r--tests/test_crypto.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_crypto.cpp b/tests/test_crypto.cpp
index 7dad892..5da742c 100644
--- a/tests/test_crypto.cpp
+++ b/tests/test_crypto.cpp
@@ -146,7 +146,10 @@ assert_equals(input, actual, length);
TestCase test_case("SHA 256 Test Case 1");
-std::uint8_t input[0] = {};
+// we want to take the hash of the empty string, but MSVC doesn't like
+// allocating 0 bytes, so allocate one item, but pass a length of zero to
+// sha256
+std::uint8_t input[1] = {0};
std::uint8_t expected[32] = {
0xE3, 0xB0, 0xC4, 0x42, 0x98, 0xFC, 0x1C, 0x14,
@@ -157,7 +160,7 @@ std::uint8_t expected[32] = {
std::uint8_t actual[32];
-_olm_crypto_sha256(input, sizeof(input), actual);
+_olm_crypto_sha256(input, 0, actual);
assert_equals(expected, actual, 32);
@@ -167,7 +170,10 @@ assert_equals(expected, actual, 32);
TestCase test_case("HMAC Test Case 1");
-std::uint8_t input[0] = {};
+// we want to take the hash of the empty string, but MSVC doesn't like
+// allocating 0 bytes, so allocate one item, but pass a length of zero to
+// hmac_sha256
+std::uint8_t input[1] = {0};
std::uint8_t expected[32] = {
0xb6, 0x13, 0x67, 0x9a, 0x08, 0x14, 0xd9, 0xec,
@@ -178,7 +184,7 @@ std::uint8_t expected[32] = {
std::uint8_t actual[32];
-_olm_crypto_hmac_sha256(input, sizeof(input), input, sizeof(input), actual);
+_olm_crypto_hmac_sha256(input, 0, input, 0, actual);
assert_equals(expected, actual, 32);