3 ms·
The reason not to implement this in inline assembly is that you would have to implement unique assembly for each architecture supported, which would mean probab
by tprynn 7y ago
The reason not to implement this in inline assembly is that you would have to implement unique assembly for each architecture supported, which would mean probably dozens of different implementations, especially considering that even on a given architecture there are notable processor-family differences in whether the same multiply instruction is constant time or not.
In any case, I think it's safe to say that 'pornin knows more about writing safe C code (and dealing with strange compiler behavior) than almost anyone.
- andrewla 7y agoBut that's the core of the problem -- the code has to be architecture specific because the constant nature of integer multiplication depends on the processor architecture. Once you're writing a multiple for an XX-generation Intel processor, you might as well write it as assembly, rather than have a MUL_XX macro that will probably do the right thing.
- svnpenn 7y ago> I think it's safe to say that 'pornin knows more about writing safe C code > (and dealing with strange compiler behavior) than almost anyone. Yeah, I agree hehe: https://stackexchange.com/leagues/162/alltime/security https://stackexchange.com/leagues/162/alltime/security