xref: /freebsd/crypto/libecc/src/utils/print_buf.c (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 /*
2  *  Copyright (C) 2021 - This file is part of libecc project
3  *
4  *  Authors:
5  *      Ryad BENADJILA <ryadbenadjila@gmail.com>
6  *      Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
7  *
8  *  This software is licensed under a dual BSD and GPL v2 license.
9  *  See LICENSE file at the root folder of the project.
10  */
11 #include <libecc/utils/print_buf.h>
12 #include <libecc/external_deps/print.h>
13 
14 /* Print the buffer of a given size */
buf_print(const char * msg,const u8 * buf,u16 buflen)15 void buf_print(const char *msg, const u8 *buf, u16 buflen)
16 {
17 	u32 i;
18 
19 	if ((buf == NULL) || (msg == NULL)) {
20 		goto err;
21 	}
22 
23 	ext_printf("%s: ", msg);
24 	for (i = 0; i < (u32)buflen; i++) {
25 		ext_printf("%02x", buf[i]);
26 	}
27 	ext_printf("\n");
28 
29 err:
30 	return;
31 }
32