summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIaroslav Gridin <iaroslav.gridin@tuni.fi>2023-04-20 13:13:37 +0000
committerIaroslav Gridin <iaroslav.gridin@tuni.fi>2023-04-20 13:13:37 +0000
commit00596c167335912314757fd6efc4b46c9c3c029a (patch)
tree435d68494377b452f0a750e26878b575e9c11d0c /lib
parent1703ee6734711462b7ead4cbcedd95a961f39aaa (diff)
downloadnss-hg-00596c167335912314757fd6efc4b46c9c3c029a.tar.gz
Bug 1784163 - Fix reading raw negative numbers r=nss-reviewers,nkulatova,mt
set sign after adding digits Differential Revision: https://phabricator.services.mozilla.com/D154315
Diffstat (limited to 'lib')
-rw-r--r--lib/freebl/mpi/mpi.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/freebl/mpi/mpi.c b/lib/freebl/mpi/mpi.c
index bc4c148d6..2e6cd8466 100644
--- a/lib/freebl/mpi/mpi.c
+++ b/lib/freebl/mpi/mpi.c
@@ -2520,12 +2520,6 @@ mp_read_raw(mp_int *mp, char *str, int len)
mp_zero(mp);
- /* Get sign from first byte */
- if (ustr[0])
- SIGN(mp) = NEG;
- else
- SIGN(mp) = ZPOS;
-
/* Read the rest of the digits */
for (ix = 1; ix < len; ix++) {
if ((res = mp_mul_d(mp, 256, mp)) != MP_OKAY)
@@ -2534,6 +2528,12 @@ mp_read_raw(mp_int *mp, char *str, int len)
return res;
}
+ /* Get sign from first byte */
+ if (ustr[0])
+ SIGN(mp) = NEG;
+ else
+ SIGN(mp) = ZPOS;
+
return MP_OKAY;
} /* end mp_read_raw() */