Proposal for Custom Test Frameworks in Rust
blog.jrenner.net11 pointsby djrenren0 comments
for (int i = 0; password[i] != 0 && entry[i] != 0; i++) {
if (password[i] != entry[i]) return false;
}
return true;
We can see that it takes fewer iterations to check entries which are incorrect earlier. For example, if the password is “foo” and the entry is “bar”, then we return in the first iteration, as opposed to the entry “fob” which returns on the third. Thus, if the programs termination time is affected by the secret value, could still detect timing variance because the full program would terminate faster even if each loop took the same amount of time.