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/cipher/cipher_aead_demo.c b/programs/cipher/cipher_aead_demo.c
index 853ec20..60a5ea2 100644
--- a/programs/cipher/cipher_aead_demo.c
+++ b/programs/cipher/cipher_aead_demo.c
@@ -35,6 +35,8 @@
#include "mbedtls/cipher.h"
+#include <test/helpers.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -78,16 +80,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, unsigned char *buf, size_t len)
-{
- printf("%s:", title);
- for (size_t i = 0; i < len; i++) {
- printf(" %02x", buf[i]);
- }
- printf("\n");
-}
-
/* Run an Mbed TLS function and bail out if it fails.
* A string description of the error code can be recovered with:
* programs/util/strerror <value> */
@@ -198,7 +190,7 @@
p += tag_len;
olen = p - out;
- print_buf("out", out, olen);
+ mbedtls_test_print_buf("out", out, olen);
exit:
return ret;