3 ms·
Secure code can absolutely be correct and be optimised in a way that reduces its security. For example, to prevent timing attacks positive and negative code pa
by sjf 7y ago
Secure code can absolutely be correct and be optimised in a way that reduces its security.
For example, to prevent timing attacks positive and negative code paths should take the same amount of time. An optimising compiler could decide that the operations in the negative code path are irrevelant, which in terms of the actual work its doing is true, and remove them. Except now it has reintroduced the timing attack.
- chrisseaton 7y agoBut the C language has notion of how long anything takes. You cannot write a C program with two branches that take the same time in the first place, for the optimisation to upset that.