Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/libecc/src/utils/print_curves.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_curves.h>
17
18
/*
19
* Locally convert given projective point to affine representation and
20
* print x and y coordinates.
21
*/
22
void ec_point_print(const char *msg, prj_pt_src_t pt)
23
{
24
aff_pt y_aff;
25
int ret, iszero;
26
y_aff.magic = WORD(0);
27
28
MUST_HAVE(msg != NULL, ret, err);
29
ret = prj_pt_iszero(pt, &iszero); EG(ret, err);
30
if (iszero) {
31
ext_printf("%s: infinity\n", msg);
32
goto err;
33
}
34
35
ret = prj_pt_to_aff(&y_aff, pt); EG(ret, err);
36
ext_printf("%s", msg);
37
nn_print("x", &(y_aff.x.fp_val));
38
ext_printf("%s", msg);
39
nn_print("y", &(y_aff.y.fp_val));
40
41
err:
42
aff_pt_uninit(&y_aff);
43
return;
44
}
45
46
void ec_montgomery_point_print(const char *msg, aff_pt_montgomery_src_t pt)
47
{
48
int ret;
49
50
MUST_HAVE(msg != NULL, ret, err);
51
ret = aff_pt_montgomery_check_initialized(pt); EG(ret, err);
52
53
ext_printf("%s", msg);
54
nn_print("u", &(pt->u.fp_val));
55
ext_printf("%s", msg);
56
nn_print("v", &(pt->v.fp_val));
57
58
err:
59
return;
60
}
61
62
void ec_edwards_point_print(const char *msg, aff_pt_edwards_src_t pt)
63
{
64
int ret;
65
66
MUST_HAVE(msg != NULL, ret, err);
67
ret = aff_pt_edwards_check_initialized(pt); EG(ret, err);
68
69
ext_printf("%s", msg);
70
nn_print("x", &(pt->x.fp_val));
71
ext_printf("%s", msg);
72
nn_print("y", &(pt->y.fp_val));
73
74
err:
75
return;
76
}
77
78