Path: blob/main/crypto/libecc/src/utils/print_fp.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_fp.h>1617/* Print the context of a prime field Fp */18void fp_ctx_print(const char *msg, fp_ctx_src_t ctx)19{20int ret;2122MUST_HAVE(msg != NULL, ret, err);23ret = fp_ctx_check_initialized(ctx); EG(ret, err);2425ext_printf("%s:\n", msg);26nn_print("\t fp_ctx->p", &(ctx->p));27ext_printf("\t fp_ctx->mpinv 0x%016lx\n",28(long unsigned int)ctx->mpinv);29nn_print("\t fp_ctx->r", &(ctx->r));30nn_print("\t fp_ctx->r_square", &(ctx->r_square));3132err:33return;34}3536/* Print the value of an Fp element */37void fp_print(const char *msg, fp_src_t a)38{39int ret;4041MUST_HAVE(msg != NULL, ret, err);42ret = fp_check_initialized(a); EG(ret, err);4344nn_print(msg, &(a->fp_val));4546err:47return;48}4950/* Print the value and Fp context of an Fp element */51void fp_print_all(const char *msg, fp_src_t a)52{53int ret;5455MUST_HAVE(msg != NULL, ret, err);56ret = fp_check_initialized(a); EG(ret, err);5758ext_printf("%s:\n", msg);59nn_print("\t fp_val", &(a->fp_val));60fp_ctx_print("", a->ctx);6162err:63return;64}656667