Move print_buf into mbedtls_test_print_buf helper function in sample programs

Reduce code duplication and fix missing-prototype error for print_buf

Signed-off-by: Michael Schuster <michael@schuster.ms>
diff --git a/tests/include/test/helpers.h b/tests/include/test/helpers.h
index d08100f..10b321d 100644
--- a/tests/include/test/helpers.h
+++ b/tests/include/test/helpers.h
@@ -381,6 +381,9 @@
 int mbedtls_test_hexcmp(uint8_t *a, uint8_t *b,
                         uint32_t a_len, uint32_t b_len);
 
+/* Print the contents of a buffer in hex */
+void mbedtls_test_print_buf(const char *title, unsigned char *buf, size_t len);
+
 #if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG)
 #include "test/fake_external_rng_for_test.h"
 #endif
diff --git a/tests/src/helpers.c b/tests/src/helpers.c
index 065d17d..29b2df5 100644
--- a/tests/src/helpers.c
+++ b/tests/src/helpers.c
@@ -660,6 +660,15 @@
     return ret;
 }
 
+void mbedtls_test_print_buf(const char *title, unsigned char *buf, size_t len)
+{
+    printf("%s:", title);
+    for (size_t i = 0; i < len; i++) {
+        printf(" %02x", buf[i]);
+    }
+    printf("\n");
+}
+
 #if defined(MBEDTLS_TEST_HOOKS)
 void mbedtls_test_err_add_check(int high, int low,
                                 const char *file, int line)