-/* $OpenBSD: bn_add.c,v 1.21 2023/02/02 18:39:26 jsing Exp $ */
+/* $OpenBSD: bn_add.c,v 1.22 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
}
- r->neg = r_neg;
+ BN_set_negative(r, r_neg);
+
return ret;
}
}
}
- r->neg = r_neg;
+ BN_set_negative(r, r_neg);
+
return ret;
}
-/* $OpenBSD: bn_div.c,v 1.36 2023/01/31 06:08:23 jsing Exp $ */
+/* $OpenBSD: bn_div.c,v 1.37 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
wnump = &(snum->d[num_n - 1]);
/* Setup to 'res' */
- res->neg = (numerator->neg ^ divisor->neg);
if (!bn_wexpand(res, (loop + 1)))
goto err;
res->top = loop - no_branch;
+ BN_set_negative(res, numerator->neg ^ divisor->neg);
resp = &(res->d[loop - 1]);
/* space for temp */
int neg = numerator->neg;
BN_rshift(remainder, snum, norm_shift);
- if (!BN_is_zero(remainder))
- remainder->neg = neg;
+ BN_set_negative(remainder, neg);
}
if (no_branch)
-/* $OpenBSD: bn_mont.c,v 1.36 2023/02/01 06:23:13 jsing Exp $ */
+/* $OpenBSD: bn_mont.c,v 1.37 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
if (!bn_wexpand(r, num))
return (0);
if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) {
- r->neg = a->neg^b->neg;
r->top = num;
bn_correct_top(r);
+ BN_set_negative(r, a->neg ^ b->neg);
return (1);
}
}
if (!bn_wexpand(r, max))
return (0);
- r->neg ^= n->neg;
+ BN_set_negative(r, r->neg ^ n->neg);
np = n->d;
rp = r->d;
if (!bn_wexpand(ret, nl))
return (0);
ret->top = nl;
- ret->neg = r->neg;
+ BN_set_negative(ret, r->neg);
rp = ret->d;
ap = &(r->d[nl]);
-/* $OpenBSD: bn_mpi.c,v 1.11 2022/11/26 16:08:51 tb Exp $ */
+/* $OpenBSD: bn_mpi.c,v 1.12 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
BN_free(a);
return (NULL);
}
- a->neg = neg;
+ BN_set_negative(a, neg);
if (neg) {
BN_clear_bit(a, BN_num_bits(a) - 1);
}
-/* $OpenBSD: bn_mul.c,v 1.30 2023/01/23 12:17:57 jsing Exp $ */
+/* $OpenBSD: bn_mul.c,v 1.31 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
rr->top = rn;
- rr->neg = a->neg ^ b->neg;
-
bn_correct_top(rr);
+ BN_set_negative(rr, a->neg ^ b->neg);
+
if (r != rr)
BN_copy(r, rr);
done:
-/* $OpenBSD: bn_print.c,v 1.37 2022/11/26 16:08:51 tb Exp $ */
+/* $OpenBSD: bn_print.c,v 1.38 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
ret->top = h;
bn_correct_top(ret);
- ret->neg = neg;
+
+ BN_set_negative(ret, neg);
*bn = ret;
return (num);
j = 0;
}
}
- ret->neg = neg;
bn_correct_top(ret);
+
+ BN_set_negative(ret, neg);
+
*bn = ret;
return (num);
return 0;
}
if (*a == '-')
- (*bn)->neg = 1;
+ BN_set_negative(*bn, 1);
return 1;
}
-/* $OpenBSD: bn_recp.c,v 1.17 2022/11/26 16:08:51 tb Exp $ */
+/* $OpenBSD: bn_recp.c,v 1.18 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
#endif
- r->neg = BN_is_zero(r) ? 0 : m->neg;
- d->neg = m->neg^recp->N.neg;
+ BN_set_negative(r, m->neg);
+ BN_set_negative(d, m->neg ^ recp->N.neg);
+
ret = 1;
err:
-/* $OpenBSD: bn_shift.c,v 1.20 2023/01/11 04:26:24 jsing Exp $ */
+/* $OpenBSD: bn_shift.c,v 1.21 2023/02/13 04:25:37 jsing Exp $ */
/*
* Copyright (c) 2022, 2023 Joel Sing <jsing@openbsd.org>
*
}
r->top = count;
- r->neg = a->neg;
-
bn_correct_top(r);
+ BN_set_negative(r, a->neg);
+
return 1;
}
*dst = *src >> rshift;
r->top = count;
- r->neg = a->neg;
-
bn_correct_top(r);
+ BN_set_negative(r, a->neg);
+
return 1;
}
-/* $OpenBSD: bn_sqr.c,v 1.24 2023/02/09 09:58:53 jsing Exp $ */
+/* $OpenBSD: bn_sqr.c,v 1.25 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
rr->top = rn;
- rr->neg = 0;
-
bn_correct_top(rr);
+ rr->neg = 0;
+
if (rr != r)
BN_copy(r, rr);
-/* $OpenBSD: bn_word.c,v 1.17 2023/01/28 16:33:34 jsing Exp $ */
+/* $OpenBSD: bn_word.c,v 1.18 2023/02/13 04:25:37 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
if (a->neg) {
a->neg = 0;
i = BN_sub_word(a, w);
- if (!BN_is_zero(a))
- a->neg=!(a->neg);
+ BN_set_negative(a, 1);
return (i);
}
for (i = 0; w != 0 && i < a->top; i++) {
if (a->neg) {
a->neg = 0;
i = BN_add_word(a, w);
- a->neg = 1;
+ BN_set_negative(a, 1);
return (i);
}
if ((a->top == 1) && (a->d[0] < w)) {
a->d[0] = w - a->d[0];
- a->neg = 1;
+ BN_set_negative(a, 1);
return (1);
}
i = 0;