Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bn_deprecated.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ mp_err mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_prim
#ifdef BN_MP_RAND_DIGIT_C
mp_err mp_rand_digit(mp_digit *r)
{
mp_err ret = s_mp_rand_source(r, sizeof(mp_digit));
mp_err err = s_mp_rand_source(r, sizeof(mp_digit));
*r &= MP_MASK;
return ret;
return err;
}
#endif
#ifdef BN_FAST_MP_INVMOD_C
Expand Down
6 changes: 3 additions & 3 deletions bn_mp_2expt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
*/
mp_err mp_2expt(mp_int *a, int b)
{
mp_err res;
mp_err err;

/* zero a as per default */
mp_zero(a);

/* grow a to accomodate the single bit */
if ((res = mp_grow(a, (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
return res;
if ((err = mp_grow(a, (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
return err;
}

/* set the used count of where the bit will go */
Expand Down
6 changes: 3 additions & 3 deletions bn_mp_abs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
*/
mp_err mp_abs(const mp_int *a, mp_int *b)
{
mp_err res;
mp_err err;

/* copy a to b */
if (a != b) {
if ((res = mp_copy(a, b)) != MP_OKAY) {
return res;
if ((err = mp_copy(a, b)) != MP_OKAY) {
return err;
}
}

Expand Down
10 changes: 5 additions & 5 deletions bn_mp_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mp_err mp_add(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_sign sa, sb;
mp_err res;
mp_err err;

/* get sign of both inputs */
sa = a->sign;
Expand All @@ -18,21 +18,21 @@ mp_err mp_add(const mp_int *a, const mp_int *b, mp_int *c)
/* both positive or both negative */
/* add their magnitudes, copy the sign */
c->sign = sa;
res = s_mp_add(a, b, c);
err = s_mp_add(a, b, c);
} else {
/* one positive, the other negative */
/* subtract the one with the greater magnitude from */
/* the one of the lesser magnitude. The result gets */
/* the sign of the one with the greater magnitude. */
if (mp_cmp_mag(a, b) == MP_LT) {
c->sign = sb;
res = s_mp_sub(b, a, c);
err = s_mp_sub(b, a, c);
} else {
c->sign = sa;
res = s_mp_sub(a, b, c);
err = s_mp_sub(a, b, c);
}
}
return res;
return err;
}

#endif
10 changes: 5 additions & 5 deletions bn_mp_add_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
/* single digit addition */
mp_err mp_add_d(const mp_int *a, mp_digit b, mp_int *c)
{
mp_err res;
mp_err err;
int ix, oldused;
mp_digit *tmpa, *tmpc, mu;

/* grow c as required */
if (c->alloc < (a->used + 1)) {
if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
return res;
if ((err = mp_grow(c, a->used + 1)) != MP_OKAY) {
return err;
}
}

Expand All @@ -24,15 +24,15 @@ mp_err mp_add_d(const mp_int *a, mp_digit b, mp_int *c)
a_.sign = MP_ZPOS;

/* c = |a| - b */
res = mp_sub_d(&a_, b, c);
err = mp_sub_d(&a_, b, c);

/* fix sign */
c->sign = MP_NEG;

/* clamp */
mp_clamp(c);

return res;
return err;
}

/* old number of used digits in c */
Expand Down
14 changes: 7 additions & 7 deletions bn_mp_addmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
/* d = a + b (mod c) */
mp_err mp_addmod(const mp_int *a, const mp_int *b, const mp_int *c, mp_int *d)
{
mp_err res;
mp_err err;
mp_int t;

if ((res = mp_init(&t)) != MP_OKAY) {
return res;
if ((err = mp_init(&t)) != MP_OKAY) {
return err;
}

if ((res = mp_add(a, b, &t)) != MP_OKAY) {
if ((err = mp_add(a, b, &t)) != MP_OKAY) {
mp_clear(&t);
return res;
return err;
}
res = mp_mod(&t, c, d);
err = mp_mod(&t, c, d);
mp_clear(&t);
return res;
return err;
}
#endif
10 changes: 5 additions & 5 deletions bn_mp_and.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c)
{
int ix, px;
mp_err res;
mp_err err;
mp_int t;
const mp_int *x;

if (a->used > b->used) {
if ((res = mp_init_copy(&t, a)) != MP_OKAY) {
return res;
if ((err = mp_init_copy(&t, a)) != MP_OKAY) {
return err;
}
px = b->used;
x = b;
} else {
if ((res = mp_init_copy(&t, b)) != MP_OKAY) {
return res;
if ((err = mp_init_copy(&t, b)) != MP_OKAY) {
return err;
}
px = a->used;
x = a;
Expand Down
4 changes: 2 additions & 2 deletions bn_mp_complement.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* b = ~a */
mp_err mp_complement(const mp_int *a, mp_int *b)
{
mp_err res = mp_neg(a, b);
return (res == MP_OKAY) ? mp_sub_d(b, 1uL, b) : res;
mp_err err = mp_neg(a, b);
return (err == MP_OKAY) ? mp_sub_d(b, 1uL, b) : err;
}
#endif
6 changes: 3 additions & 3 deletions bn_mp_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mp_err mp_copy(const mp_int *a, mp_int *b)
{
int n;
mp_err res;
mp_err err;

/* if dst == src do nothing */
if (a == b) {
Expand All @@ -16,8 +16,8 @@ mp_err mp_copy(const mp_int *a, mp_int *b)

/* grow dest */
if (b->alloc < a->used) {
if ((res = mp_grow(b, a->used)) != MP_OKAY) {
return res;
if ((err = mp_grow(b, a->used)) != MP_OKAY) {
return err;
}
}

Expand Down
6 changes: 3 additions & 3 deletions bn_mp_decr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
/* Decrement "a" by one like "a--". Changes input! */
mp_err mp_decr(mp_int *a)
{
mp_err e = MP_OKAY;
if (MP_IS_ZERO(a)) {
mp_set(a,1uL);
a->sign = MP_NEG;
return MP_OKAY;
} else if (a->sign == MP_NEG) {
mp_err err;
a->sign = MP_ZPOS;
if ((e = mp_incr(a)) != MP_OKAY) {
return e;
if ((err = mp_incr(a)) != MP_OKAY) {
return err;
}
/* There is no -0 in LTM */
if (!MP_IS_ZERO(a)) {
Expand Down
Loading