Re: [PATCH] MPI helper of comparison, Least Leak Intended

NIIBE Yutaka via Gcrypt-devel <[email protected]>
Newsgroups gmane.comp.encryption.gpg.libgcrypt.devel
Message-ID <[email protected]>
NIIBE Yutaka <[email protected]> wrote:
> Jussi Kivilinna <[email protected]> wrote:
>>    int
>>    _gcry_mpih_cmp_lli (mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size)
>>    {
>>      mpi_size_t i;
>>      mpi_limb_t res_gt = 0;
>>      mpi_limb_t res_lt = 0;
>>
>>      for (i = 0; i < size ; i++)
>>        {
>>          mpi_limb_t gt, lt, eq, neq;
>>          gt = mpih_ct_limb_greater_than (up[i], vp[i]);
>>          lt = mpih_ct_limb_less_than (up[i], vp[i]);
>>          neq = ct_limb_gen_mask(gt | lt);
>>          eq = ct_limb_gen_inv_mask(gt | lt);
>>          res_gt = (eq & res_gt) | (neq & gt);
>>          res_lt = (eq & res_lt) | (neq & lt);
>>        }
>>
>>      return (int)(res_gt - res_lt); /* return 0 if U==V, 1 if U>V, -1 if U<V */
>>    }
>
> Please apply and push this version, because it's the way the function
> name suggests (returning -1, 0, 1).

I'm going to push this implementation to master.
--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.