comparison libtommath/bn_s_mp_add.c @ 1437:871b18fd7065 fuzz

merge from main (libtommath/libtomcrypt/curve25510-donna updates)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 22:51:45 +0800
parents 60fc6476e044
children 8bba51a55704
comparison
equal deleted inserted replaced
1432:41dca1e5ea34 1437:871b18fd7065
1 #include <tommath.h> 1 #include <tommath_private.h>
2 #ifdef BN_S_MP_ADD_C 2 #ifdef BN_S_MP_ADD_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 * 4 *
5 * LibTomMath is a library that provides multiple-precision 5 * LibTomMath is a library that provides multiple-precision
6 * integer arithmetic as well as number theoretic functionality. 6 * integer arithmetic as well as number theoretic functionality.
10 * additional optimizations in place. 10 * additional optimizations in place.
11 * 11 *
12 * The library is free for all purposes without any express 12 * The library is free for all purposes without any express
13 * guarantee it works. 13 * guarantee it works.
14 * 14 *
15 * Tom St Denis, [email protected], http://math.libtomcrypt.com 15 * Tom St Denis, [email protected], http://libtom.org
16 */ 16 */
17 17
18 /* low level addition, based on HAC pp.594, Algorithm 14.7 */ 18 /* low level addition, based on HAC pp.594, Algorithm 14.7 */
19 int 19 int
20 s_mp_add (mp_int * a, mp_int * b, mp_int * c) 20 s_mp_add (mp_int * a, mp_int * b, mp_int * c)
34 max = b->used; 34 max = b->used;
35 x = b; 35 x = b;
36 } 36 }
37 37
38 /* init result */ 38 /* init result */
39 if (c->alloc < max + 1) { 39 if (c->alloc < (max + 1)) {
40 if ((res = mp_grow (c, max + 1)) != MP_OKAY) { 40 if ((res = mp_grow (c, max + 1)) != MP_OKAY) {
41 return res; 41 return res;
42 } 42 }
43 } 43 }
44 44
45 /* get old used digit count and set new one */ 45 /* get old used digit count and set new one */
46 olduse = c->used; 46 olduse = c->used;
47 c->used = max + 1; 47 c->used = max + 1;
48 48
49 { 49 {
50 register mp_digit u, *tmpa, *tmpb, *tmpc; 50 mp_digit u, *tmpa, *tmpb, *tmpc;
51 register int i; 51 int i;
52 52
53 /* alias for digit pointers */ 53 /* alias for digit pointers */
54 54
55 /* first input */ 55 /* first input */
56 tmpa = a->dp; 56 tmpa = a->dp;
102 mp_clamp (c); 102 mp_clamp (c);
103 return MP_OKAY; 103 return MP_OKAY;
104 } 104 }
105 #endif 105 #endif
106 106
107 /* $Source: /cvs/libtom/libtommath/bn_s_mp_add.c,v $ */ 107 /* $Source$ */
108 /* $Revision: 1.3 $ */ 108 /* $Revision$ */
109 /* $Date: 2006/03/31 14:18:44 $ */ 109 /* $Date$ */