On Wed, May 15, 2024 at 10:29:56AM +0200, Andy Polyakov wrote: > >+static void cswap(fe51 p, fe51 q, unsigned int bit) > > The "c" in cswap stands for "constant-time," and the problem is that > contemporary compilers have exhibited the ability to produce > non-constant-time machine code as result of compilation of the above > kind of technique. This can happen with *any* comnpiler, on *any* platform. In general, you have to write machine code if you want to be sure what machine code will eventually be executed. > The outcome is platform-specific and ironically some > of PPC code generators were observed to generate "most" > non-constant-time code. "Most" in sense that execution time variations > would be most easy to catch. One way to work around the problem, at > least for the time being, is to add 'asm volatile("" : "+r"(c))' after > you calculate 'c'. But there is no guarantee that the next compiler > version won't see through it, hence the permanent solution is to do it > in assembly. I can put together something... Such tricks can help ameliorate the problem, sure. But it is not a solution ever. Segher