[PATCH 1/5] mpi/ec: remove VLA usage
Jussi Kivilinna
jussi.kivilinna at iki.fi
Mon Oct 3 17:30:59 CEST 2022
On 3.10.2022 3.19, Jacob Bachmeyer wrote:
> Jussi Kivilinna wrote:
>> * mpi/ec-nist.c (_gcry_mpi_ec_nist192_mod, _gcry_mpi_ec_nist224_mod)
>> (_gcry_mpi_ec_nist256_mod, _gcry_mpi_ec_nist384_mod)
>> (_gcry_mpi_ec_nist521_mod): Avoid VLA for arrays on stack.
>> * mpi/ec.c (ec_secp256k1_mod): Avoid VLA for arrays on stack.
>> --
>>
>> Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
>> ---
>> mpi/ec-nist.c | 40 ++++++++++++++++++++--------------------
>> mpi/ec.c | 6 +++---
>> 2 files changed, 23 insertions(+), 23 deletions(-)
>>
>> diff --git a/mpi/ec-nist.c b/mpi/ec-nist.c
>> index 69b05a6d..14e3c3ab 100644
>> [...]
>> + mpi_limb64_t o[DIM(s)];
>> [...]
>> + mpi_limb64_t d[DIM(s)];
>> [...]
>> + mpi_limb64_t t[DIM(s)];
>> + mpi_limb64_t d[DIM(s)];
>> + mpi_limb64_t e[DIM(s)];
>> + const mpi_size_t wsize = DIM(s) - 1;
>> [...]
>> + mpi_limb64_t t[DIM(s)];
>> + mpi_limb64_t d[DIM(s)];
>> + mpi_limb64_t x[DIM(s)];
>> [...]
>> + mpi_limb_t s[(256 + BITS_PER_MPI_LIMB - 1) / BITS_PER_MPI_LIMB + 1];
>> + mpi_limb_t n[sizeof(s)];
>> + const mpi_size_t wsize = DIM(s) - 1;
>> mpi_limb_t cy, borrow;
>> mpi_ptr_t wp;
>
> Am I misreading the patch (e.g. sizeof(mpi_limb_t) == 1?) or did you miss a spot at the end?
>
I missed it at first, but fixed before pushing to master.
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=9978fc22045ca7623a6e0cbf704fb48ab1550419;hp=0cb29a5736cfcd6bce4ce2495cd0481f0bdb34a4
-Jussi
More information about the Gcrypt-devel
mailing list