mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-30 06:33:06 +00:00
7cba859235
In mbedtls_mpi_read_string, if the string is empty, return an empty bignum rather than a bignum with one limb with the value 0. Both representations are correct, so this is not, in principle, a user-visible change. The change does leak however through mbedtls_mpi_write_string in base 16 (but not in other bases), as it writes a bignum with 0 limbs as "" but a bignum with the value 0 and at least one limb as "00". This change makes it possible to construct an empty bignum through mbedtls_mpi_read_string, which is especially useful to construct test cases (a common use of mbedtls_mpi_read_string, as most formats use in production encode numbers in binary, to be read with mbedtls_mpi_read_binary or mbedtls_mpi_read_binary_le). Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>