Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/libecc/src/utils/print_fp.c
34889 views
1
/*
2
* Copyright (C) 2017 - This file is part of libecc project
3
*
4
* Authors:
5
* Ryad BENADJILA <[email protected]>
6
* Arnaud EBALARD <[email protected]>
7
* Jean-Pierre FLORI <[email protected]>
8
*
9
* Contributors:
10
* Nicolas VIVET <[email protected]>
11
* Karim KHALFALLAH <[email protected]>
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_fp.h>
17
18
/* Print the context of a prime field Fp */
19
void fp_ctx_print(const char *msg, fp_ctx_src_t ctx)
20
{
21
int ret;
22
23
MUST_HAVE(msg != NULL, ret, err);
24
ret = fp_ctx_check_initialized(ctx); EG(ret, err);
25
26
ext_printf("%s:\n", msg);
27
nn_print("\t fp_ctx->p", &(ctx->p));
28
ext_printf("\t fp_ctx->mpinv 0x%016lx\n",
29
(long unsigned int)ctx->mpinv);
30
nn_print("\t fp_ctx->r", &(ctx->r));
31
nn_print("\t fp_ctx->r_square", &(ctx->r_square));
32
33
err:
34
return;
35
}
36
37
/* Print the value of an Fp element */
38
void fp_print(const char *msg, fp_src_t a)
39
{
40
int ret;
41
42
MUST_HAVE(msg != NULL, ret, err);
43
ret = fp_check_initialized(a); EG(ret, err);
44
45
nn_print(msg, &(a->fp_val));
46
47
err:
48
return;
49
}
50
51
/* Print the value and Fp context of an Fp element */
52
void fp_print_all(const char *msg, fp_src_t a)
53
{
54
int ret;
55
56
MUST_HAVE(msg != NULL, ret, err);
57
ret = fp_check_initialized(a); EG(ret, err);
58
59
ext_printf("%s:\n", msg);
60
nn_print("\t fp_val", &(a->fp_val));
61
fp_ctx_print("", a->ctx);
62
63
err:
64
return;
65
}
66
67