xref: /freebsd/crypto/libecc/src/utils/print_nn.c (revision f0865ec9906d5a18fa2a3b61381f22ce16e606ad)
1 /*
2  *  Copyright (C) 2017 - 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  *      Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
8  *
9  *  Contributors:
10  *      Nicolas VIVET <nicolas.vivet@ssi.gouv.fr>
11  *      Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr>
12  *
13  *  This software is licensed under a dual BSD and GPL v2 license.
14  *  See LICENSE file at the root folder of the project.
15  */
16 #include <libecc/utils/print_nn.h>
17 
18 /* Print out given nn, prepending msg to the output */
nn_print(const char * msg,nn_src_t a)19 void nn_print(const char *msg, nn_src_t a)
20 {
21 	int ret, w;
22 
23 	ret = nn_check_initialized(a); EG(ret, err);
24 	MUST_HAVE(msg != NULL, ret, err);
25 
26 	ext_printf("%s (%d words, i.e. %d bits): 0x", msg, a->wlen,
27 		   a->wlen * WORD_BYTES * 8);
28 
29 	for (w = a->wlen - 1; w >= 0; w--) {
30 		ext_printf(PRINTF_WORD_HEX_FMT, a->val[w]);
31 	}
32 
33 	ext_printf("\n");
34 
35 err:
36 	return;
37 }
38