upvote
It's still impossible to control actual timing, but easy to ensure control flow isn't data-dependent, which is what you need. Classic example is memcmp. Although you can write the or-then-check-zero memcmp in any high level language and it's very unlikely to compile to data-dependent timing unless your compiler is AGI.
reply
> Although you can write the or-then-check-zero memcmp in any high level language and it's very unlikely to compile to data-dependent timing unless your compiler is AGI.

No need for "AGI", the compiler just needs to have enough value tracking to know that the value saturates (once a bit is set, it never gets unset), and an heuristic to move the comparison inside the loop when it might allow it to do less loop iterations.

(I wrote a Rust crate to do precisely that kind of "constant time memcmp", and the only truly reliable way to do so without help of the compiler, is by using inline assembly as a "black box" to make a few things invisible to the compiler's optimizer. It was inspired by code in the Linux kernel which did the same thing also using inline assembly as a "black box".)

reply