1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-22 16:39:56 +08:00
Hanno Becker abdf67ee9f Cast number of operations to uint in MBEDTLS_ECP_BUDGET
Context:
The macro `MBEDTLS_ECP_BUDGET()` is called before performing a
number of potentially time-consuming ECC operations. If restartable
ECC is enabled, it wraps a call to `mbedtls_ecp_check_budget()`
which in turn checks if the requested number of operations can be
performed without exceeding the maximum number of consecutive ECC
operations.

Issue:
The function `mbedtls_ecp_check_budget()` expects a the number
of requested operations to be given as a value of type `unsigned`,
while some calls of the wrapper macro `MBEDTLS_ECP_BUDGET()` use
expressions of type `size_t`.
This rightfully leads to warnings about implicit truncation
from `size_t` to `unsigned` on some compilers.

Fix:
This commit makes the truncation explicit by adding an explicit cast
to `unsigned` in the expansion of the `MBEDTLS_ECP_BUDGET()` macro.

Justification:
Functionally, the new version is equivalent to the previous code.
The warning about truncation can be discarded because, as can be
inferred from `ecp.h`, the number of requested operations is never
larger than 1000.
2018-10-26 15:06:51 +01:00
..
2018-07-24 16:43:20 +01:00
2018-07-01 10:22:53 +03:00
2018-10-15 13:22:41 +02:00
2018-05-15 09:21:57 +01:00
2018-09-12 12:33:32 +02:00
2018-08-14 16:08:38 +01:00
2018-07-24 16:43:20 +01:00
2018-10-15 13:22:41 +02:00