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/programs/psa/aead_demo.c b/programs/psa/aead_demo.c
index 619166d..b300e36 100644
--- a/programs/psa/aead_demo.c
+++ b/programs/psa/aead_demo.c
@@ -36,6 +36,8 @@
#include "psa/crypto.h"
+#include <test/helpers.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -81,16 +83,6 @@
* 32-byte is enough to all the key size supported by this program. */
const unsigned char key_bytes[32] = { 0x2a };
-/* Print the contents of a buffer in hex */
-void print_buf(const char *title, uint8_t *buf, size_t len)
-{
- printf("%s:", title);
- for (size_t i = 0; i < len; i++) {
- printf(" %02x", buf[i]);
- }
- printf("\n");
-}
-
/* Run a PSA function and bail out if it fails.
* The symbolic name of the error code can be recovered using:
* programs/psa/psa_constant_name status <value> */
@@ -216,7 +208,7 @@
p += olen_tag;
olen = p - out;
- print_buf("out", out, olen);
+ mbedtls_test_print_buf("out", out, olen);
exit:
psa_aead_abort(&op); // required on errors, harmless on success