[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240516192806.GM19790@gate.crashing.org>
Date: Thu, 16 May 2024 14:28:06 -0500
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Andy Polyakov <appro@...ptogams.org>
Cc: Danny Tsen <dtsen@...ux.ibm.com>, linux-crypto@...r.kernel.org,
herbert@...dor.apana.org.au, dtsen@...ibm.com, nayna@...ux.ibm.com,
linux-kernel@...r.kernel.org, ltcgcw@...ux.vnet.ibm.com,
leitao@...ian.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH 2/3] crypto: X25519 core functions for ppc64le
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
Powered by blists - more mailing lists