Skip to content

Commit 9eed07f

Browse files
committed
format with astyle (step 2)
1 parent 45771cc commit 9eed07f

32 files changed

+758
-758
lines changed

bn_error.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
*/
1717

1818
static const struct {
19-
int code;
20-
const char *msg;
19+
int code;
20+
const char *msg;
2121
} msgs[] = {
22-
{ MP_OKAY, "Successful" },
23-
{ MP_MEM, "Out of heap" },
24-
{ MP_VAL, "Value out of range" }
22+
{ MP_OKAY, "Successful" },
23+
{ MP_MEM, "Out of heap" },
24+
{ MP_VAL, "Value out of range" }
2525
};
2626

2727
/* return a char * string for a given code */
@@ -31,9 +31,9 @@ const char *mp_error_to_string(int code)
3131

3232
/* scan the lookup table for the given message */
3333
for (x = 0; x < (int)(sizeof(msgs) / sizeof(msgs[0])); x++) {
34-
if (msgs[x].code == code) {
35-
return msgs[x].msg;
36-
}
34+
if (msgs[x].code == code) {
35+
return msgs[x].msg;
36+
}
3737
}
3838

3939
/* generic reply for invalid code */

bn_fast_s_mp_mul_digs.c

+32-32
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@
3333
*/
3434
int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs)
3535
{
36-
int olduse, res, pa, ix, iz;
37-
mp_digit W[MP_WARRAY];
38-
mp_word _W;
36+
int olduse, res, pa, ix, iz;
37+
mp_digit W[MP_WARRAY];
38+
mp_word _W;
3939

40-
/* grow the destination as required */
41-
if (c->alloc < digs) {
42-
if ((res = mp_grow(c, digs)) != MP_OKAY) {
43-
return res;
44-
}
45-
}
40+
/* grow the destination as required */
41+
if (c->alloc < digs) {
42+
if ((res = mp_grow(c, digs)) != MP_OKAY) {
43+
return res;
44+
}
45+
}
4646

47-
/* number of output digits to produce */
48-
pa = MIN(digs, a->used + b->used);
47+
/* number of output digits to produce */
48+
pa = MIN(digs, a->used + b->used);
4949

50-
/* clear the carry */
51-
_W = 0;
52-
for (ix = 0; ix < pa; ix++) {
50+
/* clear the carry */
51+
_W = 0;
52+
for (ix = 0; ix < pa; ix++) {
5353
int tx, ty;
5454
int iy;
5555
mp_digit *tmpx, *tmpy;
@@ -78,27 +78,27 @@ int fast_s_mp_mul_digs(mp_int *a, mp_int *b, mp_int *c, int digs)
7878

7979
/* make next carry */
8080
_W = _W >> ((mp_word)DIGIT_BIT);
81-
}
81+
}
8282

83-
/* setup dest */
84-
olduse = c->used;
85-
c->used = pa;
83+
/* setup dest */
84+
olduse = c->used;
85+
c->used = pa;
8686

87-
{
88-
mp_digit *tmpc;
89-
tmpc = c->dp;
90-
for (ix = 0; ix < (pa + 1); ix++) {
91-
/* now extract the previous digit [below the carry] */
92-
*tmpc++ = W[ix];
93-
}
87+
{
88+
mp_digit *tmpc;
89+
tmpc = c->dp;
90+
for (ix = 0; ix < (pa + 1); ix++) {
91+
/* now extract the previous digit [below the carry] */
92+
*tmpc++ = W[ix];
93+
}
9494

95-
/* clear unused digits [that existed in the old copy of c] */
96-
for (; ix < olduse; ix++) {
97-
*tmpc++ = 0;
98-
}
99-
}
100-
mp_clamp(c);
101-
return MP_OKAY;
95+
/* clear unused digits [that existed in the old copy of c] */
96+
for (; ix < olduse; ix++) {
97+
*tmpc++ = 0;
98+
}
99+
}
100+
mp_clamp(c);
101+
return MP_OKAY;
102102
}
103103
#endif
104104

bn_fast_s_mp_mul_high_digs.c

+32-32
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@
2626
*/
2727
int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs)
2828
{
29-
int olduse, res, pa, ix, iz;
30-
mp_digit W[MP_WARRAY];
31-
mp_word _W;
29+
int olduse, res, pa, ix, iz;
30+
mp_digit W[MP_WARRAY];
31+
mp_word _W;
3232

33-
/* grow the destination as required */
34-
pa = a->used + b->used;
35-
if (c->alloc < pa) {
36-
if ((res = mp_grow(c, pa)) != MP_OKAY) {
37-
return res;
38-
}
39-
}
33+
/* grow the destination as required */
34+
pa = a->used + b->used;
35+
if (c->alloc < pa) {
36+
if ((res = mp_grow(c, pa)) != MP_OKAY) {
37+
return res;
38+
}
39+
}
4040

41-
/* number of output digits to produce */
42-
pa = a->used + b->used;
43-
_W = 0;
44-
for (ix = digs; ix < pa; ix++) {
41+
/* number of output digits to produce */
42+
pa = a->used + b->used;
43+
_W = 0;
44+
for (ix = digs; ix < pa; ix++) {
4545
int tx, ty, iy;
4646
mp_digit *tmpx, *tmpy;
4747

@@ -68,28 +68,28 @@ int fast_s_mp_mul_high_digs(mp_int *a, mp_int *b, mp_int *c, int digs)
6868

6969
/* make next carry */
7070
_W = _W >> ((mp_word)DIGIT_BIT);
71-
}
71+
}
7272

73-
/* setup dest */
74-
olduse = c->used;
75-
c->used = pa;
73+
/* setup dest */
74+
olduse = c->used;
75+
c->used = pa;
7676

77-
{
78-
mp_digit *tmpc;
77+
{
78+
mp_digit *tmpc;
7979

80-
tmpc = c->dp + digs;
81-
for (ix = digs; ix < pa; ix++) {
82-
/* now extract the previous digit [below the carry] */
83-
*tmpc++ = W[ix];
84-
}
80+
tmpc = c->dp + digs;
81+
for (ix = digs; ix < pa; ix++) {
82+
/* now extract the previous digit [below the carry] */
83+
*tmpc++ = W[ix];
84+
}
8585

86-
/* clear unused digits [that existed in the old copy of c] */
87-
for (; ix < olduse; ix++) {
88-
*tmpc++ = 0;
89-
}
90-
}
91-
mp_clamp(c);
92-
return MP_OKAY;
86+
/* clear unused digits [that existed in the old copy of c] */
87+
for (; ix < olduse; ix++) {
88+
*tmpc++ = 0;
89+
}
90+
}
91+
mp_clamp(c);
92+
return MP_OKAY;
9393
}
9494
#endif
9595

bn_fast_s_mp_sqr.c

+35-35
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ After that loop you do the squares and add them in.
2727

2828
int fast_s_mp_sqr(mp_int *a, mp_int *b)
2929
{
30-
int olduse, res, pa, ix, iz;
31-
mp_digit W[MP_WARRAY], *tmpx;
32-
mp_word W1;
33-
34-
/* grow the destination as required */
35-
pa = a->used + a->used;
36-
if (b->alloc < pa) {
37-
if ((res = mp_grow(b, pa)) != MP_OKAY) {
38-
return res;
39-
}
40-
}
41-
42-
/* number of output digits to produce */
43-
W1 = 0;
44-
for (ix = 0; ix < pa; ix++) {
30+
int olduse, res, pa, ix, iz;
31+
mp_digit W[MP_WARRAY], *tmpx;
32+
mp_word W1;
33+
34+
/* grow the destination as required */
35+
pa = a->used + a->used;
36+
if (b->alloc < pa) {
37+
if ((res = mp_grow(b, pa)) != MP_OKAY) {
38+
return res;
39+
}
40+
}
41+
42+
/* number of output digits to produce */
43+
W1 = 0;
44+
for (ix = 0; ix < pa; ix++) {
4545
int tx, ty, iy;
4646
mp_word _W;
4747
mp_digit *tmpy;
@@ -86,26 +86,26 @@ int fast_s_mp_sqr(mp_int *a, mp_int *b)
8686

8787
/* make next carry */
8888
W1 = _W >> ((mp_word)DIGIT_BIT);
89-
}
90-
91-
/* setup dest */
92-
olduse = b->used;
93-
b->used = a->used+a->used;
94-
95-
{
96-
mp_digit *tmpb;
97-
tmpb = b->dp;
98-
for (ix = 0; ix < pa; ix++) {
99-
*tmpb++ = W[ix] & MP_MASK;
100-
}
101-
102-
/* clear unused digits [that existed in the old copy of c] */
103-
for (; ix < olduse; ix++) {
104-
*tmpb++ = 0;
105-
}
106-
}
107-
mp_clamp(b);
108-
return MP_OKAY;
89+
}
90+
91+
/* setup dest */
92+
olduse = b->used;
93+
b->used = a->used+a->used;
94+
95+
{
96+
mp_digit *tmpb;
97+
tmpb = b->dp;
98+
for (ix = 0; ix < pa; ix++) {
99+
*tmpb++ = W[ix] & MP_MASK;
100+
}
101+
102+
/* clear unused digits [that existed in the old copy of c] */
103+
for (; ix < olduse; ix++) {
104+
*tmpb++ = 0;
105+
}
106+
}
107+
mp_clamp(b);
108+
return MP_OKAY;
109109
}
110110
#endif
111111

bn_mp_2expt.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@
2222
*/
2323
int mp_2expt(mp_int *a, int b)
2424
{
25-
int res;
25+
int res;
2626

27-
/* zero a as per default */
28-
mp_zero(a);
27+
/* zero a as per default */
28+
mp_zero(a);
2929

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

35-
/* set the used count of where the bit will go */
36-
a->used = (b / DIGIT_BIT) + 1;
35+
/* set the used count of where the bit will go */
36+
a->used = (b / DIGIT_BIT) + 1;
3737

38-
/* put the single bit in its place */
39-
a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT);
38+
/* put the single bit in its place */
39+
a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT);
4040

41-
return MP_OKAY;
41+
return MP_OKAY;
4242
}
4343
#endif
4444

bn_mp_abs.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121
*/
2222
int mp_abs(mp_int *a, mp_int *b)
2323
{
24-
int res;
24+
int res;
2525

26-
/* copy a to b */
27-
if (a != b) {
28-
if ((res = mp_copy(a, b)) != MP_OKAY) {
29-
return res;
30-
}
31-
}
26+
/* copy a to b */
27+
if (a != b) {
28+
if ((res = mp_copy(a, b)) != MP_OKAY) {
29+
return res;
30+
}
31+
}
3232

33-
/* force the sign of b to positive */
34-
b->sign = MP_ZPOS;
33+
/* force the sign of b to positive */
34+
b->sign = MP_ZPOS;
3535

36-
return MP_OKAY;
36+
return MP_OKAY;
3737
}
3838
#endif
3939

0 commit comments

Comments
 (0)