diff options
Diffstat (limited to 'testsuites/libtests')
-rw-r--r-- | testsuites/libtests/sha/init.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/testsuites/libtests/sha/init.c b/testsuites/libtests/sha/init.c index 49cc17db44..43ba8e843d 100644 --- a/testsuites/libtests/sha/init.c +++ b/testsuites/libtests/sha/init.c @@ -31,6 +31,7 @@ #include <sha224.h> #include <sha256.h> +#include <sha384.h> #include <sha512.h> #include <stdio.h> #include <string.h> @@ -100,6 +101,39 @@ test_sha256_results[RTEMS_ARRAY_SIZE(test_vectors)][SHA256_DIGEST_LENGTH] = { }; static const unsigned char +test_sha384_results[RTEMS_ARRAY_SIZE(test_vectors)][SHA384_DIGEST_LENGTH] = { + { + 0xcb, 0x00, 0x75, 0x3f, 0x45, 0xa3, 0x5e, 0x8b, + 0xb5, 0xa0, 0x3d, 0x69, 0x9a, 0xc6, 0x50, 0x07, + 0x27, 0x2c, 0x32, 0xab, 0x0e, 0xde, 0xd1, 0x63, + 0x1a, 0x8b, 0x60, 0x5a, 0x43, 0xff, 0x5b, 0xed, + 0x80, 0x86, 0x07, 0x2b, 0xa1, 0xe7, 0xcc, 0x23, + 0x58, 0xba, 0xec, 0xa1, 0x34, 0xc8, 0x25, 0xa7 + }, { + 0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38, + 0x4c, 0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a, + 0x21, 0xfd, 0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43, + 0x4c, 0x0c, 0xc7, 0xbf, 0x63, 0xf6, 0xe1, 0xda, + 0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb, + 0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b + }, { + 0x33, 0x91, 0xfd, 0xdd, 0xfc, 0x8d, 0xc7, 0x39, + 0x37, 0x07, 0xa6, 0x5b, 0x1b, 0x47, 0x09, 0x39, + 0x7c, 0xf8, 0xb1, 0xd1, 0x62, 0xaf, 0x05, 0xab, + 0xfe, 0x8f, 0x45, 0x0d, 0xe5, 0xf3, 0x6b, 0xc6, + 0xb0, 0x45, 0x5a, 0x85, 0x20, 0xbc, 0x4e, 0x6f, + 0x5f, 0xe9, 0x5b, 0x1f, 0xe3, 0xc8, 0x45, 0x2b + }, { + 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, + 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, + 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, + 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, + 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, + 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 + } +}; + +static const unsigned char test_sha512_results[RTEMS_ARRAY_SIZE(test_vectors)][SHA512_DIGEST_LENGTH] = { { 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, @@ -205,6 +239,29 @@ static void test_sha256(void) } } +static void test_sha384(void) +{ + size_t i; + + printf("test SHA384\n"); + + for (i = 0; i < RTEMS_ARRAY_SIZE(test_vectors); ++i) { + SHA384_CTX ctx; + unsigned char r[SHA384_DIGEST_LENGTH]; + const char *s = test_vectors[i]; + + SHA384_Init(&ctx); + SHA384_Update(&ctx, s, strlen(s)); + SHA384_Final(r, &ctx); + + print_result(&r[0], sizeof(r)); + + rtems_test_assert( + memcmp(&r[0], &test_sha384_results[i][0], sizeof(r)) == 0 + ); + } +} + static void test_sha512(void) { size_t i; @@ -234,6 +291,7 @@ static void Init(rtems_task_argument arg) test_sha224(); test_sha256(); + test_sha384(); test_sha512(); rtems_stack_checker_report_usage(); |