mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-17 18:43:50 +01:00
sha256: move from crypto to hashes
This commit is contained in:
parent
f4006a67f1
commit
51db509f7c
@ -44,7 +44,4 @@
|
|||||||
*
|
*
|
||||||
* Additional examples can be found in the test suite.
|
* Additional examples can be found in the test suite.
|
||||||
*
|
*
|
||||||
* @section hashes Hashes
|
|
||||||
*
|
|
||||||
* RIOT currently supports sha256 as a cryptographic hash implementation.
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup sys_crypto
|
* @ingroup sys_hashes
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "crypto/sha256.h"
|
#include "hashes/sha256.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
#ifdef __BIG_ENDIAN__
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup sys_crypto
|
* @ingroup sys_hashes
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
* @file
|
* @file
|
||||||
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
void tests_crypto(void)
|
void tests_crypto(void)
|
||||||
{
|
{
|
||||||
TESTS_RUN(tests_crypto_sha256_tests());
|
|
||||||
TESTS_RUN(tests_crypto_chacha_tests());
|
TESTS_RUN(tests_crypto_chacha_tests());
|
||||||
TESTS_RUN(tests_crypto_aes_tests());
|
TESTS_RUN(tests_crypto_aes_tests());
|
||||||
TESTS_RUN(tests_crypto_3des_tests());
|
TESTS_RUN(tests_crypto_3des_tests());
|
||||||
|
|||||||
@ -31,13 +31,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
void tests_crypto(void);
|
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
|
* @brief Generates tests for crypto/chacha.h
|
||||||
*
|
*
|
||||||
|
|||||||
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
#include "embUnit/embUnit.h"
|
#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,
|
static int compare_str_vs_digest(const char *str,
|
||||||
const unsigned char hash[SHA256_DIGEST_LENGTH])
|
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);
|
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",
|
TEST_ASSERT(calc_and_compare_hash("1234567890_1",
|
||||||
"3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0"));
|
"3eda9ffe5537a588f54d0b2a453e5fa932986d0bc0f9556924f5c2379b2c91b0"));
|
||||||
@ -81,14 +81,14 @@ static void test_crypto_sha256_hash_sequence(void)
|
|||||||
"c19d3bf8588897076873f1a0a106ba840ca46bd1179d592953acecc4df59593c"));
|
"c19d3bf8588897076873f1a0a106ba840ca46bd1179d592953acecc4df59593c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Test *tests_crypto_sha256_tests(void)
|
Test *tests_hashes_sha256_tests(void)
|
||||||
{
|
{
|
||||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
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);
|
fixtures);
|
||||||
|
|
||||||
return (Test *)&crypto_sha256_tests;
|
return (Test *)&hashes_sha256_tests;
|
||||||
}
|
}
|
||||||
@ -23,4 +23,5 @@
|
|||||||
void tests_hashes(void)
|
void tests_hashes(void)
|
||||||
{
|
{
|
||||||
TESTS_RUN(tests_hashes_md5_tests());
|
TESTS_RUN(tests_hashes_md5_tests());
|
||||||
|
TESTS_RUN(tests_hashes_sha256_tests());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,14 @@ void tests_hashes(void);
|
|||||||
*/
|
*/
|
||||||
Test *tests_hashes_md5_tests(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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user