Path: blob/main/crypto/libecc/src/utils/print_curves.c
34889 views
/*1* Copyright (C) 2017 - This file is part of libecc project2*3* Authors:4* Ryad BENADJILA <[email protected]>5* Arnaud EBALARD <[email protected]>6* Jean-Pierre FLORI <[email protected]>7*8* Contributors:9* Nicolas VIVET <[email protected]>10* Karim KHALFALLAH <[email protected]>11*12* This software is licensed under a dual BSD and GPL v2 license.13* See LICENSE file at the root folder of the project.14*/15#include <libecc/utils/print_curves.h>1617/*18* Locally convert given projective point to affine representation and19* print x and y coordinates.20*/21void ec_point_print(const char *msg, prj_pt_src_t pt)22{23aff_pt y_aff;24int ret, iszero;25y_aff.magic = WORD(0);2627MUST_HAVE(msg != NULL, ret, err);28ret = prj_pt_iszero(pt, &iszero); EG(ret, err);29if (iszero) {30ext_printf("%s: infinity\n", msg);31goto err;32}3334ret = prj_pt_to_aff(&y_aff, pt); EG(ret, err);35ext_printf("%s", msg);36nn_print("x", &(y_aff.x.fp_val));37ext_printf("%s", msg);38nn_print("y", &(y_aff.y.fp_val));3940err:41aff_pt_uninit(&y_aff);42return;43}4445void ec_montgomery_point_print(const char *msg, aff_pt_montgomery_src_t pt)46{47int ret;4849MUST_HAVE(msg != NULL, ret, err);50ret = aff_pt_montgomery_check_initialized(pt); EG(ret, err);5152ext_printf("%s", msg);53nn_print("u", &(pt->u.fp_val));54ext_printf("%s", msg);55nn_print("v", &(pt->v.fp_val));5657err:58return;59}6061void ec_edwards_point_print(const char *msg, aff_pt_edwards_src_t pt)62{63int ret;6465MUST_HAVE(msg != NULL, ret, err);66ret = aff_pt_edwards_check_initialized(pt); EG(ret, err);6768ext_printf("%s", msg);69nn_print("x", &(pt->x.fp_val));70ext_printf("%s", msg);71nn_print("y", &(pt->y.fp_val));7273err:74return;75}767778