Lines Matching full:in2

23  *  o out = in1 +/- in2 if cnd is not zero.
27 * constant time for that specific factor, nor on the values of in1 and in2.
28 * It still depends on the maximal length of in1 and in2.
35 * Conditionally adds 'in2' to 'in1' according to "cnd", storing the result
41 * commutative, i.e. "_nn_cnd_add(cnd, out, in1, in2)" is not equivalent
42 * to "_nn_cnd_add(cnd, out, in2, in1)". It is commutative though if "cnd"
43 * is not zero or 'in1' == 'in2'.
46 * that is if not aliased to 'in1' or 'in2'. The length of "out" is set to
47 * the maximal length of 'in1' and 'in2'. Note that both 'in1' and 'in2' will
54 * o the data stored in 'in1' and 'in2'.
56 * o the maximal length of 'in1' and 'in2'.
60 ATTRIBUTE_WARN_UNUSED_RET static int _nn_cnd_add(int cnd, nn_t out, nn_src_t in1, nn_src_t in2, in _nn_cnd_add() argument
70 ret = nn_check_initialized(in2); EG(ret, err); in _nn_cnd_add()
73 loop_wlen = LOCAL_MAX(in1->wlen, in2->wlen); in _nn_cnd_add()
74 if ((out != in1) && (out != in2)) { in _nn_cnd_add()
82 tmp = (word_t)(in1->val[i] + (in2->val[i] & mask)); in _nn_cnd_add()
97 * Conditionally adds 'in2' to 'in1' according to "cnd", storing the result
99 * length of 'in1' and 'in2'. It is user responsibility to ensure that the
101 * for instance guaranteed if both in1->wlen and in2->wlen are less than
119 int nn_cnd_add(int cnd, nn_t out, nn_src_t in1, nn_src_t in2) in nn_cnd_add() argument
124 ret = _nn_cnd_add(cnd, out, in1, in2, &carry); EG(ret, err); in nn_cnd_add()
146 * Unconditionally adds 'in2' to 'in1', storing the result in "out",
148 * 'in1' and 'in2'. The function returns 0 on success, -1 on error.
158 int nn_add(nn_t out, nn_src_t in1, nn_src_t in2) in nn_add() argument
160 return nn_cnd_add(1, out, in1, in2); in nn_add()
237 * Conditionally subtracts 'in2' from 'in1' according to "cnd",
239 * o out = in1 - in2 if cnd is not zero.
242 * 'in1' and 'in2' must point to initialized nn, such that the value of 'in1'
243 * is larger than 'in2'. Aliasing is supported, i.e. 'out' can point to the
244 * same nn as 'in1' or 'in2'. If aliasing is not used, 'out' is initialized by
250 int nn_cnd_sub(int cnd, nn_t out, nn_src_t in1, nn_src_t in2) in nn_cnd_sub() argument
258 ret = nn_check_initialized(in2); EG(ret, err); in nn_cnd_sub()
261 loop_wlen = LOCAL_MAX(in1->wlen, in2->wlen); in nn_cnd_sub()
262 if ((out != in1) && (out != in2)) { in nn_cnd_sub()
270 tmp = (word_t)(in1->val[i] - (in2->val[i] & mask)); in nn_cnd_sub()
278 /* We only support the in1 >= in2 case */ in nn_cnd_sub()
286 int nn_sub(nn_t out, nn_src_t in1, nn_src_t in2) in nn_sub() argument
288 return nn_cnd_sub(1, out, in1, in2); in nn_sub()
334 * Compute out = in1 + in2 mod p. The function returns 0 on success, -1 on
339 static int _nn_mod_add(nn_t out, nn_src_t in1, nn_src_t in2, nn_src_t p) in _nn_mod_add() argument
344 ret = nn_check_initialized(in2); EG(ret, err); in _nn_mod_add()
348 …SHOULD_HAVE((!nn_cmp(in2, p, &cmp)) && (cmp < 0), ret, err); /* a SHOULD_HAVE as documented above … in _nn_mod_add()
350 ret = nn_add(out, in1, in2); EG(ret, err); in _nn_mod_add()
360 * of in1 and in2 so getting a carry out does not necessarily mean in _nn_mod_add()
374 * Compute out = in1 + in2 mod p. The function returns 0 on success, -1 on
379 int nn_mod_add(nn_t out, nn_src_t in1, nn_src_t in2, nn_src_t p) in nn_mod_add() argument
388 ret = _nn_mod_add(out, in1, in2, &p_cpy); in nn_mod_add()
395 ret = _nn_mod_add(out, in1, in2, p); in nn_mod_add()
457 * Compute out = in1 - in2 mod p. The function returns 0 on success, -1 on
462 static int _nn_mod_sub(nn_t out, nn_src_t in1, nn_src_t in2, nn_src_t p) in _nn_mod_sub() argument
470 ret = nn_check_initialized(in2); EG(ret, err); in _nn_mod_sub()
474 …SHOULD_HAVE((!nn_cmp(in2, p, &cmp)) && (cmp < 0), ret, err); /* a SHOULD_HAVE as documented above … in _nn_mod_sub()
476 /* Handle the case where in2 and out are aliased */ in _nn_mod_sub()
477 if (in2 == out) { in _nn_mod_sub()
478 ret = nn_copy(&in2_cpy, in2); EG(ret, err); in _nn_mod_sub()
482 in2_ = in2; in _nn_mod_sub()
500 * Compute out = in1 - in2 mod p. The function returns 0 on success, -1 on
505 int nn_mod_sub(nn_t out, nn_src_t in1, nn_src_t in2, nn_src_t p) in nn_mod_sub() argument
514 ret = _nn_mod_sub(out, in1, in2, &p_cpy); in nn_mod_sub()
521 ret = _nn_mod_sub(out, in1, in2, p); in nn_mod_sub()