1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-27 07:37:05 +08:00
Gilles Peskine fa85cc2da5 mbedtls_mpi_sub_abs: check the range of the result when it happens
The function mbedtls_mpi_sub_abs first checked that A >= B and then
performed the subtraction, relying on the fact that A >= B to
guarantee that the carry propagation would stop, and not taking
advantage of the fact that the carry when subtracting two numbers can
only be 0 or 1. This made the carry propagation code a little hard to
follow.

Write an ad hoc loop for the carry propagation, checking the size of
the result. This makes termination obvious.

The initial check that A >= B is no longer needed, since the function
now checks that the carry propagation terminates, which is equivalent.
This is a slight performance gain.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-06-09 11:54:20 +02:00
..
2019-02-11 21:10:48 +00:00
2020-02-04 09:52:27 +01:00
2018-06-21 14:03:14 +03:00
2020-04-08 17:22:51 +01:00
2019-10-25 09:01:34 +01:00
2019-07-08 15:26:09 +02:00
2018-11-05 12:17:15 +00:00
2018-02-22 08:20:42 +00:00
2018-02-22 08:20:42 +00:00
2015-09-04 14:21:07 +02:00
2015-09-04 14:21:07 +02:00
2020-02-18 11:27:08 +01:00
2017-10-29 17:53:52 +02:00
2018-10-26 10:08:29 +01:00
2019-06-20 16:28:10 +01:00
2015-09-04 14:21:07 +02:00
2018-12-05 23:23:39 +00:00
2015-09-04 14:21:07 +02:00