Skip to content

Commit d6a9a58

Browse files
committed
remove space after function name and cast
1 parent 378be11 commit d6a9a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+490
-490
lines changed

bn_fast_mp_invmod.c

+26-26
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
2727
int res, neg;
2828

2929
/* 2. [modified] b must be odd */
30-
if (mp_iseven (b) == MP_YES) {
30+
if (mp_iseven(b) == MP_YES) {
3131
return MP_VAL;
3232
}
3333

@@ -37,108 +37,108 @@ int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c)
3737
}
3838

3939
/* x == modulus, y == value to invert */
40-
if ((res = mp_copy (b, &x)) != MP_OKAY) {
40+
if ((res = mp_copy(b, &x)) != MP_OKAY) {
4141
goto LBL_ERR;
4242
}
4343

4444
/* we need y = |a| */
45-
if ((res = mp_mod (a, b, &y)) != MP_OKAY) {
45+
if ((res = mp_mod(a, b, &y)) != MP_OKAY) {
4646
goto LBL_ERR;
4747
}
4848

4949
/* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
50-
if ((res = mp_copy (&x, &u)) != MP_OKAY) {
50+
if ((res = mp_copy(&x, &u)) != MP_OKAY) {
5151
goto LBL_ERR;
5252
}
53-
if ((res = mp_copy (&y, &v)) != MP_OKAY) {
53+
if ((res = mp_copy(&y, &v)) != MP_OKAY) {
5454
goto LBL_ERR;
5555
}
56-
mp_set (&D, 1);
56+
mp_set(&D, 1);
5757

5858
top:
5959
/* 4. while u is even do */
60-
while (mp_iseven (&u) == MP_YES) {
60+
while (mp_iseven(&u) == MP_YES) {
6161
/* 4.1 u = u/2 */
62-
if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
62+
if ((res = mp_div_2(&u, &u)) != MP_OKAY) {
6363
goto LBL_ERR;
6464
}
6565
/* 4.2 if B is odd then */
66-
if (mp_isodd (&B) == MP_YES) {
67-
if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
66+
if (mp_isodd(&B) == MP_YES) {
67+
if ((res = mp_sub(&B, &x, &B)) != MP_OKAY) {
6868
goto LBL_ERR;
6969
}
7070
}
7171
/* B = B/2 */
72-
if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
72+
if ((res = mp_div_2(&B, &B)) != MP_OKAY) {
7373
goto LBL_ERR;
7474
}
7575
}
7676

7777
/* 5. while v is even do */
78-
while (mp_iseven (&v) == MP_YES) {
78+
while (mp_iseven(&v) == MP_YES) {
7979
/* 5.1 v = v/2 */
80-
if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
80+
if ((res = mp_div_2(&v, &v)) != MP_OKAY) {
8181
goto LBL_ERR;
8282
}
8383
/* 5.2 if D is odd then */
84-
if (mp_isodd (&D) == MP_YES) {
84+
if (mp_isodd(&D) == MP_YES) {
8585
/* D = (D-x)/2 */
86-
if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
86+
if ((res = mp_sub(&D, &x, &D)) != MP_OKAY) {
8787
goto LBL_ERR;
8888
}
8989
}
9090
/* D = D/2 */
91-
if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
91+
if ((res = mp_div_2(&D, &D)) != MP_OKAY) {
9292
goto LBL_ERR;
9393
}
9494
}
9595

9696
/* 6. if u >= v then */
97-
if (mp_cmp (&u, &v) != MP_LT) {
97+
if (mp_cmp(&u, &v) != MP_LT) {
9898
/* u = u - v, B = B - D */
99-
if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
99+
if ((res = mp_sub(&u, &v, &u)) != MP_OKAY) {
100100
goto LBL_ERR;
101101
}
102102

103-
if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
103+
if ((res = mp_sub(&B, &D, &B)) != MP_OKAY) {
104104
goto LBL_ERR;
105105
}
106106
} else {
107107
/* v - v - u, D = D - B */
108-
if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
108+
if ((res = mp_sub(&v, &u, &v)) != MP_OKAY) {
109109
goto LBL_ERR;
110110
}
111111

112-
if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
112+
if ((res = mp_sub(&D, &B, &D)) != MP_OKAY) {
113113
goto LBL_ERR;
114114
}
115115
}
116116

117117
/* if not zero goto step 4 */
118-
if (mp_iszero (&u) == MP_NO) {
118+
if (mp_iszero(&u) == MP_NO) {
119119
goto top;
120120
}
121121

122122
/* now a = C, b = D, gcd == g*v */
123123

124124
/* if v != 1 then there is no inverse */
125-
if (mp_cmp_d (&v, 1) != MP_EQ) {
125+
if (mp_cmp_d(&v, 1) != MP_EQ) {
126126
res = MP_VAL;
127127
goto LBL_ERR;
128128
}
129129

130130
/* b is now the inverse */
131131
neg = a->sign;
132132
while (D.sign == MP_NEG) {
133-
if ((res = mp_add (&D, b, &D)) != MP_OKAY) {
133+
if ((res = mp_add(&D, b, &D)) != MP_OKAY) {
134134
goto LBL_ERR;
135135
}
136136
}
137-
mp_exch (&D, c);
137+
mp_exch(&D, c);
138138
c->sign = neg;
139139
res = MP_OKAY;
140140

141-
LBL_ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
141+
LBL_ERR:mp_clear_multi(&x, &y, &u, &v, &B, &D, NULL);
142142
return res;
143143
}
144144
#endif

bn_fast_mp_montgomery_reduce.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
3333

3434
/* grow a as required */
3535
if (x->alloc < (n->used + 1)) {
36-
if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) {
36+
if ((res = mp_grow(x, n->used + 1)) != MP_OKAY) {
3737
return res;
3838
}
3939
}
@@ -73,7 +73,7 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
7373
* that W[ix-1] have the carry cleared (see after the inner loop)
7474
*/
7575
mp_digit mu;
76-
mu = (mp_digit) (((W[ix] & MP_MASK) * rho) & MP_MASK);
76+
mu = (mp_digit)(((W[ix] & MP_MASK) * rho) & MP_MASK);
7777

7878
/* a = a + mu * m * b**i
7979
*
@@ -157,11 +157,11 @@ int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
157157

158158
/* set the max used and clamp */
159159
x->used = n->used + 1;
160-
mp_clamp (x);
160+
mp_clamp(x);
161161

162162
/* if A >= m then A = A - m */
163-
if (mp_cmp_mag (x, n) != MP_LT) {
164-
return s_mp_sub (x, n, x);
163+
if (mp_cmp_mag(x, n) != MP_LT) {
164+
return s_mp_sub(x, n, x);
165165
}
166166
return MP_OKAY;
167167
}

bn_fast_s_mp_mul_digs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
3939

4040
/* grow the destination as required */
4141
if (c->alloc < digs) {
42-
if ((res = mp_grow (c, digs)) != MP_OKAY) {
42+
if ((res = mp_grow(c, digs)) != MP_OKAY) {
4343
return res;
4444
}
4545
}
@@ -97,7 +97,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
9797
*tmpc++ = 0;
9898
}
9999
}
100-
mp_clamp (c);
100+
mp_clamp(c);
101101
return MP_OKAY;
102102
}
103103
#endif

bn_fast_s_mp_mul_high_digs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
3333
/* grow the destination as required */
3434
pa = a->used + b->used;
3535
if (c->alloc < pa) {
36-
if ((res = mp_grow (c, pa)) != MP_OKAY) {
36+
if ((res = mp_grow(c, pa)) != MP_OKAY) {
3737
return res;
3838
}
3939
}
@@ -88,7 +88,7 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
8888
*tmpc++ = 0;
8989
}
9090
}
91-
mp_clamp (c);
91+
mp_clamp(c);
9292
return MP_OKAY;
9393
}
9494
#endif

bn_fast_s_mp_sqr.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
3434
/* grow the destination as required */
3535
pa = a->used + a->used;
3636
if (b->alloc < pa) {
37-
if ((res = mp_grow (b, pa)) != MP_OKAY) {
37+
if ((res = mp_grow(b, pa)) != MP_OKAY) {
3838
return res;
3939
}
4040
}
@@ -104,7 +104,7 @@ int fast_s_mp_sqr (mp_int * a, mp_int * b)
104104
*tmpb++ = 0;
105105
}
106106
}
107-
mp_clamp (b);
107+
mp_clamp(b);
108108
return MP_OKAY;
109109
}
110110
#endif

bn_mp_2expt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ mp_2expt (mp_int * a, int b)
2626
int res;
2727

2828
/* zero a as per default */
29-
mp_zero (a);
29+
mp_zero(a);
3030

3131
/* grow a to accomodate the single bit */
32-
if ((res = mp_grow (a, (b / DIGIT_BIT) + 1)) != MP_OKAY) {
32+
if ((res = mp_grow(a, (b / DIGIT_BIT) + 1)) != MP_OKAY) {
3333
return res;
3434
}
3535

bn_mp_abs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mp_abs (mp_int * a, mp_int * b)
2626

2727
/* copy a to b */
2828
if (a != b) {
29-
if ((res = mp_copy (a, b)) != MP_OKAY) {
29+
if ((res = mp_copy(a, b)) != MP_OKAY) {
3030
return res;
3131
}
3232
}

bn_mp_add.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ int mp_add (mp_int * a, mp_int * b, mp_int * c)
2929
/* both positive or both negative */
3030
/* add their magnitudes, copy the sign */
3131
c->sign = sa;
32-
res = s_mp_add (a, b, c);
32+
res = s_mp_add(a, b, c);
3333
} else {
3434
/* one positive, the other negative */
3535
/* subtract the one with the greater magnitude from */
3636
/* the one of the lesser magnitude. The result gets */
3737
/* the sign of the one with the greater magnitude. */
38-
if (mp_cmp_mag (a, b) == MP_LT) {
38+
if (mp_cmp_mag(a, b) == MP_LT) {
3939
c->sign = sb;
40-
res = s_mp_sub (b, a, c);
40+
res = s_mp_sub(b, a, c);
4141
} else {
4242
c->sign = sa;
43-
res = s_mp_sub (a, b, c);
43+
res = s_mp_sub(a, b, c);
4444
}
4545
}
4646
return res;

bn_mp_addmod.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
2222
int res;
2323
mp_int t;
2424

25-
if ((res = mp_init (&t)) != MP_OKAY) {
25+
if ((res = mp_init(&t)) != MP_OKAY) {
2626
return res;
2727
}
2828

29-
if ((res = mp_add (a, b, &t)) != MP_OKAY) {
30-
mp_clear (&t);
29+
if ((res = mp_add(a, b, &t)) != MP_OKAY) {
30+
mp_clear(&t);
3131
return res;
3232
}
33-
res = mp_mod (&t, c, d);
34-
mp_clear (&t);
33+
res = mp_mod(&t, c, d);
34+
mp_clear(&t);
3535
return res;
3636
}
3737
#endif

bn_mp_and.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
2323
mp_int t, *x;
2424

2525
if (a->used > b->used) {
26-
if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
26+
if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
2727
return res;
2828
}
2929
px = b->used;
3030
x = b;
3131
} else {
32-
if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
32+
if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
3333
return res;
3434
}
3535
px = a->used;
@@ -45,9 +45,9 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
4545
t.dp[ix] = 0;
4646
}
4747

48-
mp_clamp (&t);
49-
mp_exch (c, &t);
50-
mp_clear (&t);
48+
mp_clamp(&t);
49+
mp_exch(c, &t);
50+
mp_clear(&t);
5151
return MP_OKAY;
5252
}
5353
#endif

bn_mp_copy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mp_copy (mp_int * a, mp_int * b)
2828

2929
/* grow dest */
3030
if (b->alloc < a->used) {
31-
if ((res = mp_grow (b, a->used)) != MP_OKAY) {
31+
if ((res = mp_grow(b, a->used)) != MP_OKAY) {
3232
return res;
3333
}
3434
}

0 commit comments

Comments
 (0)