summaryrefslogtreecommitdiffstats
path: root/cpukit/libtest/t-test-hash-sha256.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libtest/t-test-hash-sha256.c')
-rw-r--r--cpukit/libtest/t-test-hash-sha256.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/cpukit/libtest/t-test-hash-sha256.c b/cpukit/libtest/t-test-hash-sha256.c
index 32e946b4cf..79da4b5dfb 100644
--- a/cpukit/libtest/t-test-hash-sha256.c
+++ b/cpukit/libtest/t-test-hash-sha256.c
@@ -1,7 +1,16 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
*
- * Copyright (C) 2019, 2021 embedded brains GmbH
+ * @ingroup RTEMSTestFrameworkImpl
+ *
+ * @brief This source file contains the implementation of
+ * T_report_hash_sha256_update() and T_report_hash_sha256().
+ */
+
+/*
+ * Copyright (C) 2019, 2021 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,7 +35,6 @@
*/
#include <rtems/test.h>
-#include <rtems/score/io.h>
#include <limits.h>
@@ -36,6 +44,8 @@
#include <openssl/sha.h>
#endif
+#include <rtems/base64.h>
+
typedef struct {
SHA256_CTX sha256;
T_putchar putchar;
@@ -44,6 +54,15 @@ typedef struct {
static T_report_hash_sha256_context T_report_hash_sha256_instance;
+void
+T_report_hash_sha256_update(char c)
+{
+ T_report_hash_sha256_context *ctx;
+
+ ctx = &T_report_hash_sha256_instance;
+ SHA256_Update(&ctx->sha256, &c, sizeof(c));
+}
+
static void
T_report_hash_sha256_putchar(int c, void *arg)
{
@@ -76,7 +95,7 @@ T_report_hash_sha256_finalize(void)
ctx = &T_report_hash_sha256_instance;
SHA256_Final(hash, &ctx->sha256);
T_printf("Y:ReportHash:SHA256:");
- (void)_IO_Base64url(ctx->putchar, ctx->putchar_arg, hash,
+ (void)_Base64url_Encode(ctx->putchar, ctx->putchar_arg, hash,
sizeof(hash), NULL, INT_MAX);
T_printf("\n");
}