Debian Codegraph @

third_party/heimdal/lib/hcrypto/libtommath/demo/shared.c

raw
1 #include "shared.h"
2
3 void ndraw(mp_int *a, const char *name)
4 {
5 char *buf = NULL;
6 int size;
7
8 mp_radix_size(a, 10, &size);
9 buf = (char *)malloc((size_t) size);
10 if (buf == NULL) {
11 fprintf(stderr, "\nndraw: malloc(%d) failed\n", size);
12 exit(EXIT_FAILURE);
13 }
14
15 printf("%s: ", name);
16 mp_to_decimal(a, buf, (size_t) size);
17 printf("%s\n", buf);
18 mp_to_hex(a, buf, (size_t) size);
19 printf("0x%s\n", buf);
20
21 free(buf);
22 }
23
24 void print_header(void)
25 {
26 #ifdef MP_8BIT
27 printf("Digit size 8 Bit \n");
28 #endif
29 #ifdef MP_16BIT
30 printf("Digit size 16 Bit \n");
31 #endif
32 #ifdef MP_32BIT
33 printf("Digit size 32 Bit \n");
34 #endif
35 #ifdef MP_64BIT
36 printf("Digit size 64 Bit \n");
37 #endif
38 printf("Size of mp_digit: %u\n", (unsigned int)sizeof(mp_digit));
39 printf("Size of mp_word: %u\n", (unsigned int)sizeof(mp_word));
40 printf("MP_DIGIT_BIT: %d\n", MP_DIGIT_BIT);
41 printf("MP_PREC: %d\n", MP_PREC);
42 }