1*f0865ec9SKyle Evans /* 2*f0865ec9SKyle Evans * Copyright (C) 2017 - This file is part of libecc project 3*f0865ec9SKyle Evans * 4*f0865ec9SKyle Evans * Authors: 5*f0865ec9SKyle Evans * Ryad BENADJILA <ryadbenadjila@gmail.com> 6*f0865ec9SKyle Evans * Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr> 7*f0865ec9SKyle Evans * Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr> 8*f0865ec9SKyle Evans * 9*f0865ec9SKyle Evans * Contributors: 10*f0865ec9SKyle Evans * Nicolas VIVET <nicolas.vivet@ssi.gouv.fr> 11*f0865ec9SKyle Evans * Karim KHALFALLAH <karim.khalfallah@ssi.gouv.fr> 12*f0865ec9SKyle Evans * 13*f0865ec9SKyle Evans * This software is licensed under a dual BSD and GPL v2 license. 14*f0865ec9SKyle Evans * See LICENSE file at the root folder of the project. 15*f0865ec9SKyle Evans */ 16*f0865ec9SKyle Evans #ifndef __NN_DIV_H__ 17*f0865ec9SKyle Evans #define __NN_DIV_H__ 18*f0865ec9SKyle Evans #include <libecc/nn/nn.h> 19*f0865ec9SKyle Evans #include <libecc/nn/nn_div_public.h> 20*f0865ec9SKyle Evans 21*f0865ec9SKyle Evans /* Compute quotient q and remainder r for given a and b such that a = q*b + r */ 22*f0865ec9SKyle Evans /* ATTRIBUTE_WARN_UNUSED_RET int nn_divrem(nn_t q, nn_t r, nn_src_t a, nn_src_t b); (declared in public header) */ 23*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_divrem_notrim(nn_t q, nn_t r, nn_src_t a, nn_src_t b); 24*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_divrem_unshifted(nn_t q, nn_t r, nn_src_t a, nn_src_t b, word_t v, 25*f0865ec9SKyle Evans bitcnt_t cnt); 26*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_divrem_normalized(nn_t q, nn_t r, nn_src_t a, nn_src_t b, word_t v); 27*f0865ec9SKyle Evans 28*f0865ec9SKyle Evans /* Compute r = a mod b */ 29*f0865ec9SKyle Evans /* ATTRIBUTE_WARN_UNUSED_RET int nn_mod(nn_t r, nn_src_t a, nn_src_t b); (declared in public header) */ 30*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_mod_notrim(nn_t r, nn_src_t a, nn_src_t b); 31*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_mod_unshifted(nn_t r, nn_src_t a, nn_src_t b, word_t v, bitcnt_t cnt); 32*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_mod_normalized(nn_t r, nn_src_t a, nn_src_t b, word_t v); 33*f0865ec9SKyle Evans 34*f0865ec9SKyle Evans /* Compute floor(B^3/(d+1)) - B. */ 35*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int wreciprocal(word_t dh, word_t dl, word_t *reciprocal); 36*f0865ec9SKyle Evans ATTRIBUTE_WARN_UNUSED_RET int nn_compute_div_coefs(nn_t p_normalized, word_t *p_shift, 37*f0865ec9SKyle Evans word_t *p_reciprocal, nn_src_t p_in); 38*f0865ec9SKyle Evans 39*f0865ec9SKyle Evans /* Compute gcd of a and b */ 40*f0865ec9SKyle Evans /* ATTRIBUTE_WARN_UNUSED_RET int nn_gcd(nn_t d, nn_src_t a, nn_src_t b, int *sign); (declared in public header) */ 41*f0865ec9SKyle Evans /* ATTRIBUTE_WARN_UNUSED_RET int nn_xgcd(nn_t g, nn_t u, nn_t v, nn_src_t a, nn_src_t b, int *sign); (declared in public header) */ 42*f0865ec9SKyle Evans 43*f0865ec9SKyle Evans #endif /* __NN_DIV_H__ */ 44