summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_div.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c
index 7ada277402..686b957eb5 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.37 2023/02/13 04:25:37 jsing Exp $ */ 1/* $OpenBSD: bn_div.c,v 1.38 2023/02/14 18:19:27 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 *
@@ -237,7 +237,7 @@ static int
237BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, 237BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator,
238 const BIGNUM *divisor, BN_CTX *ctx, int ct) 238 const BIGNUM *divisor, BN_CTX *ctx, int ct)
239{ 239{
240 int norm_shift, i, loop; 240 int norm_shift, i, loop, r_neg;
241 BIGNUM *tmp, wnum, *snum, *sdiv, *res; 241 BIGNUM *tmp, wnum, *snum, *sdiv, *res;
242 BN_ULONG *resp, *wnump; 242 BN_ULONG *resp, *wnump;
243 BN_ULONG d0, d1; 243 BN_ULONG d0, d1;
@@ -341,7 +341,7 @@ BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator,
341 if (!bn_wexpand(res, (loop + 1))) 341 if (!bn_wexpand(res, (loop + 1)))
342 goto err; 342 goto err;
343 res->top = loop - no_branch; 343 res->top = loop - no_branch;
344 BN_set_negative(res, numerator->neg ^ divisor->neg); 344 r_neg = 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 */
@@ -420,6 +420,8 @@ BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator,
420 if (no_branch) 420 if (no_branch)
421 bn_correct_top(res); 421 bn_correct_top(res);
422 422
423 BN_set_negative(res, r_neg);
424
423 done: 425 done:
424 ret = 1; 426 ret = 1;
425 err: 427 err: