2021-10-12 21:32:33 +02:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
2021-10-14 21:19:31 +02:00
|
|
|
project(algorithms_test)
|
2022-01-29 17:14:15 +01:00
|
|
|
set(TEST_CATEGORY Algorithms)
|
2021-10-12 21:32:33 +02:00
|
|
|
|
2021-10-14 21:19:31 +02:00
|
|
|
# Add new tests here #
|
|
|
|
set(AVAILABLE_TESTS
|
2021-10-20 11:17:55 +02:00
|
|
|
# Endian
|
|
|
|
32BitIntegerEndianSwap
|
|
|
|
64BitFloatEndianSwap
|
Tests for the CRC and hash algorithms (#335)
* Update TEST_ASSERT to do nothing if condition is true
The TEST_ASSERT should not return if the condition is true, because:
- it prevents the usage of multiple TEST_ASSERT in a single test case,
- that behavior differs from how the assert in the standard library
works, and thus may give unexpected results.
Make the TEST_ASSERT to print an error message (with an formatted
optional user part) when it fails to make debugging easier.
* Fix some bugs in TestProvider, add unit tests
Use pointer-to-vector in TestProvider so writes can be tested, too.
* Add test EncodeDecode16, fix some encode16 bugs
The function mbedtls_mpi_write_string needs a bit longer buffer than the
resulting string actually will be.
Known bug: mbedtls_mpi_read_binary ingores initial null bytes
* Add test EncodeDecode64, fix some bugs
The functions mbedtls_base64_encode and mbedtls_base64_decode needs a
bit longer buffer than the resulting string actually will be.
* Remove check for empty data from TestProvider
It can be valid to get the hash of empty string.
* Add tests for CRC calculation
Two type of thests:
- compare the result of the CRC calculation to a known to be good
results,
- generate random data as message, calculate of it's CRC and append that
to the message, the CRC of this new data should be 0.
* Add test for hash algorithms
* Add includes in tests
* Remove the use of C++20 ranges
It seems that Apple Clang does not support range-based constrained
algorithms at this time.
* Replace encode16 implementation
To encode the zero bytes at the begining of the input vector, too.
2021-11-26 22:14:44 +01:00
|
|
|
|
|
|
|
# Crypto
|
|
|
|
EncodeDecode16
|
|
|
|
EncodeDecode64
|
2022-08-01 13:20:20 +02:00
|
|
|
EncodeDecodeLEB128
|
Tests for the CRC and hash algorithms (#335)
* Update TEST_ASSERT to do nothing if condition is true
The TEST_ASSERT should not return if the condition is true, because:
- it prevents the usage of multiple TEST_ASSERT in a single test case,
- that behavior differs from how the assert in the standard library
works, and thus may give unexpected results.
Make the TEST_ASSERT to print an error message (with an formatted
optional user part) when it fails to make debugging easier.
* Fix some bugs in TestProvider, add unit tests
Use pointer-to-vector in TestProvider so writes can be tested, too.
* Add test EncodeDecode16, fix some encode16 bugs
The function mbedtls_mpi_write_string needs a bit longer buffer than the
resulting string actually will be.
Known bug: mbedtls_mpi_read_binary ingores initial null bytes
* Add test EncodeDecode64, fix some bugs
The functions mbedtls_base64_encode and mbedtls_base64_decode needs a
bit longer buffer than the resulting string actually will be.
* Remove check for empty data from TestProvider
It can be valid to get the hash of empty string.
* Add tests for CRC calculation
Two type of thests:
- compare the result of the CRC calculation to a known to be good
results,
- generate random data as message, calculate of it's CRC and append that
to the message, the CRC of this new data should be 0.
* Add test for hash algorithms
* Add includes in tests
* Remove the use of C++20 ranges
It seems that Apple Clang does not support range-based constrained
algorithms at this time.
* Replace encode16 implementation
To encode the zero bytes at the begining of the input vector, too.
2021-11-26 22:14:44 +01:00
|
|
|
CRC32
|
|
|
|
CRC32Random
|
|
|
|
CRC16
|
|
|
|
CRC16Random
|
|
|
|
CRC8
|
|
|
|
CRC8Random
|
|
|
|
md5
|
|
|
|
sha1
|
|
|
|
sha224
|
|
|
|
sha256
|
|
|
|
sha384
|
|
|
|
sha512
|
2021-10-14 21:19:31 +02:00
|
|
|
)
|
2021-10-12 21:32:33 +02:00
|
|
|
|
|
|
|
|
2022-01-29 17:14:15 +01:00
|
|
|
add_executable(${PROJECT_NAME}
|
2021-10-20 11:17:55 +02:00
|
|
|
source/endian.cpp
|
Tests for the CRC and hash algorithms (#335)
* Update TEST_ASSERT to do nothing if condition is true
The TEST_ASSERT should not return if the condition is true, because:
- it prevents the usage of multiple TEST_ASSERT in a single test case,
- that behavior differs from how the assert in the standard library
works, and thus may give unexpected results.
Make the TEST_ASSERT to print an error message (with an formatted
optional user part) when it fails to make debugging easier.
* Fix some bugs in TestProvider, add unit tests
Use pointer-to-vector in TestProvider so writes can be tested, too.
* Add test EncodeDecode16, fix some encode16 bugs
The function mbedtls_mpi_write_string needs a bit longer buffer than the
resulting string actually will be.
Known bug: mbedtls_mpi_read_binary ingores initial null bytes
* Add test EncodeDecode64, fix some bugs
The functions mbedtls_base64_encode and mbedtls_base64_decode needs a
bit longer buffer than the resulting string actually will be.
* Remove check for empty data from TestProvider
It can be valid to get the hash of empty string.
* Add tests for CRC calculation
Two type of thests:
- compare the result of the CRC calculation to a known to be good
results,
- generate random data as message, calculate of it's CRC and append that
to the message, the CRC of this new data should be 0.
* Add test for hash algorithms
* Add includes in tests
* Remove the use of C++20 ranges
It seems that Apple Clang does not support range-based constrained
algorithms at this time.
* Replace encode16 implementation
To encode the zero bytes at the begining of the input vector, too.
2021-11-26 22:14:44 +01:00
|
|
|
source/crypto.cpp
|
2021-10-20 11:17:55 +02:00
|
|
|
)
|
2021-10-14 21:19:31 +02:00
|
|
|
|
2022-01-29 17:14:15 +01:00
|
|
|
|
|
|
|
# ---- No need to change anything from here downwards unless you know what you're doing ---- #
|
|
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE include)
|
2023-01-04 14:03:09 +01:00
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE libimhex tests_common ${FMT_LIBRARIES})
|
2022-01-29 17:14:15 +01:00
|
|
|
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
2021-10-14 21:19:31 +02:00
|
|
|
|
|
|
|
foreach (test IN LISTS AVAILABLE_TESTS)
|
2022-01-29 17:14:15 +01:00
|
|
|
add_test(NAME "${TEST_CATEGORY}/${test}" COMMAND ${PROJECT_NAME} "${test}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
Tests for the CRC and hash algorithms (#335)
* Update TEST_ASSERT to do nothing if condition is true
The TEST_ASSERT should not return if the condition is true, because:
- it prevents the usage of multiple TEST_ASSERT in a single test case,
- that behavior differs from how the assert in the standard library
works, and thus may give unexpected results.
Make the TEST_ASSERT to print an error message (with an formatted
optional user part) when it fails to make debugging easier.
* Fix some bugs in TestProvider, add unit tests
Use pointer-to-vector in TestProvider so writes can be tested, too.
* Add test EncodeDecode16, fix some encode16 bugs
The function mbedtls_mpi_write_string needs a bit longer buffer than the
resulting string actually will be.
Known bug: mbedtls_mpi_read_binary ingores initial null bytes
* Add test EncodeDecode64, fix some bugs
The functions mbedtls_base64_encode and mbedtls_base64_decode needs a
bit longer buffer than the resulting string actually will be.
* Remove check for empty data from TestProvider
It can be valid to get the hash of empty string.
* Add tests for CRC calculation
Two type of thests:
- compare the result of the CRC calculation to a known to be good
results,
- generate random data as message, calculate of it's CRC and append that
to the message, the CRC of this new data should be 0.
* Add test for hash algorithms
* Add includes in tests
* Remove the use of C++20 ranges
It seems that Apple Clang does not support range-based constrained
algorithms at this time.
* Replace encode16 implementation
To encode the zero bytes at the begining of the input vector, too.
2021-11-26 22:14:44 +01:00
|
|
|
endforeach ()
|
2023-05-20 13:37:57 +02:00
|
|
|
add_dependencies(unit_tests ${PROJECT_NAME})
|