mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 23:23:13 +00:00
libtests/sha: Add tests for SHA512-224
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <sha256.h>
|
||||
#include <sha384.h>
|
||||
#include <sha512.h>
|
||||
#include <sha512t.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -174,6 +175,31 @@ test_sha512_results[RTEMS_ARRAY_SIZE(test_vectors)][SHA512_DIGEST_LENGTH] = {
|
||||
}
|
||||
};
|
||||
|
||||
static const unsigned char test_sha512_224_results
|
||||
[RTEMS_ARRAY_SIZE(test_vectors)][SHA512_224_DIGEST_LENGTH] = {
|
||||
{
|
||||
0x46, 0x34, 0x27, 0x0f, 0x70, 0x7b, 0x6a, 0x54,
|
||||
0xda, 0xae, 0x75, 0x30, 0x46, 0x08, 0x42, 0xe2,
|
||||
0x0e, 0x37, 0xed, 0x26, 0x5c, 0xee, 0xe9, 0xa4,
|
||||
0x3e, 0x89, 0x24, 0xaa
|
||||
}, {
|
||||
0x6e, 0xd0, 0xdd, 0x02, 0x80, 0x6f, 0xa8, 0x9e,
|
||||
0x25, 0xde, 0x06, 0x0c, 0x19, 0xd3, 0xac, 0x86,
|
||||
0xca, 0xbb, 0x87, 0xd6, 0xa0, 0xdd, 0xd0, 0x5c,
|
||||
0x33, 0x3b, 0x84, 0xf4
|
||||
}, {
|
||||
0xe5, 0x30, 0x2d, 0x6d, 0x54, 0xbb, 0x24, 0x22,
|
||||
0x75, 0xd1, 0xe7, 0x62, 0x2d, 0x68, 0xdf, 0x6e,
|
||||
0xb0, 0x2d, 0xed, 0xd1, 0x3f, 0x56, 0x4c, 0x13,
|
||||
0xdb, 0xda, 0x21, 0x74
|
||||
}, {
|
||||
0x23, 0xfe, 0xc5, 0xbb, 0x94, 0xd6, 0x0b, 0x23,
|
||||
0x30, 0x81, 0x92, 0x64, 0x0b, 0x0c, 0x45, 0x33,
|
||||
0x35, 0xd6, 0x64, 0x73, 0x4f, 0xe4, 0x0e, 0x72,
|
||||
0x68, 0x67, 0x4a, 0xf9
|
||||
}
|
||||
};
|
||||
|
||||
static void print_result(const unsigned char *r, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
@@ -285,6 +311,29 @@ static void test_sha512(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void test_sha512_224(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf("test SHA512-224\n");
|
||||
|
||||
for (i = 0; i < RTEMS_ARRAY_SIZE(test_vectors); ++i) {
|
||||
SHA512_CTX ctx;
|
||||
unsigned char r[SHA512_224_DIGEST_LENGTH];
|
||||
const char *s = test_vectors[i];
|
||||
|
||||
SHA512_224_Init(&ctx);
|
||||
SHA512_224_Update(&ctx, s, strlen(s));
|
||||
SHA512_224_Final(r, &ctx);
|
||||
|
||||
print_result(&r[0], sizeof(r));
|
||||
|
||||
rtems_test_assert(
|
||||
memcmp(&r[0], &test_sha512_224_results[i][0], sizeof(r)) == 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
@@ -293,6 +342,7 @@ static void Init(rtems_task_argument arg)
|
||||
test_sha256();
|
||||
test_sha384();
|
||||
test_sha512();
|
||||
test_sha512_224();
|
||||
rtems_stack_checker_report_usage();
|
||||
|
||||
TEST_END();
|
||||
|
||||
Reference in New Issue
Block a user