diff --git a/sys/checksum/Makefile b/sys/crc/Makefile similarity index 100% rename from sys/checksum/Makefile rename to sys/crc/Makefile diff --git a/sys/checksum/crc16_ccitt.c b/sys/crc/crc16_ccitt.c similarity index 97% rename from sys/checksum/crc16_ccitt.c rename to sys/crc/crc16_ccitt.c index a3fb59598c..d22c25a1e4 100644 --- a/sys/checksum/crc16_ccitt.c +++ b/sys/crc/crc16_ccitt.c @@ -7,7 +7,7 @@ */ /** - * @ingroup sys_checksum_crc16_ccitt + * @ingroup sys_crc_crc16_ccitt * @{ * * @file @@ -21,7 +21,7 @@ #include #include -#include "checksum/crc16_ccitt.h" +#include "crc/crc16_ccitt.h" static const uint16_t _crc16_lookuptable[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, diff --git a/sys/include/checksum/doc.txt b/sys/crc/doc.txt similarity index 75% rename from sys/include/checksum/doc.txt rename to sys/crc/doc.txt index c3fc700e56..c2f42a7b6f 100644 --- a/sys/include/checksum/doc.txt +++ b/sys/crc/doc.txt @@ -7,7 +7,7 @@ */ /** - * @defgroup sys_checksum Checksum + * @defgroup sys_crc CRC Cyclic redundancy checks * @ingroup sys - * @brief Checksum function libraries + * @brief CRC hashing functions */ diff --git a/sys/crypto/doc.txt b/sys/crypto/doc.txt index e2195001d2..5e77da4c62 100644 --- a/sys/crypto/doc.txt +++ b/sys/crypto/doc.txt @@ -44,7 +44,4 @@ * * Additional examples can be found in the test suite. * - * @section hashes Hashes - * - * RIOT currently supports sha256 as a cryptographic hash implementation. */ diff --git a/sys/hashes/doc.txt b/sys/hashes/doc.txt new file mode 100644 index 0000000000..63f9e44605 --- /dev/null +++ b/sys/hashes/doc.txt @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 INRIA + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @defgroup sys_hashes Hashes + * @ingroup sys + * + * @brief RIOT provides a collection of hash algorithms. + * + * RIOT supports the following hash functions: + * + * @section Checksums + * + * * Fletcher-16 + * * Fletcher-32 + * + * @section Non-cryptographic hash functions + * + * * Bernstein hash djb2i (http://www.cse.yorku.ca/~oz/hash.html) + * * sdbm (http://www.cse.yorku.ca/~oz/hash.html) + * * Kernighan and Ritchie + * * Shift, And, Xor + * * Donald E. Knuth + * * Fowler–Noll–Vo hash function + * * Rotating Hash + * * One at a time Hash + * + * @section Unkeyed cryptographic hash functions + * + * * MD5 + * * SHA-256 + * + */ diff --git a/sys/crypto/sha256.c b/sys/hashes/sha256.c similarity index 99% rename from sys/crypto/sha256.c rename to sys/hashes/sha256.c index 10d7a06204..f2fc33295a 100644 --- a/sys/crypto/sha256.c +++ b/sys/hashes/sha256.c @@ -28,7 +28,7 @@ */ /** - * @ingroup sys_crypto + * @ingroup sys_hashes * @{ * * @file @@ -43,7 +43,7 @@ #include -#include "crypto/sha256.h" +#include "hashes/sha256.h" #include "board.h" #ifdef __BIG_ENDIAN__ diff --git a/sys/include/checksum/crc16_ccitt.h b/sys/include/crc/crc16_ccitt.h similarity index 95% rename from sys/include/checksum/crc16_ccitt.h rename to sys/include/crc/crc16_ccitt.h index 1eaded39aa..04b29e5827 100644 --- a/sys/include/checksum/crc16_ccitt.h +++ b/sys/include/crc/crc16_ccitt.h @@ -7,8 +7,8 @@ */ /** - * @defgroup sys_checksum_crc16_ccitt CRC16-CCITT - * @ingroup sys_checksum + * @defgroup sys_crc_crc16_ccitt CRC16-CCITT + * @ingroup sys_crc * * @brief CRC16-CCITT checksum algorithm * @details This implementation of CRC16 is based on the CCITT diff --git a/sys/include/hashes.h b/sys/include/hashes.h index fb370d2dad..0950132856 100644 --- a/sys/include/hashes.h +++ b/sys/include/hashes.h @@ -7,7 +7,7 @@ */ /** - * @defgroup sys_hashes Hashes + * @ingroup sys_hashes Hashes * @ingroup sys * @brief Hash function library * @{ @@ -31,7 +31,7 @@ extern "C" { #endif /** - * @brief djb2_hash + * @brief djb2 * * HISTORY * This algorithm (k=33) was first reported by Dan Bernstein many years @@ -50,7 +50,7 @@ extern "C" { uint32_t djb2_hash(const uint8_t *buf, size_t len); /** - * @brief sdbm_hash + * @brief sdbm * * HISTORY * This algorithm was created for sdbm (a public-domain reimplementation @@ -75,7 +75,7 @@ uint32_t djb2_hash(const uint8_t *buf, size_t len); uint32_t sdbm_hash(const uint8_t *buf, size_t len); /** - * @brief lose lose + * @brief Kernighan and Ritchie * * HISTORY * This hash function appeared in K&R (1st ed) but at least the reader @@ -100,9 +100,7 @@ uint32_t sdbm_hash(const uint8_t *buf, size_t len); uint32_t kr_hash(const uint8_t *buf, size_t len); /** - * @brief sax_hash - * - * Shift, Add, XOR + * @brief Shift, Add, XOR * * @param buf input buffer to hash * @param len length of buffer @@ -111,7 +109,7 @@ uint32_t kr_hash(const uint8_t *buf, size_t len); uint32_t sax_hash(const uint8_t *buf, size_t len); /** - * @brief dek_hash + * @brief Donald E. Knuth * * HISTORY * Proposed by Donald E. Knuth in The Art Of Computer Programming Vol. 3, @@ -124,7 +122,7 @@ uint32_t sax_hash(const uint8_t *buf, size_t len); uint32_t dek_hash(const uint8_t *buf, size_t len); /** - * @brief fnv_hash + * @brief Fowler–Noll–Vo * * NOTE * For a more fully featured and modern version of this hash, see fnv32.c @@ -137,7 +135,7 @@ uint32_t fnv_hash(const uint8_t *buf, size_t len); /** - * @brief rotating_hash + * @brief Rotating * * found on * http://burtleburtle.net/bob/hash/doobs.html @@ -149,7 +147,7 @@ uint32_t fnv_hash(const uint8_t *buf, size_t len); uint32_t rotating_hash(const uint8_t *buf, size_t len); /** - * @brief one_at_a_time_hash + * @brief One at a time * * found on * http://burtleburtle.net/bob/hash/doobs.html diff --git a/sys/include/crypto/sha256.h b/sys/include/hashes/sha256.h similarity index 99% rename from sys/include/crypto/sha256.h rename to sys/include/hashes/sha256.h index 194dbf3a81..133910eaac 100644 --- a/sys/include/crypto/sha256.h +++ b/sys/include/hashes/sha256.h @@ -29,7 +29,7 @@ /** - * @ingroup sys_crypto + * @ingroup sys_hashes * @{ * * @file diff --git a/tests/unittests/tests-checksum/Makefile.include b/tests/unittests/tests-checksum/Makefile.include deleted file mode 100644 index 5cbd968a58..0000000000 --- a/tests/unittests/tests-checksum/Makefile.include +++ /dev/null @@ -1 +0,0 @@ -USEMODULE += checksum diff --git a/tests/unittests/tests-checksum/Makefile b/tests/unittests/tests-crc/Makefile similarity index 100% rename from tests/unittests/tests-checksum/Makefile rename to tests/unittests/tests-crc/Makefile diff --git a/tests/unittests/tests-crc/Makefile.include b/tests/unittests/tests-crc/Makefile.include new file mode 100644 index 0000000000..79a6daa4eb --- /dev/null +++ b/tests/unittests/tests-crc/Makefile.include @@ -0,0 +1 @@ +USEMODULE += crc diff --git a/tests/unittests/tests-checksum/tests-checksum-crc16-ccitt.c b/tests/unittests/tests-crc/tests-crc-crc16-ccitt.c similarity index 89% rename from tests/unittests/tests-checksum/tests-checksum-crc16-ccitt.c rename to tests/unittests/tests-crc/tests-crc-crc16-ccitt.c index 2159999eb4..e8c5d82761 100644 --- a/tests/unittests/tests-checksum/tests-checksum-crc16-ccitt.c +++ b/tests/unittests/tests-crc/tests-crc-crc16-ccitt.c @@ -10,9 +10,9 @@ #include "embUnit/embUnit.h" -#include "checksum/crc16_ccitt.h" +#include "crc/crc16_ccitt.h" -#include "tests-checksum.h" +#include "tests-crc.h" static int calc_and_compare_crc_with_update(const unsigned char *buf, size_t len, size_t split, uint16_t expected) @@ -32,7 +32,7 @@ static int calc_and_compare_crc(const unsigned char *buf, size_t len, return result == expected; } -static void test_checksum_crc16_ccitt_sequence(void) +static void test_crc_crc16_ccitt_sequence(void) { /* Reference values according to * http://srecord.sourceforge.net/crc16-ccitt.html */ @@ -85,13 +85,13 @@ static void test_checksum_crc16_ccitt_sequence(void) } } -Test *tests_checksum_crc16_ccitt_tests(void) +Test *tests_crc_crc16_ccitt_tests(void) { EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture(test_checksum_crc16_ccitt_sequence), + new_TestFixture(test_crc_crc16_ccitt_sequence), }; - EMB_UNIT_TESTCALLER(checksum_crc16_ccitt_tests, NULL, NULL, fixtures); + EMB_UNIT_TESTCALLER(crc_crc16_ccitt_tests, NULL, NULL, fixtures); - return (Test *)&checksum_crc16_ccitt_tests; + return (Test *)&crc_crc16_ccitt_tests; } diff --git a/tests/unittests/tests-checksum/tests-checksum.c b/tests/unittests/tests-crc/tests-crc.c similarity index 70% rename from tests/unittests/tests-checksum/tests-checksum.c rename to tests/unittests/tests-crc/tests-crc.c index 356c081ecf..38376518fc 100644 --- a/tests/unittests/tests-checksum/tests-checksum.c +++ b/tests/unittests/tests-crc/tests-crc.c @@ -6,9 +6,9 @@ * directory for more details. */ -#include "tests-checksum.h" +#include "tests-crc.h" -void tests_checksum(void) +void tests_crc(void) { - TESTS_RUN(tests_checksum_crc16_ccitt_tests()); + TESTS_RUN(tests_crc_crc16_ccitt_tests()); } diff --git a/tests/unittests/tests-checksum/tests-checksum.h b/tests/unittests/tests-crc/tests-crc.h similarity index 79% rename from tests/unittests/tests-checksum/tests-checksum.h rename to tests/unittests/tests-crc/tests-crc.h index 10c90e1366..80b0ab3d5c 100644 --- a/tests/unittests/tests-checksum/tests-checksum.h +++ b/tests/unittests/tests-crc/tests-crc.h @@ -11,7 +11,7 @@ * @{ * * @file - * @brief Unittests for the ``checksum`` module + * @brief Unittests for the ``crc`` module * * @author Ludwig Knüpfer */ @@ -28,14 +28,14 @@ extern "C" { /** * @brief The entry point of this test suite. */ -void tests_checksum(void); +void tests_crc(void); /** - * @brief Generates tests for checksum/crc16_ccitt.h + * @brief Generates tests for crc/crc16_ccitt.h * * @return embUnit tests if successful, NULL if not. */ -Test *tests_checksum_crc16_ccitt_tests(void); +Test *tests_crc_crc16_ccitt_tests(void); #ifdef __cplusplus } diff --git a/tests/unittests/tests-crypto/tests-crypto.c b/tests/unittests/tests-crypto/tests-crypto.c index 1d2646bb7e..6914cd5836 100644 --- a/tests/unittests/tests-crypto/tests-crypto.c +++ b/tests/unittests/tests-crypto/tests-crypto.c @@ -11,7 +11,6 @@ void tests_crypto(void) { - TESTS_RUN(tests_crypto_sha256_tests()); TESTS_RUN(tests_crypto_chacha_tests()); TESTS_RUN(tests_crypto_aes_tests()); TESTS_RUN(tests_crypto_3des_tests()); diff --git a/tests/unittests/tests-crypto/tests-crypto.h b/tests/unittests/tests-crypto/tests-crypto.h index d7f05e3824..e03a18bca0 100644 --- a/tests/unittests/tests-crypto/tests-crypto.h +++ b/tests/unittests/tests-crypto/tests-crypto.h @@ -31,13 +31,6 @@ extern "C" { */ void tests_crypto(void); -/** - * @brief Generates tests for crypto/sha256.h - * - * @return embUnit tests if successful, NULL if not. - */ -Test *tests_crypto_sha256_tests(void); - /** * @brief Generates tests for crypto/chacha.h * diff --git a/tests/unittests/tests-crypto/tests-crypto-sha256.c b/tests/unittests/tests-hashes/tests-hashes-sha256.c similarity index 92% rename from tests/unittests/tests-crypto/tests-crypto-sha256.c rename to tests/unittests/tests-hashes/tests-hashes-sha256.c index 4306b8cd90..8029043745 100644 --- a/tests/unittests/tests-crypto/tests-crypto-sha256.c +++ b/tests/unittests/tests-hashes/tests-hashes-sha256.c @@ -14,9 +14,9 @@ #include "embUnit/embUnit.h" -#include "crypto/sha256.h" +#include "hashes/sha256.h" -#include "tests-crypto.h" +#include "tests-hashes.h" static int compare_str_vs_digest(const char *str, const unsigned char hash[SHA256_DIGEST_LENGTH]) @@ -47,7 +47,7 @@ static int calc_and_compare_hash(const char *str, const char *expected) return compare_str_vs_digest(expected, hash); } -static void test_crypto_sha256_hash_sequence(void) +static void test_hashes_sha256_hash_sequence(void) { TEST_ASSERT(calc_and_compare_hash("1234567890_1", "3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0")); @@ -81,14 +81,14 @@ static void test_crypto_sha256_hash_sequence(void) "c19d3bf8588897076873f1a0a106ba840ca46bd1179d592953acecc4df59593c")); } -Test *tests_crypto_sha256_tests(void) +Test *tests_hashes_sha256_tests(void) { EMB_UNIT_TESTFIXTURES(fixtures) { - new_TestFixture(test_crypto_sha256_hash_sequence), + new_TestFixture(test_hashes_sha256_hash_sequence), }; - EMB_UNIT_TESTCALLER(crypto_sha256_tests, NULL, NULL, + EMB_UNIT_TESTCALLER(hashes_sha256_tests, NULL, NULL, fixtures); - return (Test *)&crypto_sha256_tests; + return (Test *)&hashes_sha256_tests; } diff --git a/tests/unittests/tests-hashes/tests-hashes.c b/tests/unittests/tests-hashes/tests-hashes.c index 8d9dc957c0..696999622f 100644 --- a/tests/unittests/tests-hashes/tests-hashes.c +++ b/tests/unittests/tests-hashes/tests-hashes.c @@ -23,4 +23,5 @@ void tests_hashes(void) { TESTS_RUN(tests_hashes_md5_tests()); + TESTS_RUN(tests_hashes_sha256_tests()); } diff --git a/tests/unittests/tests-hashes/tests-hashes.h b/tests/unittests/tests-hashes/tests-hashes.h index 28fc91e1c1..993f641d4d 100644 --- a/tests/unittests/tests-hashes/tests-hashes.h +++ b/tests/unittests/tests-hashes/tests-hashes.h @@ -37,6 +37,14 @@ void tests_hashes(void); */ Test *tests_hashes_md5_tests(void); +/** + * @brief Generates tests for hashes/sha256.h + * + * @return embUnit tests if successful, NULL if not. + */ +Test *tests_hashes_sha256_tests(void); + + #ifdef __cplusplus } #endif