Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src

   Date: Thu, 30 Aug 2012 11:44:41 -0400
   From: (Christos Zoulas)

   memcmp() does not promise alphabetical sorting. It just promises to do the
   byte comparison as unsigned so that the results are consistent. It is not
   complicated to do this at all, for example:

   consttime_memcmp(const void *s1, const void *s2, size_t n)
           int rv = 0, sv = 0;
           const unsigned char *p1 = s1, *p2 = s2;

                   if (rv == 0)
                           rv = *p1++ - *p2++;

Data-dependent branches are totally unacceptable for a routine whose
sole purpose is to avoid timing side channels.

Are there any applications that both want memcmp semantics and need to
avoid timing side channels?

Home | Main Index | Thread Index | Old Index