[rtems commit] libtest: Print SHA256 hash in base64url
Sebastian Huber
sebh at rtems.org
Fri Feb 26 08:25:54 UTC 2021
Module: rtems
Branch: master
Commit: c96644e873799b4787036b25ff30587697d67b3c
Changeset: http://git.rtems.org/rtems/commit/?id=c96644e873799b4787036b25ff30587697d67b3c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Feb 24 14:45:47 2021 +0100
libtest: Print SHA256 hash in base64url
---
cpukit/libtest/t-test-hash-sha256.c | 13 ++++++-------
testsuites/libtests/ttest01/init.c | 2 +-
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/cpukit/libtest/t-test-hash-sha256.c b/cpukit/libtest/t-test-hash-sha256.c
index 25584cc..32e946b 100644
--- a/cpukit/libtest/t-test-hash-sha256.c
+++ b/cpukit/libtest/t-test-hash-sha256.c
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (C) 2019 embedded brains GmbH
+ * Copyright (C) 2019, 2021 embedded brains GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,6 +26,9 @@
*/
#include <rtems/test.h>
+#include <rtems/score/io.h>
+
+#include <limits.h>
#if defined(__rtems__)
#include <sha256.h>
@@ -69,16 +72,12 @@ T_report_hash_sha256_finalize(void)
{
T_report_hash_sha256_context *ctx;
unsigned char hash[32];
- size_t i;
ctx = &T_report_hash_sha256_instance;
SHA256_Final(hash, &ctx->sha256);
T_printf("Y:ReportHash:SHA256:");
-
- for (i = 0; i < 32; ++i) {
- T_printf("%02x", hash[i]);
- }
-
+ (void)_IO_Base64url(ctx->putchar, ctx->putchar_arg, hash,
+ sizeof(hash), NULL, INT_MAX);
T_printf("\n");
}
diff --git a/testsuites/libtests/ttest01/init.c b/testsuites/libtests/ttest01/init.c
index 3e3242a..658f8f6 100644
--- a/testsuites/libtests/ttest01/init.c
+++ b/testsuites/libtests/ttest01/init.c
@@ -188,7 +188,7 @@ run_initialize(void)
}
static const char expected_final[] = "Z:ttest01:C:344:N:1339:F:795:D:0.691999\n"
-"Y:ReportHash:SHA256:2e044b038565203cde1ff74b3e28403a3a96f0802e8d3f82a37170065a17a0a1\n";
+"Y:ReportHash:SHA256:LgRLA4VlIDzeH_dLPihAOjqW8IAujT-Co3FwBloXoKE=\n";
static void
run_finalize(void)
More information about the vc
mailing list