/* * Copyright (C) 2017 - This file is part of libecc project * * Authors: * Ryad BENADJILA * Arnaud EBALARD * Jean-Pierre FLORI * * Contributors: * Nicolas VIVET * Karim KHALFALLAH * * This software is licensed under a dual BSD and GPL v2 license. * See LICENSE file at the root folder of the project. */ #include #include /* * Initialize given Fp element in 'out' storage space to a Fp value chosen * uniformly at random in [1, p-1] where p is provided by 'ctx'. The function * returns 0 on success, -1 on error. */ int fp_get_random(fp_t out, fp_ctx_src_t ctx) { int ret; ret = fp_init(out, ctx); EG(ret, err); ret = nn_get_random_mod(&(out->fp_val), &(ctx->p)); err: return ret; }