/*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*/1516#include <libecc/fp/fp_rand.h>17#include <libecc/nn/nn_rand.h>1819/*20* Initialize given Fp element in 'out' storage space to a Fp value chosen21* uniformly at random in [1, p-1] where p is provided by 'ctx'. The function22* returns 0 on success, -1 on error.23*/24int fp_get_random(fp_t out, fp_ctx_src_t ctx)25{26int ret;2728ret = fp_init(out, ctx); EG(ret, err);29ret = nn_get_random_mod(&(out->fp_val), &(ctx->p));3031err:32return ret;33}343536