3 ms·
C has enough security questions hanging around it; for things like constant time operation, which has AFAIK never been promised anywhere in the C standards (and
by pjc50 2y ago
C has enough security questions hanging around it; for things like constant time operation, which has AFAIK never been promised anywhere in the C standards (and probably can't be!), I think the only reasonable solution is a new language specifically designed for the purpose.
Not for writing whole programs in, but for writing fairly small amounts of code that performs arithmetic and compiles to libraries with C linkage. No VM, not even any memory allocation (make the caller do that in advance with fixed-size areas).
Basically the "portable assembler" that people keep using C for despite its explicit promises in the standard to not be that.
- PaulDavisThe1st 2y ago> the only reasonable solution is a new language specifically designed for the purpose. actual assembler is just such a language, as is being discussed here.
- pjc50 2y agoSure - but that's not a portable language at all! Nor is it an especially good target for any kind of formal verification or even type-checking.
- saagarjha 2y agoNeither is C, to be fair.
- PaulDavisThe1st 2y agoGiven that to meet constant-time requirements, the language will need to guarantee more or less 1-for-1 (or more generally, M-for-N) translation to assembler, I don't think you're going to improve on the verification or type checking situation by changing the syntax to something else.
- fuhsnn 2y agoConstant-time programming itself isn't quite portable, RISC-V for example requires the Zkt extension to mandate it.
- variadix 2y agoAt least for C and C++, why don’t GCC/clang implement constant time primitives as intrinsics? It would be useful in the meantime to developers working on cryptographic code, would provide better guarantees, and could emit useful errors when compiling against platforms where such guarantees cannot be provided. It would also act as prior art for standardization. I’ve always thought it was strange that assembly wasn’t used for some of these primitives, since you don’t control the codegen, but letting the compiler provide intrinsics would solve the problem without requiring every project to write their own assembly routines.