by sophacles · 17y ago · 0 comments
Since the usage of zip in that case will only compare the shorter of the strings to the start of the longer string, you can still achieve the timing attack, since the only inconsistency happens on the final comparison.
A better solution would be to check for length equality before doing the zip, or to pad the shorter of the strings compared to the length of the longer. Maybe also to just make the return statement:
return (len(a) == len(b)) and (result == 0)
which may be sufficient.
Anyway, rambling thoughts aside: thanks for the article.