-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
secp256k1_scalar_cmov not constant-time on ICC #777
Comments
The first two options are ok of this is ok as long as compilers don't start to play around with the cmov functions that we really use in the arithmetic routines. At the moment, I tend to believe that we should keep the three functions, i.e., add the |
The only reservation I have about the volatile trick is that there is a long history of compilers emitting broken code in the presence of volatile because almost nothing uses it. This has improved in recent times (like post GCC 7-ish) Otherwise it seems pretty reasonable and clean too. I didn't raise a concern about this because the particular usage where the volatile variable is assigned once then read from with nothing too interesting going on (no complex control flow, no scopes, etc.) is probably a usage that is least likely to expose bugs. It's my unverified belief that the volatile should have ~no performance impact, or at least we should be able to make a version that does. MISRA 2012 Rule 13.2 "The value of an expression and its persistent side effects shall be the I dubious of other approaches. If a compiler can't be trusted to leave simple bit operations alone all bets are off. E.g. cmovs using multiplies are at greater risk from compilers aggressively trying to eliminate multiplies (which I think was a factor in the ecdh u_last issue). x86/x86_64 assembly is pretty maintainable, but as you've probably noticed w/ arm ... it's not always so easy. I think we ought to try for something in C if we're at all able. ASM would let us be more sure and maybe faster-- where its supported. |
Sorry I can't follow. How is the existing workaround related to this rule? How would a volatile sandwich avoid memory accesses? Wouldn't it even introduce a second memory access? I agree with all you say otherwise. |
fun(int x) then use tmp2. So there is only one read from tmp1 and it can make a register copy of it. |
We talked somewhere else and figured out that @gmaxwell was under the wrong impression that the current |
AMD64 ICC 19.1.2.254
Your volatile tricks do not fool ICC.
Originally posted by @gmaxwell in #772 (comment)
The text was updated successfully, but these errors were encountered: