[PATCH] MPI helper of addition one limb, Least Leak Intended

NIIBE Yutaka gniibe at fsij.org
Mon Feb 17 06:26:56 CET 2025


Hello, Jussi,

Jussi Kivilinna <jussi.kivilinna at iki.fi> wrote:
> I think this function could use 'add_ssaaaa' macro to handle addition with
> carry.
>
> Something like this (completely untested):
>
>    cy = s2_limb;
>    while ( s1_size )
>      {
>        x = *s1_ptr;
>        add_ssaaaa(cy, x, 0, cy, 0, x);
>        *s1_ptr++ = x;
>        s1_size--;
>      }
>    return cy;

Good.  I'm going to push this to master for _gcry_mpih_add_1_lli
function.

Further, I'm goint to push the chnage for _gcry_mpih_add_lli
function as:

mpi_limb_t
_gcry_mpih_add_lli (mpi_ptr_t wp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t usize)
{
  mpi_size_t i;
  mpi_limb_t cy;

  cy = 0;
  for (i = 0; i < usize; i++)
    {
      mpi_limb_t u = up[i];
      mpi_limb_t v = vp[i];
      mpi_limb_t w;

      add_ssaaaa (cy, w, 0, u, 0, cy);
      add_ssaaaa (cy, w, cy, w, 0, v);
      wp[i] = w;
    }

  return cy;
}
-- 



More information about the Gcrypt-devel mailing list