Lines Matching +full:in2 +full:-

2  *  Copyright (C) 2017 - This file is part of libecc project
7 * Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
20 * Compute out = in1 + in2 mod p. 'out' parameter must have been initialized
21 * by the caller. Returns 0 on success, -1 on error.
25 int fp_add(fp_t out, fp_src_t in1, fp_src_t in2) in fp_add() argument
31 ret = fp_check_initialized(in2); EG(ret, err); in fp_add()
33 MUST_HAVE(((&(in1->ctx->p)) == (&(in2->ctx->p))), ret, err); in fp_add()
34 MUST_HAVE(((&(in1->ctx->p)) == (&(out->ctx->p))), ret, err); in fp_add()
36 SHOULD_HAVE(!nn_cmp(&in1->fp_val, &(in1->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_add()
37 SHOULD_HAVE(!nn_cmp(&in2->fp_val, &(in2->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_add()
39 ret = nn_mod_add(&(out->fp_val), &(in1->fp_val), in fp_add()
40 &(in2->fp_val), &(in1->ctx->p)); in fp_add()
48 * by the caller. Returns 0 on success, -1 on error.
59 MUST_HAVE(((&(in->ctx->p)) == (&(out->ctx->p))), ret, err); in fp_inc()
61 SHOULD_HAVE(!nn_cmp(&in->fp_val, &(in->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_inc()
63 ret = nn_mod_inc(&(out->fp_val), &(in->fp_val), &(in->ctx->p)); in fp_inc()
70 * Compute out = in1 - in2 mod p. 'out' parameter must have been initialized
71 * by the caller. Returns 0 on success, -1 on error.
75 int fp_sub(fp_t out, fp_src_t in1, fp_src_t in2) in fp_sub() argument
81 ret = fp_check_initialized(in2); EG(ret, err); in fp_sub()
83 MUST_HAVE(((&(in1->ctx->p)) == (&(in2->ctx->p))), ret, err); in fp_sub()
84 MUST_HAVE(((&(in1->ctx->p)) == (&(out->ctx->p))), ret, err); in fp_sub()
86 SHOULD_HAVE(!nn_cmp(&in1->fp_val, &(in1->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_sub()
87 SHOULD_HAVE(!nn_cmp(&in2->fp_val, &(in2->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_sub()
89 ret = nn_mod_sub(&(out->fp_val), &(in1->fp_val), in fp_sub()
90 &(in2->fp_val), &(in1->ctx->p)); in fp_sub()
97 * Compute out = in - 1 mod p. 'out' parameter must have been initialized
98 * by the caller. Returns 0 on success, -1 on error.
109 MUST_HAVE(((&(in->ctx->p)) == (&(out->ctx->p))), ret, err); in fp_dec()
111 SHOULD_HAVE(!nn_cmp(&in->fp_val, &(in->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_dec()
113 ret = nn_mod_dec(&(out->fp_val), &(in->fp_val), &(in->ctx->p)); in fp_dec()
120 * Compute out = -in mod p = (p - in) mod p. 'out' parameter must have been
121 * initialized by the caller. Returns 0 on success, -1 on error.
132 MUST_HAVE(((&(in->ctx->p)) == (&(out->ctx->p))), ret, err); in fp_neg()
134 SHOULD_HAVE(!nn_cmp(&in->fp_val, &(in->ctx->p), &cmp) && (cmp < 0), ret, err); in fp_neg()
136 ret = nn_sub(&(out->fp_val), &(in->ctx->p), &(in->fp_val)); in fp_neg()