diff options
Diffstat (limited to 'src/lib/libcrypto/bn/bn_div.c')
-rw-r--r-- | src/lib/libcrypto/bn/bn_div.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c index acacfb1a8c..7ada277402 100644 --- a/src/lib/libcrypto/bn/bn_div.c +++ b/src/lib/libcrypto/bn/bn_div.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_div.c,v 1.36 2023/01/31 06:08:23 jsing Exp $ */ | 1 | /* $OpenBSD: bn_div.c,v 1.37 2023/02/13 04:25:37 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -338,10 +338,10 @@ BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, | |||
338 | wnump = &(snum->d[num_n - 1]); | 338 | wnump = &(snum->d[num_n - 1]); |
339 | 339 | ||
340 | /* Setup to 'res' */ | 340 | /* Setup to 'res' */ |
341 | res->neg = (numerator->neg ^ divisor->neg); | ||
342 | if (!bn_wexpand(res, (loop + 1))) | 341 | if (!bn_wexpand(res, (loop + 1))) |
343 | goto err; | 342 | goto err; |
344 | res->top = loop - no_branch; | 343 | res->top = loop - no_branch; |
344 | BN_set_negative(res, numerator->neg ^ divisor->neg); | ||
345 | resp = &(res->d[loop - 1]); | 345 | resp = &(res->d[loop - 1]); |
346 | 346 | ||
347 | /* space for temp */ | 347 | /* space for temp */ |
@@ -414,8 +414,7 @@ BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, | |||
414 | int neg = numerator->neg; | 414 | int neg = numerator->neg; |
415 | 415 | ||
416 | BN_rshift(remainder, snum, norm_shift); | 416 | BN_rshift(remainder, snum, norm_shift); |
417 | if (!BN_is_zero(remainder)) | 417 | BN_set_negative(remainder, neg); |
418 | remainder->neg = neg; | ||
419 | } | 418 | } |
420 | 419 | ||
421 | if (no_branch) | 420 | if (no_branch) |