Hanno Becker defe56928e Make length of output explicit in mpi_mul_hlp()
The helper `mpi_mul_hlp()` performs a multiply-accumulate
operation `d += s * b`, where `d,b` are MPIs and `b` is a scalar.

Previously, only the length of `s` was specified, while `d` was
assumed to be 0-terminated of unspecified length.

This was leveraged at the end of the core multiplication steps
computingg the first `limb(s)` limbs of `d + s*b`: Namely, the
routine would keep on adding the current carry to `d` until none
was left. This can, in theory, run for an arbitrarily long time
if `d` has a tail of `0xFF`s, and hence the assumption of
`0`-termination.

This solution is both fragile and insecure -- the latter because
the carry-loop depends on the result of the multiplication.

This commit changes the signature of `mpi_mul_hlp()` to receive
the length of the output buffer, which must be greater or equal
to the length of the input buffer.

It is _not_ assumed that the output buffer is strictly larger
than the input buffer -- instead, the routine will simply return
any carry that's left. This will be useful in some applications
of this function. It is the responsibility of the caller to either
size the output appropriately so that no carry will be left, or
to handle the carry.

NOTE: The commit leaves the library in a state where it cannot
      be compiled since the call-sites of mpi_mul_hlp() have
      not yet been adjusted. This will be done in the subsequent
      commits.

Signed-off-by: Hanno Becker <hanno.becker@arm.com>
2022-04-06 06:59:29 +01:00
..
2021-03-10 12:52:37 +00:00
2021-06-28 09:24:07 +01:00
2021-08-19 09:55:41 +01:00
2021-10-21 11:33:37 +02:00
2021-06-17 21:46:29 +02:00
2021-09-27 16:22:08 +02:00
2021-06-25 12:46:40 +01:00
2021-06-08 16:45:41 +02:00
2021-08-19 09:31:55 +01:00
2021-06-28 09:24:07 +01:00
2021-04-07 12:45:35 +01:00
2021-03-29 14:20:18 +01:00
2021-03-29 14:20:18 +01:00
2021-04-07 12:45:35 +01:00
2021-06-16 10:34:25 +02:00
2021-03-10 12:52:37 +00:00
2021-06-28 09:24:07 +01:00
2021-06-08 16:45:41 +02:00
2022-03-23 20:54:38 +08:00
2022-03-23 11:42:06 +08:00
2021-04-15 11:19:47 +01:00
2021-12-02 18:03:12 +00:00
2021-09-08 22:04:13 +05:30
2020-11-25 13:10:50 +01:00
2021-12-06 07:50:27 +01:00
2022-02-14 12:24:56 +01:00
2021-08-19 09:31:55 +01:00
2021-08-19 09:31:55 +01:00
2022-03-16 13:45:41 +01:00
2022-03-31 14:13:57 +02:00
2022-03-29 17:08:49 +02:00
2022-03-29 17:43:56 +02:00
2022-03-21 15:26:19 +00:00